- Timestamp:
- 06/23/15 00:50:52 (10 years ago)
- Location:
- cpp/frams/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/sstring-simple.cpp
r385 r395 167 167 /////////////////////////////////////// 168 168 169 intSString::equals(const SString& s) const170 { 171 if (this==&s) return 1;172 if (len()!=s.len()) return 0;173 return !strcmp(getPtr(),s.getPtr());169 bool SString::equals(const SString& s) const 170 { 171 if (this==&s) return true; 172 if (len()!=s.len()) return false; 173 return strcmp(getPtr(),s.getPtr())==0; 174 174 } 175 175 … … 194 194 } 195 195 196 intSString::getNextToken (int& pos,SString &token,char separator) const197 { 198 if (pos>=len()) {token=0;return 0;}196 bool SString::getNextToken (int& pos,SString &token,char separator) const 197 { 198 if (pos>=len()) {token=0;return false;} 199 199 int p1=pos,p2; 200 200 const char *t1=getPtr()+pos; … … 203 203 strncpy(token.directWrite(p2-p1),t1,p2-p1); 204 204 token.endWrite(p2-p1); 205 return 1;206 } 207 208 intSString::startsWith(const char *pattern) const205 return true; 206 } 207 208 bool SString::startsWith(const char *pattern) const 209 209 { 210 210 const char *t=this->c_str(); 211 211 for (;*pattern;pattern++,t++) 212 if (*t != *pattern) return 0;213 return 1;212 if (*t != *pattern) return false; 213 return true; 214 214 } 215 215 -
cpp/frams/util/sstring-simple.h
r385 r395 110 110 void operator+=(const SString&); ///< append other SString 111 111 112 intequals(const SString &s) const; ///< TRUE if equal113 intoperator==(const SString &s) const {return equals(s);} ///< TRUE if equal114 intoperator!=(const SString &s) const {return !equals(s);} ///< TRUE if not equal112 bool equals(const SString &s) const; ///< TRUE if equal 113 bool operator==(const SString &s) const {return equals(s);} ///< TRUE if equal 114 bool operator!=(const SString &s) const {return !equals(s);} ///< TRUE if not equal 115 115 bool operator<(const SString &s) const {return strcmp(getPtr(),s.getPtr())<1;} 116 116 const char* operator()(int p) const {return getPtr()+p;} ///< pointer to p'th character in SString … … 125 125 /// <B>pos</B> is moved accordingly. 126 126 /// returns <B>false</B> if no more tokens are available or <B>true</B> otherwise. 127 intgetNextToken(int& pos,SString &token,char separator) const;127 bool getNextToken(int& pos,SString &token,char separator) const; 128 128 129 129 void operator+=(char ch) {directAppend(1)[0]=ch;endAppend(1);} ///< append single character 130 130 131 intstartsWith(const char *pattern) const;131 bool startsWith(const char *pattern) const; 132 132 char charAt(int pos) const {return operator[](pos);} 133 133 uint32_t hash() const; -
cpp/frams/util/sstring.cpp
r367 r395 333 333 } 334 334 335 intSString::getNextToken (int& pos,SString &token,char separator) const336 { 337 if (pos>=len()) {token=0;return 0;}335 bool SString::getNextToken (int& pos,SString &token,char separator) const 336 { 337 if (pos>=len()) {token=0;return false;} 338 338 int p1=pos,p2; 339 339 const char *t1=buf->txt+pos; … … 342 342 strncpy(token.directWrite(p2-p1),t1,p2-p1); 343 343 token.endWrite(p2-p1); 344 return 1;345 } 346 347 intSString::startsWith(const char *pattern) const344 return true; 345 } 346 347 bool SString::startsWith(const char *pattern) const 348 348 { 349 349 const char *t=this->c_str(); 350 350 for (;*pattern;pattern++,t++) 351 if (*t != *pattern) return 0;352 return 1;351 if (*t != *pattern) return false; 352 return true; 353 353 } 354 354 -
cpp/frams/util/sstring.h
r385 r395 171 171 /// <B>pos</B> is moved accordingly. 172 172 /// returns <B>false</B> if no more tokens are available or <B>true</B> otherwise. 173 intgetNextToken(int& pos,SString &token,char separator) const;173 bool getNextToken(int& pos,SString &token,char separator) const; 174 174 175 175 void operator+=(char ch) {directAppend(1)[0]=ch;endAppend(1);} ///< append single character 176 176 177 intstartsWith(const char *pattern) const;177 bool startsWith(const char *pattern) const; 178 178 char charAt(int pos) const {return buf->txt[pos];} 179 179 uint32_t hash() const {return buf->hash();}
Note: See TracChangeset
for help on using the changeset viewer.