Changeset 2096 for trunk


Ignore:
Timestamp:
Nov 20, 2012, 1:23:09 AM (7 years ago)
Author:
sam
Message:

core: more string concatenation and comparison methods, plus a lot
of unit tests for the String class.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r2084 r2096  
    1818    \
    1919    lol/unit.h lol/debug.h \
     20    lol/core/array.h lol/core/string.h \
    2021    lol/math/vector.h lol/math/half.h lol/math/real.h lol/math/remez.h \
    2122    lol/math/math.h \
  • trunk/src/lol/core/string.h

    r2089 r2096  
    4545    }
    4646
     47    inline String(String const &s)
     48      : Super((Super const &)s)
     49    {
     50    }
     51
    4752    inline char &operator [](int n)
    4853    {
     
    5560    }
    5661
    57     inline String operator +(String const &s)
     62    inline int Count() const
     63    {
     64        return ((Super const &)*this).Count() - 1;
     65    }
     66
     67    inline String operator +(String const &s) const
    5868    {
    5969        String ret(*this);
     
    6878        return *this;
    6979    }
     80
     81    inline String operator +(char c) const
     82    {
     83        String ret(*this);
     84        return ret += c;
     85    }
     86
     87    inline String operator +=(char c)
     88    {
     89        ((Super &)*this).Last() = c;
     90        ((Super &)*this).Push('\0');
     91        return *this;
     92    }
     93
     94    inline bool operator ==(String const &s) const
     95    {
     96        if (this->m_count != s.m_count)
     97            return false;
     98
     99        for (int i = 0; i < this->m_count; ++i)
     100            if ((*this)[i] != s[i])
     101                return false;
     102
     103        return true;
     104    }
     105
     106    inline bool operator !=(String const &s) const
     107    {
     108        return !(*this == s);
     109    }
    70110};
    71111
  • trunk/test/Makefile.am

    r2084 r2096  
    2323    unit/vector.cpp unit/matrix.cpp unit/half.cpp unit/trig.cpp \
    2424    unit/build.cpp unit/real.cpp unit/image.cpp unit/quat.cpp unit/cmplx.cpp \
    25     unit/array.cpp unit/rotation.cpp
     25    unit/array.cpp unit/rotation.cpp unit/string.cpp
    2626testsuite_CPPFLAGS = @LOL_CFLAGS@
    2727testsuite_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@
Note: See TracChangeset for help on using the changeset viewer.