Open
Graph Drawing
Framework

 v.2012.07
 

ogdf::String Class Reference

Representation of character strings. More...

#include <ogdf/basic/String.h>

List of all members.

Public Member Functions

 String ()
 Constructs an empty string, i.e., a string with length 0.
 String (const char c)
 Constructs a string consisting of a single character c.
 String (const char *str)
 Constructs a string that is a copy of str.
 String (size_t maxLen, const char *str)
 Constructs a string consisting of the first maxLen characters of str.
 String (const String &str)
 Constructs a string that is a copy of str.
 ~String ()
const char * cstr () const
 Cast a string into a 0-terminated C++ string.
size_t length () const
 Returns the length of the string.
Stringoperator+= (const String &str)
 Appends string str to this string.
Stringoperator= (const String &str)
 Assignment operator.
Stringoperator= (const char *str)
 Assignment operator.
char & operator[] (size_t i)
 Returns a reference to the character at position i.
const char & operator[] (size_t i) const
 Returns a reference to the character at position i.
void sprintf (const char *format,...)
 Formatted assignment operator.

Static Public Member Functions

static int compare (const String &x, const String &y)
 Compare function for strings.

Private Attributes

size_t m_length
 The length of the string (number of characters).
char * m_pChar
 Pointer to characters.

Static Private Attributes

static char s_pBuffer [OGDF_STRING_BUFFER_SIZE]
 Temporary buffer used by sprintf().

Friends

bool operator!= (const String &x, const String &y)
 Inequality operator.
bool operator!= (const char *x, const String &y)
 Inequality operator.
bool operator!= (const String &x, const char *y)
 Inequality operator.
bool operator< (const String &x, const String &y)
 Less than operator.
bool operator< (const char *x, const String &y)
 Less than operator.
bool operator< (const String &x, const char *y)
 Less than operator.
bool operator<= (const String &x, const String &y)
 Less or equal than operator.
bool operator<= (const char *x, const String &y)
 Less or equal than operator.
bool operator<= (const String &x, const char *y)
 Less or equal than operator.
bool operator== (const String &x, const String &y)
 Equality operator.
bool operator== (const char *x, const String &y)
 Equality operator.
bool operator== (const String &x, const char *y)
 Equality operator.
bool operator> (const String &x, const String &y)
 Greater than operator.
bool operator> (const char *x, const String &y)
 Greater than operator.
bool operator> (const String &x, const char *y)
 Greater than operator.
bool operator>= (const String &x, const String &y)
 Greater or equal than operator.
bool operator>= (const char *x, const String &y)
 Greater or equal than operator.
bool operator>= (const String &x, const char *y)
 Greater or equal than operator.
istream & operator>> (istream &is, String &str)
 Input operator.

Detailed Description

Representation of character strings.

Strings are internally stored as an Ascii character array. The positions within a string a numbered 0,1,...

Definition at line 67 of file String.h.


Constructor & Destructor Documentation

ogdf::String::String ( )

Constructs an empty string, i.e., a string with length 0.

ogdf::String::String ( const char  c)

Constructs a string consisting of a single character c.

ogdf::String::String ( const char *  str)

Constructs a string that is a copy of str.

ogdf::String::String ( size_t  maxLen,
const char *  str 
)

Constructs a string consisting of the first maxLen characters of str.

Parameters:
maxLenis the number of characters to be copied from the begin of str. If str is shorter than maxLen, then the complete string is copied.
stris the string to be copied.
ogdf::String::String ( const String str)

Constructs a string that is a copy of str.

ogdf::String::~String ( )

Member Function Documentation

static int ogdf::String::compare ( const String x,
const String y 
)
static

Compare function for strings.

const char* ogdf::String::cstr ( ) const
inline

Cast a string into a 0-terminated C++ string.

Definition at line 96 of file String.h.

size_t ogdf::String::length ( ) const
inline

Returns the length of the string.

Definition at line 99 of file String.h.

String& ogdf::String::operator+= ( const String str)

Appends string str to this string.

String& ogdf::String::operator= ( const String str)

Assignment operator.

String& ogdf::String::operator= ( const char *  str)

Assignment operator.

char& ogdf::String::operator[] ( size_t  i)
inline

Returns a reference to the character at position i.

Definition at line 102 of file String.h.

const char& ogdf::String::operator[] ( size_t  i) const
inline

Returns a reference to the character at position i.

Definition at line 108 of file String.h.

void ogdf::String::sprintf ( const char *  format,
  ... 
)

Formatted assignment operator.

Behaves essentially like the C function printf().


Friends And Related Function Documentation

bool operator!= ( const String x,
const String y 
)
friend

Inequality operator.

Definition at line 127 of file String.h.

bool operator!= ( const char *  x,
const String y 
)
friend

Inequality operator.

Definition at line 131 of file String.h.

bool operator!= ( const String x,
const char *  y 
)
friend

Inequality operator.

Definition at line 135 of file String.h.

bool operator< ( const String x,
const String y 
)
friend

Less than operator.

Definition at line 140 of file String.h.

bool operator< ( const char *  x,
const String y 
)
friend

Less than operator.

Definition at line 144 of file String.h.

bool operator< ( const String x,
const char *  y 
)
friend

Less than operator.

Definition at line 148 of file String.h.

bool operator<= ( const String x,
const String y 
)
friend

Less or equal than operator.

Definition at line 153 of file String.h.

bool operator<= ( const char *  x,
const String y 
)
friend

Less or equal than operator.

Definition at line 157 of file String.h.

bool operator<= ( const String x,
const char *  y 
)
friend

Less or equal than operator.

Definition at line 161 of file String.h.

bool operator== ( const String x,
const String y 
)
friend

Equality operator.

Definition at line 114 of file String.h.

bool operator== ( const char *  x,
const String y 
)
friend

Equality operator.

Definition at line 118 of file String.h.

bool operator== ( const String x,
const char *  y 
)
friend

Equality operator.

Definition at line 122 of file String.h.

bool operator> ( const String x,
const String y 
)
friend

Greater than operator.

Definition at line 166 of file String.h.

bool operator> ( const char *  x,
const String y 
)
friend

Greater than operator.

Definition at line 170 of file String.h.

bool operator> ( const String x,
const char *  y 
)
friend

Greater than operator.

Definition at line 174 of file String.h.

bool operator>= ( const String x,
const String y 
)
friend

Greater or equal than operator.

Definition at line 179 of file String.h.

bool operator>= ( const char *  x,
const String y 
)
friend

Greater or equal than operator.

Definition at line 183 of file String.h.

bool operator>= ( const String x,
const char *  y 
)
friend

Greater or equal than operator.

Definition at line 187 of file String.h.

istream& operator>> ( istream &  is,
String str 
)
friend

Input operator.


Member Data Documentation

size_t ogdf::String::m_length
private

The length of the string (number of characters).

Definition at line 70 of file String.h.

char* ogdf::String::m_pChar
private

Pointer to characters.

Definition at line 69 of file String.h.

char ogdf::String::s_pBuffer[OGDF_STRING_BUFFER_SIZE]
staticprivate

Temporary buffer used by sprintf().

Definition at line 72 of file String.h.


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