NeoPZ
pzstring.h
Go to the documentation of this file.
1 
6 #ifndef PZSTRING_H
7 #define PZSTRING_H
8 
9 #include "pzstack.h"
10 #include "pzmanvector.h"
11 
12 #include <string.h>
13 
18 class TPZString : public TPZStack < char >
19 {
20 public:
21 
23  TPZString();
24 
26  TPZString(char const * source);
27 
29  TPZString(const int size);
30 
32  TPZString(const char chr);
33 
35  ~TPZString() { }
36 
41  TPZString operator + (const char * increment) const;
42 
47  TPZString operator + (const TPZString & increment) const;
48 
50  void operator += (const char * increment);
51 
53  void operator += (const char increment);
54 
56  bool operator == (const TPZString cmp)
57  {
58  if(!strcmp(fStore, cmp.fStore)) return true;
59  else return false;
60 
61  }
62 
64  void operator = (const char * source)
65  {
66  size_t len = strlen(source);
67 
68  if (NElements() < (len + 1))
69  {
70  Resize(len + 1);
71  }
72 
73  strncpy(fStore, source, NElements());
74  }
75 
77  void Append(const char TailIncrement);
78 
80  void Append(const char * TailIncrement);
81 
83  const char * Str() const;
84 
86  operator const char * () const;
87 
89  size_t Length() const;
90 
104  TPZString SubStr(const int start, const int end) const;
105 
107  void Empty();
108 
110  void Optimize();
111 
113  void SimplifyWhiteSpace();
114 
116  int Replace(const char * old_str, const char * new_str);
117 
119  int Find(const char * find_str);
120 };
121 
127 
128 #endif
129 
void Optimize()
Internally allocates the exact string size to store it.
Definition: pzstring.cpp:141
void operator=(const char *source)
Operator attribution. Resizes if necessary.
Definition: pzstring.h:64
~TPZString()
Default destructor.
Definition: pzstring.h:35
int Replace(const char *old_str, const char *new_str)
Replace the subset of string. Return the times of replacement.
Definition: pzstring.cpp:181
TPZVec< TPZString > TPZText
Typedef to vector of strings.
Definition: pzstring.h:126
void operator+=(const char *increment)
Appends a string at the tail. Resizes the TPZString if necessary.
Definition: pzstring.cpp:60
const char * Str() const
Explicitly convertes a TPZString into a const null ended char string.
Definition: pzstring.cpp:70
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
virtual void Resize(const int64_t newsize, const char &object)
Resizes the vector object.
Definition: pzmanvector.h:426
void Empty()
Empties the string.
Definition: pzstring.cpp:136
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
size_t Length() const
Similar to strlen(string). Also returns the number of non-null characters.
Definition: pzstring.cpp:80
Free store vector implementation.
void Append(const char TailIncrement)
Appends a character at the end. Resizes if necessary.
Definition: pzstring.cpp:86
bool operator==(const TPZString cmp)
Operator equal. Resizes if necessary.
Definition: pzstring.h:56
TPZString()
Default Constructor.
Definition: pzstring.cpp:11
Implements strings as stack. Utility.
Definition: pzstring.h:18
A simple stack.
TPZString SubStr(const int start, const int end) const
Returns a subset string.
Definition: pzstring.cpp:114
TPZString operator+(const char *increment) const
Concatenates the &#39;this&#39; string with another character string (increment)
Definition: pzstring.cpp:41
char * fStore
Allocated storage for the vector object.
Definition: pzvec.h:230
This class implements a stack object. Utility.
Definition: pzcheckmesh.h:14
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
void SimplifyWhiteSpace()
Remove the repeat white spaces.
Definition: pzstring.cpp:148
int Find(const char *find_str)
Find the positions of the first occurence of the find string.
Definition: pzstring.cpp:195
char * end() const
Returns a pointer to the last+1 element.
Definition: pzvec.h:455