PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
string_lower_upper.cpp
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 
8 #include "string_lower_upper.h"
9 
11 
14 bool isCharNumber(char ch){
15  return (ch >= 48 && ch <= 57);
16 }
17 
19 
22 bool isStrNumber(const std::string & str){
23  if(str.size() == 0lu){return false;}
24  bool isMatch(true);
25  long unsigned int i(0lu);
26  while(i < str.size() && isMatch){
27  isMatch = isCharNumber(str[i]);
28  ++i;
29  }
30  return isMatch;
31 }
32 
34 
37 bool isListStrNumber(const std::list<std::string> & listStr){
38  if(listStr.size() == 0lu){return false;}
39  bool isMatch(true);
40  std::list<std::string>::const_iterator it(listStr.begin());
41  while(isMatch && it != listStr.end()){
42  isMatch &= isStrNumber(*it);
43  ++it;
44  }
45  return isMatch;
46 }
47 
49 
52 bool isCharNumberOrDot(char ch){
53  return ((ch >= 48 && ch <= 57) || ch == '.');
54 }
55 
57 
61  return ((ch >= 48 && ch <= 57) || ch == '.' || ch == '-' || ch == '+' || ch == 'e' || ch == 'E');
62 }
63 
65 
68 bool isStrNumberOrDot(const std::string & str){
69  if(str.size() == 0l){return false;}
70  bool isMatch(true);
71  long unsigned int i(0lu);
72  while(i < str.size() && isMatch){
73  isMatch = isCharNumberOrDot(str[i]);
74  ++i;
75  }
76  return isMatch;
77 }
78 
80 
83 bool isStrNumberDotMinusPlusE(const std::string & str){
84  if(str.size() == 0lu){return false;}
85  bool isMatch(true);
86  long unsigned int i(0lu);
87  while(i < str.size() && isMatch){
88  isMatch = isCharNumberDotMinusPlusE(str[i]);
89  ++i;
90  }
91  return isMatch;
92 }
93 
95 
98 bool isCharLetter(char ch){
99  return (((int)ch >= 65 && (int)ch <= 90) || ((int)ch >= 97 && (int)ch <= 122) || ((int)ch == 95));
100 }
101 
103 
106 bool isCharNumberOrLetter(char ch){
107  return ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || (ch == 95) || (ch >= 48 && ch <= 57));
108 }
109 
111 
115  return ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || (ch == 95) || (ch >= 48 && ch <= 57) || (ch == '.'));
116 }
117 
119 
122 bool isCharNumberOrStar(char ch){
123  return ((ch >= 48 && ch <= 57) || ch == '*');
124 }
125 
127 
130 bool isCharLetterOrStar(char ch){
131  return (((int)ch >= 65 && (int)ch <= 90) || ((int)ch >= 97 && (int)ch <= 122) || ((int)ch == 95) || ch == '*');
132 }
133 
135 
139  return ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || (ch == 95) || (ch >= 48 && ch <= 57) || ch == '*');
140 }
141 
143 
146 bool isCharUpperCase(char ch){
147  return (ch >= 65 && ch <= 90);
148 }
149 
151 
154 bool isCharLowerCase(char ch){
155  return (ch >= 97 && ch <= 122);
156 }
157 
159 
162 bool isStrUpperCase(const std::string & str){
163  bool isUpper(true);
164  size_t i(0lu);
165  while(i < str.size() && isUpper){
166  isUpper = isCharUpperCase(str[i]);
167  ++i;
168  }
169  return isUpper;
170 }
171 
173 
176 bool isStrLowerCase(const std::string & str){
177  bool isLower(true);
178  size_t i(0lu);
179  while(i < str.size() && isLower){
180  isLower = isCharLowerCase(str[i]);
181  ++i;
182  }
183  return isLower;
184 }
185 
187 
190 std::string strToLower(const std::string & str){
191  std::string strOut("");
192  char currentChar;
193  long unsigned int size(str.size());
194  for(long unsigned int i(0lu); i < size; ++i){
195  currentChar = str[i];
196  if(isCharUpperCase(currentChar)){
197  strOut += currentChar + (char)32;
198  }else{
199  strOut += currentChar;
200  }
201  }
202  return strOut;
203 }
204 
206 
209 std::string strToUpper(const std::string & str){
210  std::string strOut("");
211  char currentChar;
212  long unsigned int size(str.size());
213  for(long unsigned int i(0); i < size; ++i){
214  currentChar = str[i];
215  if(isCharLowerCase(currentChar)){
216  strOut += currentChar - (char)32;
217  }else{
218  strOut += currentChar;
219  }
220  }
221  return strOut;
222 }
223 
225 
228 std::string strToLowerUnderscore(const std::string & str){
229  std::string strOut("");
230  char currentChar;
231  long unsigned int size(str.size());
232  for(long unsigned int i(0lu); i < size; ++i){
233  currentChar = str[i];
234  if(isCharUpperCase(currentChar)){
235  strOut += currentChar + (char)32;
236  }else{
237  if(currentChar == ' ') strOut += '_';
238  else strOut += currentChar;
239  }
240  }
241  return strOut;
242 }
243 
245 
248 std::string firstToUpper(const std::string & str){
249  if(str.size() == 0lu) return "";
250  std::string strOut(str);
251  char currentChar = strOut[0lu];
252  if(isCharLowerCase(currentChar)){
253  strOut[0lu] = currentChar - (char)32;
254  }
255  return strOut;
256 }
257 
259 
262 std::string firstToLower(const std::string & str){
263  if(str.size() == 0lu) return "";
264  std::string strOut(str);
265  char currentChar = strOut[0lu];
266  if(isCharUpperCase(currentChar)){
267  strOut[0lu] = currentChar + (char)32;
268  }
269  return strOut;
270 }
271 
272 
273 
isCharNumberOrLetterOrDot
bool isCharNumberOrLetterOrDot(char ch)
Tels if the character is a letter, number, '.' or '_'.
Definition: string_lower_upper.cpp:114
firstToLower
std::string firstToLower(const std::string &str)
Convert first letter of the std::string in lower case.
Definition: string_lower_upper.cpp:262
isStrUpperCase
bool isStrUpperCase(const std::string &str)
Say if the given std::string is in uppercase.
Definition: string_lower_upper.cpp:162
strToLower
std::string strToLower(const std::string &str)
Convert std::string in lower case.
Definition: string_lower_upper.cpp:190
isCharLetter
bool isCharLetter(char ch)
Tels if the character is a letter or '_'.
Definition: string_lower_upper.cpp:98
firstToUpper
std::string firstToUpper(const std::string &str)
Convert first letter of the std::string in upper case.
Definition: string_lower_upper.cpp:248
strToLowerUnderscore
std::string strToLowerUnderscore(const std::string &str)
Convert std::string in lower case and space in '_'.
Definition: string_lower_upper.cpp:228
isStrLowerCase
bool isStrLowerCase(const std::string &str)
Say if the given std::string is in lowercase.
Definition: string_lower_upper.cpp:176
isCharNumberOrLetterOrStar
bool isCharNumberOrLetterOrStar(char ch)
Tels if the character is letter, number, star or '_'.
Definition: string_lower_upper.cpp:138
isCharUpperCase
bool isCharUpperCase(char ch)
Tels if the character is upper case letter.
Definition: string_lower_upper.cpp:146
isCharLowerCase
bool isCharLowerCase(char ch)
Tels if the character is lower case letter.
Definition: string_lower_upper.cpp:154
isCharNumberOrStar
bool isCharNumberOrStar(char ch)
Tels if the character is number or star.
Definition: string_lower_upper.cpp:122
isStrNumber
bool isStrNumber(const std::string &str)
Tels if std::string contains figures.
Definition: string_lower_upper.cpp:22
isCharNumberOrDot
bool isCharNumberOrDot(char ch)
Tels if the character is a number or a '.'.
Definition: string_lower_upper.cpp:52
string_lower_upper.h
isCharLetterOrStar
bool isCharLetterOrStar(char ch)
Tels if the character is letter, star or '_'.
Definition: string_lower_upper.cpp:130
createReleaseCurl.str
str
Definition: createReleaseCurl.py:128
isListStrNumber
bool isListStrNumber(const std::list< std::string > &listStr)
Say if the list of std::string contains a number.
Definition: string_lower_upper.cpp:37
isCharNumberOrLetter
bool isCharNumberOrLetter(char ch)
Tels if the character is letter, figure or '_'.
Definition: string_lower_upper.cpp:106
isCharNumber
bool isCharNumber(char ch)
Tels if the character is a number or not.
Definition: string_lower_upper.cpp:14
isCharNumberDotMinusPlusE
bool isCharNumberDotMinusPlusE(char ch)
Tels if the character is a figure, a '.', a -, +, e or E.
Definition: string_lower_upper.cpp:60
strToUpper
std::string strToUpper(const std::string &str)
Convert std::string in upper case.
Definition: string_lower_upper.cpp:209
isStrNumberOrDot
bool isStrNumberOrDot(const std::string &str)
Tels if std::string contains figures or dots.
Definition: string_lower_upper.cpp:68
isStrNumberDotMinusPlusE
bool isStrNumberDotMinusPlusE(const std::string &str)
Tels if std::string std::string contains figures, '.', -, +, e or E.
Definition: string_lower_upper.cpp:83