![]() |
![]() |
00001 #ifndef stringTools_h 00002 #define stringTools_h 00003 00004 #include<string> 00005 00009 int replace(std::string & input, const std::string& gone, const std::string& it, bool multiple=false); 00010 00014 int replaceRange(std::string & input, const std::string&first, const std::string& last, const std::string& it, bool multiple=false); 00015 00016 00017 /* 00018 remove leading and trailing "blanks" 00019 */ 00020 void strip(std::string & input, const std::string& blanks=" \n\t"); 00021 00022 00025 class stringUpdate{ 00026 public: 00027 stringUpdate(const std::string & is) : s(is), old(0){} 00028 00029 std::string operator()() { 00030 if (s.size()>old) { 00031 size_t d = old; 00032 old = s.size(); 00033 return s.substr(d); 00034 } 00035 else return std::string(); 00036 } 00037 00038 void reset() { old=0;} 00039 bool updated() const { return s.size()>old;} 00040 00041 private: 00042 00043 const std::string & s; 00044 size_t old; 00045 }; 00046 00047 00048 #endif // stringTools_h