18 size_t len = strlen(source);
20 strncpy(fStore, source, NElements());
44 newstring.
Append(increment);
51 newstring.
Append(increment);
65 TPZString::operator
const char * ()
const 82 if (fNElements == 0)
return 0;
83 return strlen(fStore);
91 if (fNElements < len + 2)
97 fStore[len + 1] =
'\0';
100 fStore[len] = TailIncrement;
106 size_t len = strlen(TailIncrement);
108 if (fNElements < OldLength + len + 1) Resize(OldLength + len + 1);
110 strncpy(fStore + OldLength, TailIncrement,fNElements-OldLength);
117 if (start > len || start > end)
123 int startpos = start, endpos = end, i;
125 if (startpos < 0) startpos = 0;
127 if (endpos > len) endpos = len - 1;
129 TPZString newstring(endpos - startpos + 2);
130 for (i = startpos; i <= endpos; i++) newstring[i - startpos] = fStore[i];
132 newstring[newstring.
NElements() - 1] =
'\0';
145 if (len + 1 < fNElements) Resize(len + 1);
150 unsigned int i, newpos = 0;
151 const unsigned int length =
Length();
152 char current =
'0', next =
'0';
153 for (i = 0; i < length - 1; i++)
160 fStore[newpos] =
' ';
163 next = fStore[i + 1];
167 next = fStore[i + 1];
169 fStore[newpos] = next;
174 if (newpos != i) fStore[newpos] = current;
178 fStore[newpos] =
'\0';
182 string newstring(fStore);
183 const int replace_len = strlen(replace_str);
185 string::size_type pos = newstring.find(replace_str, 0);
186 while( pos!= string::npos) {
187 newstring.replace(pos, replace_len, new_substr);
188 pos = newstring.find(replace_str, 0);
191 if(count) strncpy(fStore, newstring.c_str(), fNElements);
197 return fchr.find(find_str, 0);
void Optimize()
Internally allocates the exact string size to store it.
int Replace(const char *old_str, const char *new_str)
Replace the subset of string. Return the times of replacement.
void Append(TPZVec< TVar > &u1, TPZVec< TVar > &u2, TPZVec< TVar > &u12)
Append u2 vector after u1 vector in u12 vector.
void operator+=(const char *increment)
Appends a string at the tail. Resizes the TPZString if necessary.
const char * Str() const
Explicitly convertes a TPZString into a const null ended char string.
void Empty()
Empties the string.
size_t Length() const
Similar to strlen(string). Also returns the number of non-null characters.
void Append(const char TailIncrement)
Appends a character at the end. Resizes if necessary.
TPZString()
Default Constructor.
Implements strings as stack. Utility.
TPZString SubStr(const int start, const int end) const
Returns a subset string.
TPZString operator+(const char *increment) const
Concatenates the 'this' string with another character string (increment)
int64_t NElements() const
Returns the number of elements of the vector.
void SimplifyWhiteSpace()
Remove the repeat white spaces.
int Find(const char *find_str)
Find the positions of the first occurence of the find string.