- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Mers::Utils::Lang::String Class Reference

`#include <String.h>`

Inheritance diagram for Mers::Utils::Lang::String:

[legend]
Collaboration diagram for Mers::Utils::Lang::String:

[legend]
List of all members.

## Public Types
typedef int | size_type
typedef char & | reference
typedef char const & | const_reference
## Public Member Functions
| String ()
| String (const char *s)
| String (const char *s, size_type n)
| String (const String &rhs)
| String (const String &rhs, size_type pos, size_type n)
| String (size_type n, char c)
| String (const std::string &rhs)
virtual | ~String ()
String & | operator= (const String &rhs)
String & | operator= (const char *s)
String & | operator= (char c)
virtual BaseModelObject * | duplicate () const
bool | operator== (const String &rhs) const
bool | operator== (const char *rhs) const
bool | operator!= (const String &rhs) const
bool | operator!= (const char *rhs) const
bool | operator< (const String &rhs) const
bool | operator< (const char *rhs) const
| operator char * ()
| operator const char * () const
reference | at (size_type pos)
const_reference | at (size_type pos) const
reference | operator[] (size_type pos)
const_reference | operator[] (size_type pos) const
const char * | c_str () const
const char * | data () const
size_type | length () const
size_type | size () const
size_type | max_size () const
void | resize (size_type n, char c=char())
size_type | capacity () const
void | reserve (size_type n=0)
bool | empty () const
String & | append (const String &str)
String & | append (const String &str, size_type pos, size_type n)
String & | append (const char *s, size_type n)
String & | append (const char *s)
String & | append (size_type n, char c)
template<typename Type>
String & | operator+= (Type rhs)
String & | operator+= (const String &rhs)
String & | operator+= (String &rhs)
String & | operator+= (const char *s)
String & | operator+= (char *s)
String & | operator+= (char c)
template<typename Type>
String | operator+ (Type rhs) const
String | operator+ (const String &rhs)
String | operator+ (const char *rhs)
String | operator+ (const std::string &rhs) const
String & | operator= (const std::string &rhs)
String & | operator+= (const std::string &rhs)
String & | assign (const String &str)
String & | assign (const String &str, size_type pos, size_type n)
String & | assign (const char *s, size_type n)
String & | assign (const char *s)
String & | assign (size_type n, char c)
String & | insert (size_type p0, const String &str)
String & | insert (size_type p0, const String &str, size_type pos, size_type n)
String & | insert (size_type p0, const char *s, size_type n)
String & | insert (size_type p0, const char *s)
String & | insert (size_type p0, size_type n, char c)
String & | erase (size_type p0=0, size_type n=npos)
String & | replace (size_type p0, size_type n0, const String &str)
String & | replace (size_type p0, size_type n0, const String &str, size_type pos, size_type n)
String & | replace (size_type p0, size_type n0, const char *s, size_type n)
String & | replace (size_type p0, size_type n0, const char *s)
String & | replace (size_type p0, size_type n0, size_type n, char c)
size_type | copy (char *s, size_type n, size_type pos=0) const
void | swap (String &str)
size_type | find (const String &str, size_type pos=0) const
size_type | find (const char *s, size_type pos, size_type n) const
size_type | find (const char *s, size_type pos=0) const
size_type | find (char c, size_type pos=0) const
size_type | rfind (const String &str, size_type pos=npos) const
size_type | rfind (const char *s, size_type pos, size_type n=npos) const
size_type | rfind (const char *s, size_type pos=npos) const
size_type | rfind (char c, size_type pos=npos) const
size_type | find_first_of (const String &str, size_type pos=0) const
size_type | find_first_of (const char *s, size_type pos, size_type n) const
size_type | find_first_of (const char *s, size_type pos=0) const
size_type | find_first_of (char c, size_type pos=0) const
size_type | find_last_of (const String &str, size_type pos=npos) const
size_type | find_last_of (const char *s, size_type pos, size_type n=npos) const
size_type | find_last_of (const char *s, size_type pos=npos) const
size_type | find_last_of (char c, size_type pos=npos) const
size_type | find_first_not_of (const String &str, size_type pos=0) const
size_type | find_first_not_of (const char *s, size_type pos, size_type n) const
size_type | find_first_not_of (const char *s, size_type pos=0) const
size_type | find_first_not_of (char c, size_type pos=0) const
size_type | find_last_not_of (const String &str, size_type pos=npos) const
size_type | find_last_not_of (const char *s, size_type pos, size_type n) const
size_type | find_last_not_of (const char *s, size_type pos=npos) const
size_type | find_last_not_of (char c, size_type pos=npos) const
String | substr (size_type pos=0, size_type n=npos) const
int | compare (const String &str) const
int | compare (size_type p0, size_type n0, const String &str)
int | compare (size_type p0, size_type n0, const String &str, size_type pos, size_type n)
int | compare (const char *s) const
int | compare (size_type p0, size_type n0, const char *s) const
int | compare (size_type p0, size_type n0, const char *s, size_type pos) const
void | print (std::ostream &out) const
size_type | trimLeft (void)
size_type | trimRight (void)
size_type | trim (void)
## Static Public Member Functions
static String | format (const char *formatStr,...)
## Static Public Attributes
static const size_type | npos
## Protected Member Functions
virtual void | destroy ()
int | grow (size_type newMaxSize)
int | shrink ()
## Protected Attributes
char * | array
| the characters of this string
size_type | curSize
| the current number of characters in the string, excluding the terminating ''
size_type | maxSize
| the maximum number of characters in the string
## Friends
String | operator+ (const char *lhs, const String &rhs)
template<typename Type>
String | operator+ (Type lhs, const String &rhs)

