string Class Reference

#include <string.hpp>

Inheritance diagram for string:

Inheritance graph
[legend]
Collaboration diagram for string:

Collaboration graph
[legend]

List of all members.


Detailed Description

A Unicode string class.

Definition at line 60 of file string.hpp.


Various Useful Utilities

string copy ()
 Makes a deep copy of the string that is not shared.
stringmake_lower ()
stringmake_upper ()
data::list< stringsplit (const string &separator) const
data::list< stringsplit (const wchar_t *separator) const
bool to_bool () const
double to_double () const
int to_int () const
stringtrim ()
static string format (const string &format,...)
static string format (const wchar_t *format,...)

Public Member Functions

virtual bool contains_index (const I &) const =0
virtual bool is_empty () const
 Returns true if the collection is empty.
virtual T & item (const I &index)=0
virtual const T & item (const I &index) const =0
stringoperator= (const string &)
stringoperator= (wchar_t *)
stringoperator= (const wchar_t *)
T & operator[] (const I &index)
const T & operator[] (const I &index) const
 string (const char *)
 string (wchar_t *)
 Makes a copy of the given wide-character string.
 string (const wchar_t *)
 Does NOT make a copy of the given wide-character string, only keeps a reference to it.
 string (const string &)
 string ()
virtual ~string ()
Other Useful Functions
virtual void append (const T &)=0
 Add an item to the end of the collection.
virtual void append (const iterable< T, IBase > &)
 Append all members of a collection to this one.
virtual iterator find_value (const T &)
virtual const_iterator find_value (const T &) const
 A generic find function that iterates over the collection to find a particular value.
virtual void insert (const iterator &, const T &)=0
 Insert an item before the one specified by the iterator.
Iterable Implementation Etc.
void append (const string &)
void append (const wchar_t *)
virtual void append (const wchar_t &)
virtual void insert (const iterator &, const wchar_t &)
virtual void remove (const iterator &)
 Remove the item specified by the iterator.
Pointer Access
const char * c_string () const
const unsigned char * p_string () const
const wchar_t * w_string () const
Countable Implementation
virtual void clear ()
 Clears the contents of the collection.
virtual gsgl::index_t size () const
 A generic count function that iterates over the collection.
Comparable Implementation Etc.
int compare (const wchar_t *) const
virtual int compare (const data::comparable &) const
 Compares two objects. Implementations should check the type of the given object.
bool operator!= (const wchar_t *s) const
bool operator< (const wchar_t *s) const
bool operator<= (const wchar_t *s) const
bool operator== (const wchar_t *s) const
bool operator> (const wchar_t *s) const
bool operator>= (const wchar_t *s) const
Indexable Implementation
virtual bool contains_index (const gsgl::index_t &index) const
virtual wchar_t & item (const gsgl::index_t &index)
virtual const wchar_t & item (const gsgl::index_t &index) const
Substrings
gsgl::index_t find (const string &substr, const gsgl::index_t index=0) const
gsgl::index_t find (const wchar_t *substr, const gsgl::index_t index=0) const
gsgl::index_t find_reverse (const string &substr, const gsgl::index_t index=-1) const
gsgl::index_t find_reverse (const wchar_t *substr, const gsgl::index_t index=-1) const
string left_substring (const gsgl::index_t length) const
string right_substring (const gsgl::index_t length) const
string substring (const gsgl::index_t index, const gsgl::index_t length=-1) const
Serializable Implementation
virtual void from_stream (io::data_stream &)
virtual void to_stream (io::data_stream &) const
Printable Implementation
virtual void from_stream (io::text_stream &)
virtual void to_stream (io::text_stream &) const
Iterators
iterator iter ()
const_iterator iter () const
String Concatenation
string operator+ (const string &) const
string operator+ (const wchar_t *) const
string operator+ (const wchar_t &) const
stringoperator+= (const string &)
stringoperator+= (const wchar_t *)
stringoperator+= (const wchar_t &)

Static Public Attributes

static const string EMPTY_STRING = L""

Private Types

enum  string_mode { STRING_NULL = 0, STRING_CONST_REF = 1, STRING_SHARED_IMPL = 2, STRING_INVALID = 3 }

Private Member Functions

void make_null ()
void unshare () const

Private Attributes

union {
   string_impl *   impl
   const wchar_t *   ref
}; 
string_mode mode

Member Enumeration Documentation

enum string_mode [private]

Enumerator:
STRING_NULL 
STRING_CONST_REF 
STRING_SHARED_IMPL 
STRING_INVALID 

Definition at line 70 of file string.hpp.


Constructor & Destructor Documentation

string (  ) 

Definition at line 201 of file string.cpp.

References ASSIGN_DEBUG_PTR.

Referenced by string::format(), and string::right_substring().

string ( const string s  ) 

Definition at line 215 of file string.cpp.

References ASSIGN_DEBUG_PTR.

string ( const wchar_t *  str  ) 

Does NOT make a copy of the given wide-character string, only keeps a reference to it.

Definition at line 247 of file string.cpp.

