Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
arcane/src/arcane/utils/CStringUtils.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* CStringUtils.cc (C) 2000-2015 */
9/* */
10/* Fonctions utilitaires sur les chaînes de caractères. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/utils/StdHeader.h"
17#include "arcane/utils/ValueConvert.h"
18#include "arcane/utils/CStringUtils.h"
19#include "arcane/utils/Iostream.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24ARCANE_BEGIN_NAMESPACE
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29Real CStringUtils::
30toReal(const char* str,bool* is_ok)
31{
32 Real v = 0.;
33 bool is_bad = builtInGetValue(v,str);
34 if (is_ok)
35 *is_ok = !is_bad;
36 return v;
37}
38
39Integer
40CStringUtils::
41toInteger(const char* str,bool* is_ok)
42{
43 Integer v = 0;
44 bool is_bad = builtInGetValue(v,str);
45 if (is_ok)
46 *is_ok = !is_bad;
47 return v;
48}
49
50int
51CStringUtils::
52toInt(const char* str,bool* is_ok)
53{
54 int v = 0;
55 bool is_bad = builtInGetValue(v,str);
56 if (is_ok)
57 *is_ok = !is_bad;
58 return v;
59}
60
62bool CStringUtils::
63isEqual(const char* s1,const char* s2)
64{
65 if (!s1 && !s2)
66 return true;
67 if (!s1 || !s2)
68 return false;
69 while (*s1==*s2){
70 if (*s1=='\0')
71 return true;
72 ++s1; ++s2;
73 }
74 return false;
75}
76
78bool CStringUtils::
79isLess(const char* s1,const char* s2)
80{
81 if (!s1 && !s2)
82 return false;
83 if (!s1 || !s2)
84 return false;
85 return (::strcmp(s1,s2) < 0);
86}
87
89Integer CStringUtils::
90len(const char* s)
91{
92 if (!s) return 0;
93 //return (Integer)::strlen(s);
94 Integer len = 0;
95 while(s[len]!='\0')
96 ++len;
97 return len;
98}
99
100char* CStringUtils::
101copyn(char* to,const char* from,Integer n)
102{
103 return ::strncpy(to,from,n);
104}
105
106char* CStringUtils::
107copy(char* to,const char* from)
108{
109 return ::strcpy(to,from);
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115extern "C++" ARCANE_UTILS_EXPORT void
116initializeStringConverter()
117{
118}
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123ARCANE_END_NAMESPACE
124
125/*---------------------------------------------------------------------------*/
126/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Integer len(const char *s)
Retourne la longueur de la chaîne s.