(file) Return to String.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/String.h between version 1.21 and 1.22

version 1.21, 2001/04/27 22:28:32 version 1.22, 2001/04/29 18:57:33
Line 105 
Line 105 
     /// Assign this string with first n characters of the plain old C-String x.     /// Assign this string with first n characters of the plain old C-String x.
     String& assign(const char* x, Uint32 n);     String& assign(const char* x, Uint32 n);
  
     /** Clear this string. After calling clear(), getLength() will return 0.      /** Clear this string. After calling clear(), size() will return 0.
         <pre>         <pre>
             String test = "abc";             String test = "abc";
             test.clear();       // String test is now NULL (length == 0)             test.clear();       // String test is now NULL (length == 0)
Line 114 
Line 114 
     void clear() { _rep.clear(); _rep.append('\0'); }     void clear() { _rep.clear(); _rep.append('\0'); }
  
     /** Reserves memory for capacity characters. Notice that this does not     /** Reserves memory for capacity characters. Notice that this does not
         change the size of the string (getSize() returns what it did before).          change the size of the string (size() returns what it did before).
         If the capacity of the string is already greater or equal to the         If the capacity of the string is already greater or equal to the
         capacity argument, this method has no effect. After calling reserve(),         capacity argument, this method has no effect. After calling reserve(),
         getCapicty() returns a value which is greater or equal to the         getCapicty() returns a value which is greater or equal to the
Line 127 
Line 127 
         @return Length of the string in characters.         @return Length of the string in characters.
         <pre>         <pre>
             String s = "abcd";             String s = "abcd";
             assert(s.getLength() == 4);              assert(s.size() == 4);
         </pre>         </pre>
     */     */
     Uint32 getLength() const { return _rep.getSize() - 1; }      Uint32 size() const { return _rep.size() - 1; }
  
     /** Returns a pointer to the first character in the null-terminated string     /** Returns a pointer to the first character in the null-terminated string
         string.         string.
Line 171 
Line 171 
             const char STR0[] = "one two three four";             const char STR0[] = "one two three four";
             String s = STR0;             String s = STR0;
             const char STR1[] = "zero ";             const char STR1[] = "zero ";
             char* tmp = new char[strlen(STR1) + s.getLength() + 1];              char* tmp = new char[strlen(STR1) + s.size() + 1];
             strcpy(tmp, STR1);             strcpy(tmp, STR1);
             s.appendToCString(tmp, 7);             s.appendToCString(tmp, 7);
             assert(strcmp(tmp, "zero one two") == 0);             assert(strcmp(tmp, "zero one two") == 0);
Line 207 
Line 207 
     */     */
     String& append(const Char16& c)     String& append(const Char16& c)
     {     {
         _rep.insert(_rep.getSize() - 1, c);          _rep.insert(_rep.size() - 1, c);
         return *this;         return *this;
     }     }
  
Line 217 
Line 217 
     /// Append the characters of str to this String object.     /// Append the characters of str to this String object.
     String& append(const String& str)     String& append(const String& str)
     {     {
         return append(str.getData(), str.getLength());          return append(str.getData(), str.size());
     }     }
  
     /** Overload operator += appends the parameter String to this String.     /** Overload operator += appends the parameter String to this String.
Line 264 
Line 264 
             s = "abc";             s = "abc";
             s.remove(0, 1);             s.remove(0, 1);
             assert(String::equal(s, "bc"));             assert(String::equal(s, "bc"));
             assert(s.getLength() == 2);              assert(s.size() == 2);
             s.remove(0);             s.remove(0);
             assert(String::equal(s, ""));             assert(String::equal(s, ""));
             assert(s.getLength() == 0);              assert(s.size() == 0);
         </pre>         </pre>
         @exception throws "OutOfBounds" exception if size is greater than         @exception throws "OutOfBounds" exception if size is greater than
         length of String plus starting position for remove.         length of String plus starting position for remove.
Line 545 
Line 545 
     char* _rep;     char* _rep;
 }; };
  
   inline Uint32 _Length(const String& s1) { return s1.size(); }
   
   inline Uint32 _Length(const char* s1) { return strlen(s1); }
   
   inline Uint32 _Length(const char) { return 1; }
   
   template<class S1, class S2>
   inline String Cat(const S1& s1, const S2& s2)
   {
       String tmp;
       tmp.reserve(_Length(s1) + _Length(s2));
       tmp.append(s1);
       tmp.append(s2);
       return tmp;
   }
   
   template<class S1, class S2, class S3>
   inline String Cat(const S1& s1, const S2& s2, const S3& s3)
   {
       String tmp;
       tmp.reserve(_Length(s1) + _Length(s2) + _Length(s3));
       tmp.append(s1);
       tmp.append(s2);
       tmp.append(s3);
       return tmp;
   }
   
   template<class S1, class S2, class S3, class S4>
   inline String Cat(const S1& s1, const S2& s2, const S3& s3, const S4& s4)
   {
       String tmp;
       tmp.reserve(_Length(s1) + _Length(s2) + _Length(s3) + _Length(s4));
       tmp.append(s1);
       tmp.append(s2);
       tmp.append(s3);
       tmp.append(s4);
       return tmp;
   }
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
 #endif /* Pegasus_String_h */ #endif /* Pegasus_String_h */


Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2