Changeset 395 for cpp/frams


Ignore:
Timestamp:
06/23/15 00:50:52 (6 years ago)
Author:
Maciej Komosinski
Message:

Fixed int/bool warnings

Location:
cpp/frams/util
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/util/sstring-simple.cpp

    r385 r395  
    167167///////////////////////////////////////
    168168
    169 int SString::equals(const SString& s) const
    170 {
    171 if (this==&s) return 1;
    172 if (len()!=s.len()) return 0;
    173 return !strcmp(getPtr(),s.getPtr());
     169bool SString::equals(const SString& s) const
     170{
     171if (this==&s) return true;
     172if (len()!=s.len()) return false;
     173return strcmp(getPtr(),s.getPtr())==0;
    174174}
    175175
     
    194194}
    195195
    196 int SString::getNextToken (int& pos,SString &token,char separator) const
    197 {
    198 if (pos>=len()) {token=0;return 0;}
     196bool SString::getNextToken (int& pos,SString &token,char separator) const
     197{
     198if (pos>=len()) {token=0;return false;}
    199199int p1=pos,p2;
    200200const char *t1=getPtr()+pos;
     
    203203strncpy(token.directWrite(p2-p1),t1,p2-p1);
    204204token.endWrite(p2-p1);
    205 return 1;
    206 }
    207 
    208 int SString::startsWith(const char *pattern) const
     205return true;
     206}
     207
     208bool SString::startsWith(const char *pattern) const
    209209{
    210210const char *t=this->c_str();
    211211for (;*pattern;pattern++,t++)
    212         if (*t != *pattern) return 0;
    213 return 1;
     212        if (*t != *pattern) return false;
     213return true;
    214214}
    215215
  • cpp/frams/util/sstring-simple.h

    r385 r395  
    110110void operator+=(const SString&); ///< append other SString
    111111
    112 int equals(const SString &s) const; ///< TRUE if equal
    113 int operator==(const SString &s) const {return equals(s);} ///< TRUE if equal
    114 int operator!=(const SString &s) const {return !equals(s);} ///< TRUE if not equal
     112bool equals(const SString &s) const; ///< TRUE if equal
     113bool operator==(const SString &s) const {return equals(s);} ///< TRUE if equal
     114bool operator!=(const SString &s) const {return !equals(s);} ///< TRUE if not equal
    115115bool operator<(const SString &s) const {return strcmp(getPtr(),s.getPtr())<1;}
    116116const char* operator()(int p) const {return getPtr()+p;} ///< pointer to p'th character in SString
     
    125125/// <B>pos</B> is moved accordingly.
    126126/// returns <B>false</B> if no more tokens are available or <B>true</B> otherwise.
    127 int getNextToken(int& pos,SString &token,char separator) const;
     127bool getNextToken(int& pos,SString &token,char separator) const;
    128128
    129129void operator+=(char ch) {directAppend(1)[0]=ch;endAppend(1);} ///< append single character
    130130
    131 int startsWith(const char *pattern) const;
     131bool startsWith(const char *pattern) const;
    132132char charAt(int pos) const {return operator[](pos);}
    133133uint32_t hash() const;
  • cpp/frams/util/sstring.cpp

    r367 r395  
    333333}
    334334
    335 int SString::getNextToken (int& pos,SString &token,char separator) const
    336 {
    337 if (pos>=len()) {token=0;return 0;}
     335bool SString::getNextToken (int& pos,SString &token,char separator) const
     336{
     337if (pos>=len()) {token=0;return false;}
    338338int p1=pos,p2;
    339339const char *t1=buf->txt+pos;
     
    342342strncpy(token.directWrite(p2-p1),t1,p2-p1);
    343343token.endWrite(p2-p1);
    344 return 1;
    345 }
    346 
    347 int SString::startsWith(const char *pattern) const
     344return true;
     345}
     346
     347bool SString::startsWith(const char *pattern) const
    348348{
    349349const char *t=this->c_str();
    350350for (;*pattern;pattern++,t++)
    351         if (*t != *pattern) return 0;
    352 return 1;
     351        if (*t != *pattern) return false;
     352return true;
    353353}
    354354
  • cpp/frams/util/sstring.h

    r385 r395  
    171171/// <B>pos</B> is moved accordingly.
    172172/// returns <B>false</B> if no more tokens are available or <B>true</B> otherwise.
    173 int getNextToken(int& pos,SString &token,char separator) const;
     173bool getNextToken(int& pos,SString &token,char separator) const;
    174174
    175175void operator+=(char ch) {directAppend(1)[0]=ch;endAppend(1);} ///< append single character
    176176
    177 int startsWith(const char *pattern) const;
     177bool startsWith(const char *pattern) const;
    178178char charAt(int pos) const {return buf->txt[pos];}
    179179uint32_t hash() const {return buf->hash();}
Note: See TracChangeset for help on using the changeset viewer.