References ASSIGN_DEBUG_PTR.

string ( wchar_t *  str  ) 

Makes a copy of the given wide-character string.

Definition at line 231 of file string.cpp.

References ASSIGN_DEBUG_PTR, and string::unshare().

string ( const char *  str  )  [explicit]

~string (  )  [virtual]


Member Function Documentation

virtual void append ( const T &   )  [pure virtual, inherited]

Add an item to the end of the collection.

Implemented in simple_array, dictionary, list, and pqueue.

void append ( const iterable< T, IBase > &  a  )  [inline, virtual, inherited]

Append all members of a collection to this one.

Definition at line 145 of file iterable.hpp.

void append ( const string str  ) 

Definition at line 424 of file string.cpp.

References string::append(), and string::w_string().

void append ( const wchar_t *  str  ) 

void append ( const wchar_t &  ch  )  [virtual]

const char * c_string (  )  const

void clear (  )  [virtual]

int compare ( const wchar_t *  str  )  const

Definition at line 511 of file string.cpp.

References string::w_string().

int compare ( const data::comparable  )  const [virtual]

Compares two objects. Implementations should check the type of the given object.

Implements comparable.

Definition at line 497 of file string.cpp.

References string::w_string().

Referenced by directory::compare().

virtual bool contains_index ( const I &   )  const [pure virtual, inherited]

Implemented in dictionary.

bool contains_index ( const gsgl::index_t index  )  const [virtual]

Definition at line 489 of file string.cpp.

References string::size().

string copy (  ) 

Makes a deep copy of the string that is not shared.

Definition at line 758 of file string.cpp.

References string::unshare().

Referenced by string::unshare().

gsgl::index_t find ( const string substr,
const gsgl::index_t  index = 0 
) const

Definition at line 719 of file string.cpp.

References string::find(), and string::w_string().

gsgl::index_t find ( const wchar_t *  substr,
const gsgl::index_t  index = 0 
) const

Definition at line 711 of file string.cpp.

References string::w_string().

Referenced by string::find().

gsgl::index_t find_reverse ( const string substr,
const gsgl::index_t  index = -1 
) const

Definition at line 750 of file string.cpp.

References string::find_reverse(), and string::w_string().

gsgl::index_t find_reverse ( const wchar_t *  substr,
const gsgl::index_t  index = -1 
) const

Definition at line 725 of file string.cpp.

References string::w_string().

Referenced by string::find_reverse(), and application::get_program_dir().

iterable< T, IBase >::iterator find_value ( const T &  item  )  [inline, virtual, inherited]

Definition at line 168 of file iterable.hpp.

References iterable::iterator::is_valid().

iterable< T, IBase >::const_iterator find_value ( const T &  item  )  const [inline, virtual, inherited]

A generic find function that iterates over the collection to find a particular value.

Note:
Not efficient; should be overridden if possible.

Definition at line 153 of file iterable.hpp.

References iterable::const_iterator::is_valid().

Referenced by gsgl::data::global_unregister_resource_aux().

string format ( const string format,
  ... 
) [static]

Definition at line 899 of file string.cpp.

References string::size(), string::string(), and string::w_string().

string format ( const wchar_t *  format,
  ... 
) [static]

void from_stream ( io::data_stream s  )  [virtual]

Implements serializable.

Definition at line 573 of file string.cpp.

References ASSIGN_DEBUG_PTR, smart_pointer::ptr(), and data_stream::read().

void from_stream ( io::text_stream s  )  [virtual]

virtual void insert ( const iterator ,
const T &   
) [pure virtual, inherited]

Insert an item before the one specified by the iterator.

Implemented in simple_array, dictionary, list, and pqueue.

void insert ( const iterator i,
const wchar_t &  ch 
) [virtual]

virtual bool is_empty (  )  const [inline, virtual, inherited]

virtual T& item ( const I &  index  )  [pure virtual, inherited]

Implemented in dictionary.

virtual const T& item ( const I &  index  )  const [pure virtual, inherited]

wchar_t & item ( const gsgl::index_t index  )  [virtual]

const wchar_t & item ( const gsgl::index_t index  )  const [virtual]

iterator iter (  )  [inline, inherited]

Returns:
An iterator pointing to the first item in the collection.

Definition at line 101 of file iterable.hpp.

const_iterator iter (  )  const [inline, inherited]

string left_substring ( const gsgl::index_t  length  )  const

Definition at line 691 of file string.cpp.

References string::substring().

Referenced by event_map::load_keyboard_events().

string & make_lower (  ) 

void make_null (  )  [private]

string & make_upper (  ) 

bool operator!= ( const wchar_t *  s  )  const [inline]

Definition at line 139 of file string.hpp.

string operator+ ( const string str  )  const

Definition at line 661 of file string.cpp.

References string::append(), and string::w_string().

string operator+ ( const wchar_t *  str  )  const

Definition at line 653 of file string.cpp.

References string::append().

string operator+ ( const wchar_t &  ch  )  const

Definition at line 645 of file string.cpp.

