NeoPZ
Public Member Functions | List of all members
TPZString Class Reference

Implements strings as stack. Utility. More...

#include <pzstring.h>

Inheritance diagram for TPZString:
[legend]
Collaboration diagram for TPZString:
[legend]

Public Member Functions

 TPZString ()
 Default Constructor. More...
 
 TPZString (char const *source)
 Constructs a TPZString object based on another string (char *) More...
 
 TPZString (const int size)
 Initializes the TPZString object with a predefined size. More...
 
 TPZString (const char chr)
 Single char constructor. More...
 
 ~TPZString ()
 Default destructor. More...
 
TPZString operator+ (const char *increment) const
 Concatenates the 'this' string with another character string (increment) More...
 
TPZString operator+ (const TPZString &increment) const
 Concatenates the 'this' string with another string object. More...
 
void operator+= (const char *increment)
 Appends a string at the tail. Resizes the TPZString if necessary. More...
 
void operator+= (const char increment)
 Appends a character at the end. Resizes if necessary. More...
 
bool operator== (const TPZString cmp)
 Operator equal. Resizes if necessary. More...
 
void operator= (const char *source)
 Operator attribution. Resizes if necessary. More...
 
void Append (const char TailIncrement)
 Appends a character at the end. Resizes if necessary. More...
 
void Append (const char *TailIncrement)
 Appends a string at the tail. Resizes the TPZString if necessary. More...
 
const char * Str () const
 Explicitly convertes a TPZString into a const null ended char string. More...
 
 operator const char * () const
 Implicit conversion. More...
 
size_t Length () const
 Similar to strlen(string). Also returns the number of non-null characters. More...
 
TPZString SubStr (const int start, const int end) const
 Returns a subset string. More...
 
void Empty ()
 Empties the string. More...
 
void Optimize ()
 Internally allocates the exact string size $ (length + 1) $ to store it. More...
 
void SimplifyWhiteSpace ()
 Remove the repeat white spaces. More...
 
int Replace (const char *old_str, const char *new_str)
 Replace the subset of string. Return the times of replacement. More...
 
int Find (const char *find_str)
 Find the positions of the first occurence of the find string. More...
 
- Public Member Functions inherited from TPZStack< char >
char & Peek () const
 
 TPZStack ()
 Create the stack object, indicates the stack increments. More...
 
 TPZStack (int nel, const char Object)
 
void Push (const char object)
 Pushes a copy of the object on the stack. More...
 
void push_back (const char object)
 
char Pop ()
 Retrieve an object from the stack. More...
 
 operator char * () const
 Casting operator. More...
 
- Public Member Functions inherited from TPZManVector< char, DEFAULTVEC_ALLOC >
 TPZManVector (const int64_t size=0)
 Creates a vector of a given size. More...
 
 TPZManVector (const int64_t size, const char &copy)
 Creates a vector of a given size, filling it. More...
 
 TPZManVector (const TPZManVector< char, NumExtAlloc > &copy)
 Copy constructor. More...
 
 TPZManVector (const TPZVec< char > &copy)
 
 TPZManVector (const std::initializer_list< char > &list)
 Creates a vector from a initializer list. More...
 
TPZManVector< char, NumExtAlloc > & operator= (const TPZManVector< char, NumExtAlloc > &copy)
 Assignment operator. More...
 
TPZManVector< char, NumExtAlloc > & operator= (const std::initializer_list< char > &list)
 initializer list assignment operator More...
 
virtual ~TPZManVector ()
 Destructor. More...
 
int NAlloc () const
 Returns number of elements allocated for this object. More...
 
void Expand (const int64_t newsize)
 Expands the allocated storage to fit the newsize parameter. More...
 
void Shrink ()
 It reallocates storage to fit the necessary storage exactly. More...
 
virtual void Resize (const int64_t newsize, const char &object)
 Resizes the vector object. More...
 
virtual void Resize (const int64_t newsize)
 Resizes the vector object reallocating the storage if necessary. More...
 
- Public Member Functions inherited from TPZVec< char >
 TPZVec ()
 Creates a vector with size 0. More...
 
 TPZVec (const int64_t size)
 Creates a vector of a given size. More...
 
 TPZVec (const int64_t size, const char &copy)
 Creates a vector of a given size. More...
 
 TPZVec (const TPZVec< char > &copy)
 Creates a vector with copy constructor.
will call the empty constructor on all objects of type T created. More...
 
 TPZVec (const std::initializer_list< char > &list)
 Creates a vector from a initializer list. More...
 
virtual ~TPZVec ()
 destructor, will delete the storage allocated More...
 
void MigratePages ()
 
void ReallocForNuma ()
 
TPZVec< char > & operator= (const TPZVec< char > &copy)
 will copy the vector into the current vector. More...
 
TPZVec< char > & operator= (const std::initializer_list< char > &list)
 create a new vector and stores in the current vector More...
 
TPZVec< char > & operator= (const char &a)
 Operator attribution. Fills the vector with a value of type T. More...
 
char & operator[] (const int64_t index) const
 Access operator, will perform bounds checking unless the variable NODEBUG is defined. More...
 
char * begin () const
 Casting operator. Returns The fStore pointer. More...
 
char * end () const
 Returns a pointer to the last+1 element. More...
 
void Fill (const char &copy, const int64_t from=0, const int64_t numelem=-1)
 Will fill the elements of the vector with a copy object. More...
 
