string Struct Reference


Public Member Functions

 string ()
 string (const char *s)
 string (const char *s, unsigned int n)
 string (const string &x)
 ~string ()
stringoperator= (const char *s)
stringoperator= (const string &x)
const char * c_str () const

Data Fields

string::srepp

Data Structures

struct  srep

Detailed Description

Definition at line 21 of file string.icc.


Constructor & Destructor Documentation

string::string (  )  [inline]

Definition at line 29 of file string.icc.

References p, and string::srep::s.

00029 { p = new srep; p->s = 0; } 

string::string ( const char *  s  )  [inline]

Definition at line 32 of file string.icc.

References p, and string::srep::s.

00032                         {
00033     p = new srep; p->s = new char[strlen(s)+1]; strcpy(p->s, s);
00034   }

string::string ( const char *  s,
unsigned int  n 
) [inline]

Definition at line 37 of file string.icc.

References p, and string::srep::s.

00037                                         {
00038     p = new srep; p->s = new char[n+1]; strncpy(p->s, s, n); *(p->s+n) = '\0';
00039   }

string::string ( const string x  )  [inline]

Definition at line 42 of file string.icc.

References string::srep::n, and p.

00042 { x.p->n++; p = x.p; }

string::~string (  )  [inline]

Definition at line 45 of file string.icc.

References string::srep::n, p, and string::srep::s.

00045 { if (--p->n == 0) { delete [] p->s; delete p; } }


Member Function Documentation

const char* string::c_str (  )  const [inline]

Definition at line 69 of file string.icc.

References p, and string::srep::s.

Referenced by operator+().

00069 { return p->s; }

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

Definition at line 61 of file string.icc.

References string::srep::n, p, and string::srep::s.

00061                                       {
00062     x.p->n++;           // protect against "st = st"
00063     if (--p->n == 0) { delete [] p->s; delete p; }
00064     p = x.p;
00065     return *this;
00066   }

string& string::operator= ( const char *  s  )  [inline]

Definition at line 48 of file string.icc.

References string::srep::n, p, and string::srep::s.

00048                                    {
00049     if (p->n > 1) {     // disconnect self
00050       p->n--;
00051       p = new srep;
00052     }else{
00053       delete [] p->s;   // free old string
00054     } 
00055     p->s = new char[strlen(s)+1];
00056     strcpy(p->s, s);
00057     return *this;
00058   } 


Field Documentation

struct string::srep * string::p

Referenced by c_str(), operator!=(), operator+(), operator<<(), operator=(), operator==(), string(), and ~string().


The documentation for this struct was generated from the following file:
Generated on Mon May 27 17:54:03 2013 for Geant4 by  doxygen 1.4.7