Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rutz::fstring Class Reference

#include <rutz/fstring.h>

Collaboration diagram for rutz::fstring:

Collaboration graph
[legend]
List of all members.

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.

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.


Constructor & Destructor Documentation

rutz::fstring::fstring  ) 
 

Construct an empty string.

Definition at line 269 of file fstring.cc.

References GVX_TRACE, and rutz::string_rep::incr_ref_count().

Referenced by clear().

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

Copy constructor.

Definition at line 277 of file fstring.cc.

References GVX_TRACE.

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

Destructory.

Definition at line 284 of file fstring.cc.

References dbg_dump, rutz::string_rep::decr_ref_count(), and GVX_TRACE.

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]
 

Get a pointer to the const underlying data array.

Definition at line 185 of file fstring.h.

Referenced by nub::logging::add_obj_scope(), tcl::interpreter::append_result(), arrowDispatch(), tcl::aux_convert_from(), tcl::aux_convert_to(), cmdUsage(), tcl::emu_namesp::export_cmd(), GVX_DBG_REGISTER::factory_pkg_loader(), tcl::emu_namesp::get_export_list(), rutz::unixcall::get_file_user_pid(), tcl::interpreter::handle_live_exception(), rutz::ibzip2open(), rutz::igzopen(), tcl::command_group::lookup_original(), rutz::obzip2open(), rutz::ogzopen(), rutz::assoc_array_base::impl::fstring_cmp::operator()(), operator<(), operator>(), rutz::error_context::prepend_to(), ColorbarsInput::readFrame(), nub::logging::remove_obj_scope(), tcl::script_app::run(), nub::logging::set_log_filename(), rutz::value::set_string(), rutz::assoc_array_base::throw_for_key(), PluginFallback::try_fallback(), ImageObj< T >::updateString(), tcl::command::usage_string(), rutz::error::what(), and write().

void rutz::fstring::clear  ) 
 

Reset to an empty string.

Definition at line 330 of file fstring.cc.

References fstring(), and GVX_TRACE.

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

Dump contents for debugging.

Definition at line 401 of file fstring.cc.

References dbg_eval_nl, and rutz::string_rep::debug_dump().

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.

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.

References GVX_TRACE.

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.

References GVX_TRACE.

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.

References GVX_TRACE.

Referenced by rutz::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 rutz::string_rep::length().

Referenced by append_usage(), and tcl::script_app::run().

std::size_t rutz::fstring::length  )  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 tcl::aux_convert_from(), rutz::assoc_array_base::impl::fstring_cmp::operator()(), rutz::error_context::prepend_to(), tcl::script_app::run(), ImageObj< T >::updateString(), 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.

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

Inequality operator.

Definition at line 264 of file fstring.h.

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.

References GVX_TRACE.

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

Assignment operator.

Definition at line 310 of file fstring.cc.

References GVX_TRACE.

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 GVX_TRACE, and swap().

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

Equality operator.

Definition at line 261 of file fstring.h.

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

Equality operator.

Definition at line 259 of file fstring.h.

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.

References GVX_TRACE.

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 GVX_TRACE, and rutz::string_rep::read_from_stream().

Referenced by rutz::operator>>().

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 GVX_TRACE, and rutz::string_rep::readline_from_stream().

Referenced by rutz::getline().

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 GVX_TRACE, and rutz::string_rep::readsome_from_stream().

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

Swap contents with another fstring object.

Definition at line 294 of file fstring.cc.

References GVX_TRACE, and rutz::swap2().

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(), GVX_TRACE, and length().

Referenced by rutz::operator<<().


The documentation for this class was generated from the following files:
Generated on Sun Nov 22 13:51:42 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4