librcsb-core-wrapper  1.000
GenString.h
Go to the documentation of this file.
1 //$$FILE$$
2 //$$VERSION$$
3 //$$DATE$$
4 //$$LICENSE$$
5 
6 
7 #ifndef GENSTRING_H
8 #define GENSTRING_H
9 
10 
11 #include <string>
12 #include <functional>
13 
14 
23 class Char
24 {
25  public:
27  {
30  eWS_INSENSITIVE, // But case-sensitive
32  };
33 
34  static char ToLower(const char c);
35  static char ToUpper(const char c);
36 
37  static bool IsCiLess(const char c1, const char c2);
38 
39  static bool IsWhiteSpace(const char c);
40  static bool IsDigit(const char c);
41 };
42 
43 
52 class CharLess
53 {
54  public:
56 
57  CharLess& operator=(const CharLess& in);
58 
59  bool operator()(const char c1, const char c2) const;
60 
62 
63  private:
64  Char::eCompareType _compareType;
65 };
66 
67 
76 class CharEqualTo : public std::binary_function<char, char, bool>
77 {
78  public:
80 
81  CharEqualTo& operator=(const CharEqualTo& in);
82 
83  bool operator()(const char c1, const char c2) const;
84 
86 
87  private:
88  Char::eCompareType _compareType;
89 };
90 
91 
92 class WhiteSpace : public std::unary_function<char, bool>
93 {
94  public:
95  bool operator()(const char c) const;
96  bool operator()(const char c1, const char c2) const;
97 };
98 
99 
109 {
110  public:
112 
113  StringLess& operator=(const StringLess& in);
114 
115  bool operator()(const std::string& s1, const std::string& s2) const;
116 
118 
119  private:
120  Char::eCompareType _compareType;
121 };
122 
123 
132 class StringEqualTo : public std::binary_function<std::string, std::string,
133  bool>
134 {
135  public:
137 
139 
140  bool operator()(const std::string& s1, const std::string& s2) const;
141 
143 
144  private:
145  Char::eCompareType _compareType;
146 };
147 
148 
160 class String
161 {
162  public:
163  static void LowerCase(const std::string& inString, std::string& outString);
164  static void LowerCase(std::string& inOutString);
165  static void UpperCase(const std::string& inString, std::string& outString);
166  static void UpperCase(std::string& inOutString);
167 
168  static void RemoveWhiteSpace(const std::string& inString,
169  std::string& outString);
170 
171  static std::string IntToString(int inInteger);
172  static std::string DoubleToString(double inDouble);
173  static int StringToInt(const std::string& inString);
174  static double StringToDouble(const std::string& inString);
175  static bool IsScientific(const std::string& number);
176  static void ToFixedFormat(std::string& fixedFormat,
177  const std::string& number);
178  static bool StringToBoolean(const std::string& inString);
179 
180  static bool IsNumber(const std::string& inString);
181 
182  static bool IsCiEqual(const std::string& firstString,
183  const std::string& secondString);
184  static bool IsEqual(const std::string& firstString,
185  const std::string& secondString,
186  const Char::eCompareType compareType);
187 
188  static void StripLeadingWs(std::string& resString);
189  static void StripTrailingWs(std::string& resString);
190  static void StripAndCompressWs(std::string& resString);
191  static void rcsb_clean_string(std::string& theString);
192 
193  static void UnEscape(std::string& outStr, const std::string& inStr);
194 
195  static void Replace(std::string& resString, const std::string& fromStr,
196  const std::string& toStr);
197 
198  private:
199  static std::string::const_iterator GetExpValue(int& expValue,
200  const std::string::const_iterator& beg,
201  const std::string::const_iterator& end);
202  static void GetMantissa(std::string& mantissa, int& addExpValue,
203  const std::string::const_iterator& beg,
204  const std::string::const_iterator& end);
205  static void ScientificNumberToFixed(std::string& fixed,
206  const bool isPositive, const std::string& mantissa, const int exponent);
207 };
208 
209 
211 {
212  return (_compareType);
213 }
214 
216 {
217  return (_compareType);
218 }
219 
220 #endif