rutz::fstring Class Reference

#include <rutz/fstring.h>

Collaboration diagram for rutz::fstring:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fstring ()
 Construct an empty string.
 fstring (const fstring &other) throw ()
 Copy constructor.
 ~fstring () throw ()
 Destructory.
 fstring (const char *s)
 Construct by copying from a C-style null-terminated char array.
 fstring (char_range r)
 Construct from a character range (pointer plus length).
void swap (fstring &other) throw ()
 Swap contents with another fstring object.
fstringoperator= (const char *text)
 Assign from a C-style null-terminated char array.
fstringoperator= (const fstring &other) throw ()
 Assignment operator.
const char * c_str () const throw ()
 Get a pointer to the const underlying data array.
std::size_t length () const throw ()
 Get the number of characters in the string (NOT INCLUDING the null terminator).
bool is_empty () const throw ()
 Query whether the length of the string is 0.
bool empty () const throw ()
 Same as is_empty(); for compatibility with std::string interface.
char operator[] (unsigned int i) const
 Return the character at position i.
void clear ()
 Reset to an empty string.
bool ends_with (const fstring &ext) const throw ()
 Query whether the terminal substring matches the given string.
bool equals (const char *other) const throw ()
 Query for equality with a C-style string.
bool equals (const fstring &other) const throw ()
 Query for equality with another fstring object.
bool operator< (const char *other) const throw ()
 Query if string is lexicographically less-than another string.
template<class string_type >
bool operator< (const string_type &other) const throw ()
 Query if string is lexicographically less-than another string.
bool operator> (const char *other) const throw ()
 Query if string is lexicographically greater-than another string.
template<class string_type >
bool operator> (const string_type &other) const throw ()
 Query if string is lexicographically greater-than another string.
void read (std::istream &is)
 Set the string by reading consecutive non-whitespace characters.
void readsome (std::istream &is, unsigned int count)
 Set the string by reading exactly count characters.
void write (std::ostream &os) const
 Write the string's contents to the ostream.
void readline (std::istream &is, char eol= '\n')
 Set the string by reading characters up until newline or EOF.
bool operator== (const char *rhs) const throw ()
 Equality operator.
bool operator== (const fstring &rhs) const throw ()
 Equality operator.
bool operator!= (const char *rhs) const throw ()
 Inequality operator.
bool operator!= (const fstring &rhs) const throw ()
 Inequality operator.
void debug_dump () const throw ()
 Dump contents for debugging.

Detailed Description

fstring is a simple string class that holds a pointer to a dynamically-allocated char array. The initializer does not have to reside in permanent storage, since a copy is made when the fstring is constructed. Assignment is allowed, with copy semantics. Also, a swap() operation is provided. The internal implementation uses reference counting to allow for efficient copies; however, to allow safe multi-threaded access to fstring, fstring's interface is read-only, except for a few functions (assignment operator, swap(), clear() read(), readline(), readsome()) which safely replace the entire string.

Definition at line 149 of file fstring.h.


Constructor & Destructor Documentation

rutz::fstring::fstring (  ) 

Construct an empty string.

Definition at line 269 of file fstring.cc.

Referenced by clear(), read(), readline(), and readsome().

rutz::fstring::fstring ( const fstring other  )  throw ()

Copy constructor.

Definition at line 277 of file fstring.cc.

rutz::fstring::~fstring (  )  throw ()

Destructory.

Definition at line 284 of file fstring.cc.

rutz::fstring::fstring ( const char *  s  )  [inline]

Construct by copying from a C-style null-terminated char array.

Definition at line 162 of file fstring.h.

rutz::fstring::fstring ( char_range  r  )  [inline, explicit]

Construct from a character range (pointer plus length).

Definition at line 169 of file fstring.h.


Member Function Documentation

const char* rutz::fstring::c_str (  )  const throw () [inline]
void rutz::fstring::clear ( void   ) 

Reset to an empty string.

Definition at line 330 of file fstring.cc.

References fstring().

void rutz::fstring::debug_dump (  )  const throw ()

Dump contents for debugging.

Definition at line 401 of file fstring.cc.