References string::append().

string & operator+= ( const string str  ) 

Definition at line 638 of file string.cpp.

References string::append(), and string::w_string().

string & operator+= ( const wchar_t *  str  ) 

Definition at line 631 of file string.cpp.

References string::append().

string & operator+= ( const wchar_t &  ch  ) 

Definition at line 624 of file string.cpp.

References string::append().

bool operator< ( const wchar_t *  s  )  const [inline]

Definition at line 140 of file string.hpp.

bool operator<= ( const wchar_t *  s  )  const [inline]

Definition at line 141 of file string.hpp.

string & operator= ( const string s  ) 

string & operator= ( wchar_t *  str  ) 

string & operator= ( const wchar_t *  str  ) 

bool operator== ( const wchar_t *  s  )  const [inline]

Definition at line 138 of file string.hpp.

bool operator> ( const wchar_t *  s  )  const [inline]

Definition at line 142 of file string.hpp.

bool operator>= ( const wchar_t *  s  )  const [inline]

Definition at line 143 of file string.hpp.

T& operator[] ( const I &  index  )  [inline, inherited]

Definition at line 58 of file indexable.hpp.

const T& operator[] ( const I &  index  )  const [inline, inherited]

Definition at line 57 of file indexable.hpp.

const unsigned char * p_string (  )  const

Definition at line 615 of file string.cpp.

References string_impl::get_p_string(), string::impl, and string::unshare().

void remove ( const iterator  )  [virtual]

Remove the item specified by the iterator.

Implements iterable.

Definition at line 440 of file string.cpp.

References assert, string::impl, simple_array::remove(), string_impl::set_modified(), string::unshare(), and string_impl::w_data.

string right_substring ( const gsgl::index_t  length  )  const

gsgl::index_t size (  )  const [virtual]

data::list< string > split ( const string separator  )  const

Definition at line 854 of file string.cpp.

References string::split(), and string::w_string().

data::list< string > split ( const wchar_t *  separator  )  const

string substring ( const gsgl::index_t  index,
const gsgl::index_t  length = -1 
) const

bool to_bool (  )  const

Definition at line 826 of file string.cpp.

References string::impl, simple_array::ptr(), and string_impl::w_data.

double to_double (  )  const

int to_int (  )  const

Definition at line 836 of file string.cpp.

References string::size(), and string::w_string().

Referenced by config_variable::assign_from_string().

void to_stream ( io::data_stream s  )  const [virtual]

Implements serializable.

Definition at line 565 of file string.cpp.

References string::size(), string::w_string(), and data_stream::write().

void to_stream ( io::text_stream s  )  const [virtual]

Implements printable.

Definition at line 534 of file string.cpp.

References string::w_string().

string & trim (  ) 

void unshare (  )  const [private]

const wchar_t * w_string (  )  const

Definition at line 591 of file string.cpp.

References assert, string_impl::get_w_string(), string::impl, string::mode, string::ref, string::STRING_CONST_REF, string::STRING_NULL, and string::STRING_SHARED_IMPL.

Referenced by string::append(), texture_impl::bind(), string::compare(), shader_base::compile(), config_record::config_record(), fragment_shader::create(), vertex_shader::create(), directory::create(), broker::create_object(), main_window::draw(), file::file(), file_log_target::file_log_target(), file_stream::file_stream(), string::find(), string::find_reverse(), font::font(), font_impl::font_impl(), string::format(), julian_day::from_gregorian_string(), keplerian_element_propagator::get_array(), config_record::get_child(), application::get_cmdline_dir(), application::get_config_overrides(), directory::get_dirs(), directory::get_files(), font_impl::get_glyph(), directory::get_paths(), gsgl::data::global_register_resource_aux(), heightmap::init(), stellar_db::load_db(), event_map::load_keyboard_events(), material_file::load_mtl_file(), mesh_file::load_obj_file(), application::load_objects(), application::load_package(), application::load_scenery(), mapped_file::mapped_file(), material::material(), material_file::material_file(), mesh_file::mesh_file(), model::model(), model_part::model_part(), string::operator+(), string::operator+=(), config_record::override_with(), package::package(), ft_stream::peek(), pkg_library::pkg_library(), pkg_scenery::pkg_scenery(), pkg_vehicle::pkg_vehicle(), debug_log_target::print_line(), file::remove(), rgba_buffer::rgba_buffer(), simulation::simulation(), solar_system::solar_system(), string::split(), string::substring(), texture::texture(), texture_impl::texture_impl(), string::to_double(), string::to_int(), string::to_stream(), string::trim(), vehicle::vehicle(), vehicle_module::vehicle_module(), and file_log_target::~file_log_target().


Member Data Documentation

union { ... } [private]

const string EMPTY_STRING = L"" [static]

Definition at line 214 of file string.hpp.

string_impl* impl [mutable]

string_mode mode [mutable, private]

const wchar_t* ref


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

Generated on Sat Mar 1 13:50:05 2008 for Periapsis Project by  doxygen 1.5.5