string Class Reference

#include <string.hpp>

List of all members.

Public Member Functions

Protected Attributes

Friends


Detailed Description

Definition at line 50 of file string.hpp.


Constructor & Destructor Documentation

string ( string_rep rep2  )  [inline]

Definition at line 105 of file string.hpp.

00108 { return copy (s); }

string ( const string_rep rep2,
bool  with_inc 
) [inline]

Definition at line 105 of file string.hpp.

00108 { return copy (s); }

string ( const string x  )  [inline]

Definition at line 105 of file string.hpp.

00108 { return copy (s); }

~string (  )  [inline]

Definition at line 105 of file string.hpp.

00108 { return copy (s); }

string ( nat  n = 0  )  [inline]

Definition at line 53 of file string.hpp.

00053 : rep (new string_rep (n)) {}

string ( char  c  ) 

Definition at line 22 of file string.cpp.

References string::rep, and string::string_rep.

00022                       {
00023   rep= new string_rep(1);
00024   rep->a[0]=c;
00025 }

string ( const char *  s  ) 

Definition at line 27 of file string.cpp.

References n, string::rep, and string::string_rep.

00027                              {
00028   register nat i, n=strlen(a);
00029   rep= new string_rep(n);
00030   for (i=0; i<n; i++)
00031     rep->a[i]=a[i];
00032 }

string ( const char *  s,
nat  n 
)

Member Function Documentation

void operator delete ( void *  ptr,
size_t  sz 
) [inline]

Definition at line 51 of file string.hpp.

00052 :
  inline string (nat n=0): rep (new string_rep (n)) {}

void operator delete[] ( void *  ptr,
size_t  sz 
) [inline]

Definition at line 51 of file string.hpp.

00052 :
  inline string (nat n=0): rep (new string_rep (n)) {}

void* operator new ( size_t  sz,
void *  where 
) [inline]

Definition at line 51 of file string.hpp.

00052 :
  inline string (nat n=0): rep (new string_rep (n)) {}

void* operator new ( size_t  sz  )  [inline]

Definition at line 51 of file string.hpp.

00052 :
  inline string (nat n=0): rep (new string_rep (n)) {}

void* operator new[] ( size_t  sz,
void *  where 
) [inline]

Definition at line 51 of file string.hpp.

00052 :
  inline string (nat n=0): rep (new string_rep (n)) {}

void* operator new[] ( size_t  sz  )  [inline]

Definition at line 51 of file string.hpp.

00052 :
  inline string (nat n=0): rep (new string_rep (n)) {}

bool operator!= ( const string s  )  const
bool operator!= ( const char *  s  )  const
string operator() ( nat  start,
nat  end 
) const

Return the substring from position start to end.

Definition at line 354 of file string.cpp.

References string::rep.

00354                                          {
00355   register nat i;
00356   string r (i2-i1);
00357   for (i=i1; i<i2; i++) r.rep->a[i-i1]= rep->a[i];
00358   return r;
00359 }

const string_rep * operator-> (  )  const [inline]

Definition at line 105 of file string.hpp.

00108 { return copy (s); }

string& operator<< ( const string t  ) 

Append t to the end of the string.

string & operator<< ( char  c  ) 

Append c to the end of the string.

Definition at line 384 of file string.cpp.

References string_rep::extend(), string::rep, and string::secure().

00384                            {
00385   secure ();
00386   rep->extend (1);
00387   rep->a[rep->n-1]= x;
00388   return *this;
00389 }

string & operator= ( const string x  )  [inline]

Definition at line 105 of file string.hpp.

00108 { return copy (s); }

bool operator== ( const string s  )  const
bool operator== ( const char *  s  )  const
string & operator>> ( char &  c  ) 

Retrieve c from the end of the string.

Definition at line 402 of file string.cpp.

References ASSERT, string::rep, string_rep::resize(), and string::secure().

00402                             {
00403   ASSERT (rep->n != 0, "non empty string expected");
00404   secure ();
00405   x= rep->a[rep->n-1];
00406   rep->resize (rep->n-1);
00407   return *this;
00408 }

char& operator[] ( nat  i  )  [inline]

Definition at line 70 of file string.hpp.

References string::rep, and string::secure().

00070 { secure (); return rep->a[i]; }

char operator[] ( nat  i  )  const [inline]