bool rutz::fstring::empty (  )  const throw () [inline]

Same as is_empty(); for compatibility with std::string interface.

Definition at line 194 of file fstring.h.

References is_empty().

bool rutz::fstring::ends_with ( const fstring ext  )  const throw ()

Query whether the terminal substring matches the given string.

Definition at line 319 of file fstring.cc.

Referenced by rutz::ibzip2open(), rutz::obzip2open(), and rutz::ogzopen().

bool rutz::fstring::equals ( const fstring other  )  const throw ()

Query for equality with another fstring object.

Definition at line 344 of file fstring.cc.

bool rutz::fstring::equals ( const char *  other  )  const throw ()

Query for equality with a C-style string.

Definition at line 337 of file fstring.cc.

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

bool rutz::fstring::is_empty (  )  const throw () [inline]

Query whether the length of the string is 0.

Definition at line 191 of file fstring.h.

References length().

Referenced by empty().

std::size_t rutz::fstring::length ( void   )  const throw () [inline]

Get the number of characters in the string (NOT INCLUDING the null terminator).

Definition at line 188 of file fstring.h.

Referenced by is_empty(), rutz::error_context::prepend_to(), rutz::error::what(), and write().

bool rutz::fstring::operator!= ( const fstring rhs  )  const throw () [inline]

Inequality operator.

Definition at line 266 of file fstring.h.

References equals().

bool rutz::fstring::operator!= ( const char *  rhs  )  const throw () [inline]

Inequality operator.

Definition at line 264 of file fstring.h.

References equals().

template<class string_type >
bool rutz::fstring::operator< ( const string_type &  other  )  const throw () [inline]

Query if string is lexicographically less-than another string.

Definition at line 223 of file fstring.h.

References c_str(), and operator<().

bool rutz::fstring::operator< ( const char *  other  )  const throw ()

Query if string is lexicographically less-than another string.

Definition at line 353 of file fstring.cc.

Referenced by operator<().

rutz::fstring & rutz::fstring::operator= ( const fstring other  )  throw ()

Assignment operator.

Definition at line 310 of file fstring.cc.

rutz::fstring & rutz::fstring::operator= ( const char *  text  ) 

Assign from a C-style null-terminated char array.

Definition at line 301 of file fstring.cc.

References swap().

bool rutz::fstring::operator== ( const fstring rhs  )  const throw () [inline]

Equality operator.

Definition at line 261 of file fstring.h.

References equals().

bool rutz::fstring::operator== ( const char *  rhs  )  const throw () [inline]

Equality operator.

Definition at line 259 of file fstring.h.

References equals().

template<class string_type >
bool rutz::fstring::operator> ( const string_type &  other  )  const throw () [inline]

Query if string is lexicographically greater-than another string.

Definition at line 233 of file fstring.h.

References c_str(), and operator>().

bool rutz::fstring::operator> ( const char *  other  )  const throw ()

Query if string is lexicographically greater-than another string.

Definition at line 362 of file fstring.cc.

Referenced by operator>().

char rutz::fstring::operator[] ( unsigned int  i  )  const [inline]

Return the character at position i.

Definition at line 197 of file fstring.h.

void rutz::fstring::read ( std::istream &  is  ) 

Set the string by reading consecutive non-whitespace characters.

Definition at line 377 of file fstring.cc.

References fstring().

void rutz::fstring::readline ( std::istream &  is,
char  eol = '\n' 
)

Set the string by reading characters up until newline or EOF.

Definition at line 395 of file fstring.cc.

References fstring().

void rutz::fstring::readsome ( std::istream &  is,
unsigned int  count 
)

Set the string by reading exactly count characters.

Definition at line 383 of file fstring.cc.

References fstring().

void rutz::fstring::swap ( rutz::fstring other  )  throw ()

Swap contents with another fstring object.

Definition at line 294 of file fstring.cc.

Referenced by operator=().

void rutz::fstring::write ( std::ostream &  os  )  const

Write the string's contents to the ostream.

Definition at line 389 of file fstring.cc.

References c_str(), and length().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:44:43 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3