My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
String.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_STRING_H
2 #define GCP_UTIL_STRING_H
3 
11 #include <string>
12 
13 namespace gcp {
14  namespace util {
15 
16  class String {
17  public:
18 
22  String();
23  String(unsigned int);
24  String(const std::string& str);
25 
29  virtual ~String();
30 
31  static void strip(std::string& targetStr, const std::string& stripStr);
32  static void strip(std::string& targetStr, char stripChar);
33 
34  void strip(const std::string& stripStr);
35  void strip(char stripChar);
36 
37  bool contains(char target);
38 
39  bool contains(std::string s);
40 
41  void replace(char stripChar, char replaceChar);
42  static void replace(std::string& targetStr, char stripChar, char replaceChar);
43 
44  void operator=(const std::string& str);
45  void operator=(const String str);
46 
47  bool operator<(String& str);
48  bool operator==(String str);
49  bool operator!=(String str);
50 
51  char& operator[](unsigned int index);
52 
53  inline std::string& str()
54  {
55  return str_;
56  }
57 
61  friend std::ostream& operator<<(std::ostream& os, String str);
62 
63  String findFirstInstanceOf(std::string start, bool useStart,
64  std::string stop, bool useStop);
65 
66  String findFirstInstanceOf(std::string start, std::string stop);
67 
68  String findFirstInstanceOf(std::string stop);
69 
70  String findNextInstanceOf(std::string start, bool useStart,
71  std::string stop, bool useStop, bool consumeStop=false);
72 
73  String findNextInstanceOf(std::string start, std::string stop);
74 
75  String findNextInstanceOf(std::string stop);
76 
77  String findNextString();
78 
79  String toLower();
80  String toUpper();
81 
82  static const std::string emptyString_;
83  static const std::string whiteSpace_;
84 
85  String findNextStringSeparatedByChars(std::string separators, bool matchEndOfString=true);
86  bool atEnd();
87  void resetToBeginning();
88 
89  void initialize();
90 
91  int toInt();
92  float toFloat();
93  double toDouble();
94 
95  bool isEmpty();
96  bool matches(unsigned char c, std::string matchSet);
97 
98  unsigned size();
99 
100  private:
101 
102  std::string::size_type iStart_;
103  std::string str_;
104 
105  }; // End class String
106 
107  } // End namespace util
108 } // End namespace gcp
109 
110 
111 
112 
113 #endif // End #ifndef GCP_UTIL_STRING_H
friend std::ostream & operator<<(std::ostream &os, String str)
String findNextStringSeparatedByChars(std::string separators, bool matchEndOfString=true)
Definition: String.cc:353
void operator=(const std::string &str)
Definition: String.cc:137
bool contains(char target)
Definition: String.cc:104
Definition: String.h:16
String findNextInstanceOf(std::string start, bool useStart, std::string stop, bool useStop, bool consumeStop=false)
Definition: String.cc:249
static void strip(std::string &targetStr, const std::string &stripStr)
Definition: String.cc:54
virtual ~String()
Definition: String.cc:48
void replace(char stripChar, char replaceChar)
Definition: String.cc:409
String()
Definition: String.cc:21