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.


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

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:56:34 2008 by Doxygen version 1.5.5.