## Detailed Description

This is a non-template implementation of the string template class.

Author:
  : Paul H. Elliott

Definition at line 44 of file String.h.

## Member Function Documentation

String String::format | ( | const char * | formatStr,
|  |  | ... |
| ) |  |  | `[static]`

Sort of like sprintf(), except that it returns a new string object instead of requiring a char* buffer.

Definition at line 1456 of file String.cpp.

References String().

Here is the call graph for this function:

BaseModelObject * String::duplicate | ( |  | ) | const`[virtual]`

Returns a copy of this object if the object can be copied or NULL if the object cannot be copied. This function returns NULL by default, overide this function to return something different.

Returns:
  a pointer to a copy of this object or NULL if it can't be copied

Reimplemented from Mers::Utils::Lang::BaseModelObject.

Definition at line 153 of file String.cpp.

References String().

Here is the call graph for this function:

Mers::Utils::Lang::String::operator char * | ( |  | ) | `[inline]`

This typecast operator will access the character string of this String automatically when necessary. This is equivalent to c_str().

Returns:
  a reference to the raw string.

Definition at line 101 of file String.h.

References array.

Mers::Utils::Lang::String::operator const char * | ( |  | ) | const`[inline]`

This typecast operator will access the character string of this String automatically when necessary. This is equivalent to c_str().

Returns:
  a constant reference to the raw string.

Definition at line 112 of file String.h.

References array.

template<typename Type>

String& Mers::Utils::Lang::String::operator+= | ( | Type | rhs | ) | `[inline]`

Operators for other values on the right hand side.

Definition at line 159 of file String.h.

References append().

Referenced by operator+=().

Here is the call graph for this function:

template<typename Type>

String Mers::Utils::Lang::String::operator+ | ( | Type | rhs | ) | const`[inline]`

This generic function will convert most + operations to += on a new String object.

Parameters:

  | t | The object that is being converted.

Definition at line 198 of file String.h.

References String().

Here is the call graph for this function:

String Mers::Utils::Lang::String::operator+ | ( | const std::string & | rhs | ) | const`[inline]`

Operators for String and std::string.

Definition at line 225 of file String.h.

References operator+.

String & String::insert | ( | size_type | p0,
|  | const String & | str |
| ) |  |  |

inserts str before p0 in this string

Parameters:

  | p0 | the index of the character that the string should be inserted before
  | str | the string being inserted

Returns:
  this object

Definition at line 530 of file String.cpp.

References array, and curSize.

Referenced by insert(), and replace().

void String::print | ( | std::ostream & | out | ) | const`[virtual]`

Prints out the String to out

Parameters:

  | out | the ostream being written to

Implements Mers::Utils::Lang::BaseModelObject.

Definition at line 1351 of file String.cpp.

References array.

String::size_type String::trimLeft | ( | void |  | ) |

Removes leading whitespace Returns the number of characters trimmed

Definition at line 1427 of file String.cpp.

References array, curSize, and erase().

Referenced by trim().

Here is the call graph for this function:

String::size_type String::trimRight | ( | void |  | ) |

Removes trailing whitespace Returns the number of characters trimmed

Definition at line 1437 of file String.cpp.

References curSize, and erase().

Referenced by trim().

Here is the call graph for this function:

String::size_type String::trim | ( | void |  | ) |

Removes leading and trailing whitespace Returns the number of characters trimmed

Definition at line 1448 of file String.cpp.

References trimLeft(), and trimRight().

Here is the call graph for this function:

void String::destroy | ( |  | ) | `[protected, virtual]`

Deletes the array, setting up the array for a copy, destructor or fresh start Derived classes should ensure this function is called as well String::destroy();

Definition at line 1362 of file String.cpp.

References array, curSize, and maxSize.

Referenced by ~String().

int String::grow | ( | size_type | newMaxSize | ) | `[protected]`

Doubles the maximum array size, unless it's zero, at which point it creates an array of size 1

Returns:
  0 on success or a positive value if the size failed to be changed

Definition at line 1374 of file String.cpp.

References array, and maxSize.

Referenced by append(), assign(), insert(), reserve(), resize(), and String().

int String::shrink | ( |  | ) | `[protected]`

Halves the maximum array size, unless it's <= 2, at which point it does nothing

Returns:
  0 on success or a negative value if the size failed to be changed this procedure returns 0 if the current maxSize is <= 2 and does nothing

Definition at line 1399 of file String.cpp.

References array, and maxSize.

## Friends And Related Function Documentation

template<typename Type>

String operator+ | ( | Type | lhs,
|  | const String & | rhs |
| ) |  |  | `[friend]`

This generic function will handle <Type> + String.

Definition at line 206 of file String.h.

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

- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Lang/String.h
- /Users/fpy/titan-1-5-MBARI/Mers/Utils/Lang/String.cpp