Return the i th character.

Definition at line 69 of file string.hpp.

References string::rep.

00069 { return rep->a[i]; }

void secure (  )  [inline]

Definition at line 105 of file string.hpp.

Referenced by string::operator<<(), string::operator>>(), and string::operator[]().

00108 { return copy (s); }


Friends And Related Function Documentation

double as_double ( const string s  )  [friend]
int as_int ( const string s  )  [friend]
string as_string ( double  x  )  [friend]

Definition at line 163 of file string.cpp.

00163                      {
00164   if (as_string_hook != NULL)
00165     return as_string_hook (x);
00166   if (x == 0.0) return "0";
00167   char buffer[32];
00168   sprintf (buffer, "%1.12g", x);
00169   return string (buffer);
00170 }

string as_string ( float  x  )  [friend]

Definition at line 153 of file string.cpp.

00153                     {
00154   if (x == 0.0) return "0";
00155   char buffer[32];
00156   sprintf (buffer, "%1.3e", x);
00157   return string (buffer);
00158 }

string as_string ( long long unsigned int  i  )  [friend]

Definition at line 130 of file string.cpp.

00130                                      {
00131   char buffer[100];
00132   sprintf (buffer, "%llu", i);
00133   return string (buffer);
00134 }

string as_string ( long long int  i  )  [friend]

Definition at line 123 of file string.cpp.

00123                             {
00124   char buffer[100];
00125   sprintf (buffer, "%lld", i);
00126   return string (buffer);
00127 }

string as_string ( long unsigned int  i  )  [friend]

Definition at line 116 of file string.cpp.

00116                                 {
00117   char buffer[100];
00118   sprintf (buffer, "%lu", i);
00119   return string (buffer);
00120 }

string as_string ( long int  i  )  [friend]

Definition at line 109 of file string.cpp.

00109                        {
00110   char buffer[100];
00111   sprintf (buffer, "%ld", i);
00112   return string (buffer);
00113 }

string as_string ( unsigned int  i  )  [friend]

Definition at line 102 of file string.cpp.

00102                            {
00103   char buffer[100];
00104   sprintf (buffer, "%u", i);
00105   return string (buffer);
00106 }

string as_string ( int  i  )  [friend]

Definition at line 95 of file string.cpp.

00095                   {
00096   char buffer[100];
00097   sprintf (buffer, "%d", i);
00098   return string (buffer);
00099 }

string as_string ( short unsigned int  i  )  [friend]

Definition at line 124 of file string.hpp.

00124                                                {
00125   return as_string ((unsigned int) i); }

string as_string ( short int  i  )  [friend]

Definition at line 122 of file string.hpp.

00122                                       {
00123   return as_string ((int) i); }

string as_string ( void *  ptr  )  [friend]

Definition at line 88 of file string.cpp.

00088                       {
00089   char buffer[100];
00090   sprintf (buffer, "0x%lx", (unsigned long) ptr);
00091   return string (buffer);
00092 }

string as_string_hexa ( int  i  )  [friend]
bool busy ( const string s  )  [friend]

Check whether s is non empty.

Definition at line 61 of file string.hpp.

00061 { return s.rep->n != 0; }

string copy ( const string s  )  [friend]
nat hash ( const string s  )  [friend]
char* inside ( const string s,
nat  pos 
) [friend]
nat N ( const string s  )  [friend]

Return the length of s.

Definition at line 59 of file string.hpp.

00059 { return s.rep->n; }

string operator* ( const string s,
const string t 
) [friend]
char read ( const string s,
nat  i 
) [friend]

Return the i th character of s.

Definition at line 67 of file string.hpp.

00067 { return s.rep->a[i]; }

const char* S ( const string s  )  [friend]

Return a const pointer to s.

Definition at line 65 of file string.hpp.

00065 { return s.rep->a; }

char* S ( string s  )  [friend]

Return a pointer to a copy of s.

Definition at line 63 of file string.hpp.

00063 { s.secure (); return s.rep->a; }

friend class string_rep [friend]

Definition at line 103 of file string.hpp.

Referenced by string::string().

string unescape ( const string s  )  [friend]

Member Data Documentation

string_rep* rep [protected]

The documentation for this class was generated from the following files:

Generated on 6 Dec 2012 for basix by  doxygen 1.6.1