int64_t NElements () const
 Returns the number of elements of the vector. More...
 
int64_t size () const
 Returns the number of elements of the vector. More...
 
virtual void resize (const int64_t newsize)
 
void Print (std::ostream &out=std::cout)
 Prints the structural information of the vector object to the output stream.
This method will not print the objects themselves! More...
 
virtual void clear ()
 Empty the vector, make its size zero. More...
 

Additional Inherited Members

- Protected Attributes inherited from TPZVec< char >
char * fStore
 Allocated storage for the vector object. More...
 
int64_t fNElements
 Number of elements of the vector object. More...
 

Detailed Description

Implements strings as stack. Utility.

Definition at line 18 of file pzstring.h.

Constructor & Destructor Documentation

◆ TPZString() [1/4]

TPZString::TPZString ( )

Default Constructor.

Definition at line 11 of file pzstring.cpp.

◆ TPZString() [2/4]

TPZString::TPZString ( char const *  source)

Constructs a TPZString object based on another string (char *)

Definition at line 16 of file pzstring.cpp.

◆ TPZString() [3/4]

TPZString::TPZString ( const int  size)

Initializes the TPZString object with a predefined size.

Definition at line 29 of file pzstring.cpp.

◆ TPZString() [4/4]

TPZString::TPZString ( const char  chr)

Single char constructor.

Definition at line 34 of file pzstring.cpp.

◆ ~TPZString()

TPZString::~TPZString ( )
inline

Default destructor.

Definition at line 35 of file pzstring.h.

References operator+(), and operator+=().

Member Function Documentation

◆ Append() [1/2]

void TPZString::Append ( const char  TailIncrement)

Appends a character at the end. Resizes if necessary.

Definition at line 86 of file pzstring.cpp.

References Length.

Referenced by operator+(), and operator=().

◆ Append() [2/2]

void TPZString::Append ( const char *  TailIncrement)

Appends a string at the tail. Resizes the TPZString if necessary.

Definition at line 103 of file pzstring.cpp.

References Length.

◆ Empty()

void TPZString::Empty ( )

Empties the string.

Definition at line 136 of file pzstring.cpp.

Referenced by operator=().

◆ Find()

int TPZString::Find ( const char *  find_str)

Find the positions of the first occurence of the find string.

Definition at line 195 of file pzstring.cpp.

Referenced by operator=().

◆ Length()

size_t TPZString::Length ( ) const

Similar to strlen(string). Also returns the number of non-null characters.

Definition at line 80 of file pzstring.cpp.

Referenced by operator=().

◆ operator const char *()

TPZString::operator const char * ( ) const

Implicit conversion.

Definition at line 65 of file pzstring.cpp.

◆ operator+() [1/2]

TPZString TPZString::operator+ ( const char *  increment) const

Concatenates the 'this' string with another character string (increment)

Note
Original strings are left unchanged.

Definition at line 41 of file pzstring.cpp.

References Append().

Referenced by ~TPZString().

◆ operator+() [2/2]

TPZString TPZString::operator+ ( const TPZString increment) const

Concatenates the 'this' string with another string object.

Note
Original string and character are left unchanged.

Definition at line 48 of file pzstring.cpp.

References Append().

◆ operator+=() [1/2]

void TPZString::operator+= ( const char *  increment)

Appends a string at the tail. Resizes the TPZString if necessary.

Definition at line 60 of file pzstring.cpp.

References Append().

Referenced by ~TPZString().

◆ operator+=() [2/2]

void TPZString::operator+= ( const char  increment)

Appends a character at the end. Resizes if necessary.

Definition at line 55 of file pzstring.cpp.

References Append().

◆ operator=()

void TPZString::operator= ( const char *  source)
inline

◆ operator==()

bool TPZString::operator== ( const TPZString  cmp)
inline

Operator equal. Resizes if necessary.

Definition at line 56 of file pzstring.h.

References TPZVec< char >::fStore, and TPZVec< T >::fStore.

◆ Optimize()

void TPZString::Optimize ( )

Internally allocates the exact string size $ (length + 1) $ to store it.

Definition at line 141 of file pzstring.cpp.

References Length.

Referenced by operator=().

◆ Replace()

int TPZString::Replace ( const char *  old_str,
const char *  new_str 
)

Replace the subset of string. Return the times of replacement.

Definition at line 181 of file pzstring.cpp.

Referenced by operator=().

◆ SimplifyWhiteSpace()

void TPZString::SimplifyWhiteSpace ( )

Remove the repeat white spaces.

Definition at line 148 of file pzstring.cpp.

References Length.

Referenced by operator=().

◆ Str()

const char * TPZString::Str ( ) const

Explicitly convertes a TPZString into a const null ended char string.

Definition at line 70 of file pzstring.cpp.

Referenced by operator=(), and TPZEulerConsLaw::Print().

◆ SubStr()

TPZString TPZString::SubStr ( const int  start,
const int  end 
) const

Returns a subset string.

Parameters
startstart of the string (zero-based)
endend of the string (zero-based) If start and end are the same, a substring containing one character is returned.

  • if $ start \leq 0 $, start is assumed to be 0;
    if $ end < start $, null pointer is returned;
    if $ end > length $, end is assumed to be equal to length.

Definition at line 114 of file pzstring.cpp.

References Length, and TPZVec< T >::NElements().

Referenced by operator=().


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