basic_string_view Class Template Reference
[String Library]

#include <stlsoft/string/string_view.hpp>

Inheritance diagram for basic_string_view:

stl_collection_tag collection_tag

List of all members.


Detailed Description

template<typename C, typename T = char_traits<C>, typename A = typename allocator_selector<C>::allocator_type>
class stlsoft::basic_string_view< C, T, A >

A string class that holds no internal storage, and merely represents a window into other string storage.

Parameters:
C The character type
T The traits type. On translators that support default template arguments this is defaulted to char_traits<C>
A The allocator type. On translators that support default template arguments this is defaulted to allocator_selector<C>::allocator_type. This is only used by the proxy generated by c_str()

Attributes

size_type size () const throw ()
 The number of elements in the string.
size_type length () const throw ()
 The number of elements in the string.
size_type capacity () const throw ()
 The storage currently allocated by the string.
bool empty () const throw ()
 Indicates whether the string is empty.
allocator_type get_allocator () const
 Returns an instance of the allocator type.
static size_type max_size () throw ()
 The maximum number of elements that can be stored in the string.

Public Types

typedef C value_type
 The value type.
typedef T traits_type
 The traits type.
typedef A allocator_type
 The allocator type.
typedef basic_string_view< C,
T, A > 
class_type
 The current parameterisation of the type.
typedef value_type char_type
 The character type.
typedef value_type const * const_pointer
 The non-mutable (const) pointer type.
typedef value_type const & const_reference
 The non-mutable (const) reference type.
typedef size_t size_type
 The size type.
typedef ss_ptrdiff_t difference_type
 The difference type.
typedef pointer_iterator
< value_type const
, const_pointer,
const_reference >::type 
const_iterator
 The non-mutating (const) iterator type.

Public Member Functions

Construction
 basic_string_view ()
 Default constructor.
 basic_string_view (class_type const &rhs)
 Copy constructor.
 basic_string_view (class_type const &s, size_type pos)
 Construct from the given string at the specified position.
 basic_string_view (class_type const &s, size_type pos, size_type cch)
 Construct with cch characters from the given string at the specified position.
 basic_string_view (char_type const *s)
 Construct from a null-terminated character string.
 basic_string_view (char_type const *s, size_type cch)
 Construct with cch characters from the given character string.
 basic_string_view (char_type const *first, char_type const *last)
 Construct from the range [first:last).
 ~basic_string_view () throw ()
 Destructor.
class_typeoperator= (class_type const &rhs)
 Copy assignment operator.
Operations
void swap (class_type &other) throw ()
 Swaps the contents between this and other.
void clear () throw ()
 Empties the string.
void refresh () throw ()
 Clear c_str() representation.
Comparison
bool equal (class_type const &rhs) const throw ()
 Evaluates whether two strings are equal.
bool equal (value_type const *rhs, size_type cchRhs) const throw ()
 Evaluates whether two strings are equal.
ss_sint_t compare (size_type pos, size_type cch, value_type const *s, size_type cchRhs) const throw ()
 Compares this with the given string.
ss_sint_t compare (size_type pos, size_type cch, value_type const *s) const throw ()
 Compares this with the given string.
ss_sint_t compare (value_type const *s) const throw ()
 Compares this with the given string.
ss_sint_t compare (size_type pos, size_type cch, class_type const &rhs, size_type posRhs, size_type cchRhs) const throw ()
 Compares this with the given string.
ss_sint_t compare (size_type pos, size_type cch, class_type const &rhs) const throw ()
 Compares this with the given string.
ss_sint_t compare (class_type const &rhs) const throw ()
 Compares this with the given string.
Accessors
const_reference operator[] (size_type index) const
 Returns non-mutable (const) reference at the given index.
const_reference at (size_type index) const
 Returns non-mutable (const) reference at the given index.
value_type const * c_str () const
 Returns null-terminated non-mutable (const) pointer to string data.
value_type const * data () const throw ()
 Returns non-mutable (const) pointer to string data.
value_type const * base () const throw ()
 Returns value of base pointer.
const_reference front () const
 Returns the first character in the string.
const_reference back () const
 Returns the last character in the string.
size_type copy (value_type *dest, size_type cch, size_type pos=0) const
 Copies elements into the given destination.
Iteration
const_iterator begin () const
 Begins the iteration.
const_iterator end () const
 Ends the iteration.

Member Typedef Documentation

typedef C value_type

The value type.

typedef T traits_type

The traits type.

typedef A allocator_type

The allocator type.

typedef basic_string_view<C, T, A> class_type

The current parameterisation of the type.

The character type.

typedef value_type const* const_pointer

The non-mutable (const) pointer type.

typedef value_type const& const_reference

The non-mutable (const) reference type.

typedef size_t size_type

The size type.

The difference type.

The non-mutating (const) iterator type.


Constructor & Destructor Documentation

Default constructor.

basic_string_view ( class_type const &  rhs  ) 

Copy constructor.

basic_string_view ( class_type const &  s,
size_type  pos 
)

Construct from the given string at the specified position.

basic_string_view ( class_type const &  s,
size_type  pos,
size_type  cch 
)

Construct with cch characters from the given string at the specified position.

basic_string_view ( char_type const *  s  ) 

Construct from a null-terminated character string.

basic_string_view ( char_type const *  s,
size_type  cch 
)

Construct with cch characters from the given character string.

basic_string_view ( char_type const *  first,
char_type const *  last 
)

Construct from the range [first:last).

~basic_string_view (  )  throw ()

Destructor.


Member Function Documentation

class_type& operator= ( class_type const &  rhs  ) 

Copy assignment operator.

void swap ( class_type other  )  throw ()

Swaps the contents between this and other.

void clear (  )  throw ()

Empties the string.

void refresh (  )  throw ()

Clear c_str() representation.

Causes the c_str() representation, if currently allocated (see c_str() for details), to be destroyed, in order that the next call to c_str() will result in a fresh nul-terminated copy of the 'current' contents of the view.

size_type size (  )  const throw ()

The number of elements in the string.

static size_type max_size (  )  throw () [static]

The maximum number of elements that can be stored in the string.

size_type length (  )  const throw ()

The number of elements in the string.

size_type capacity (  )  const throw ()

The storage currently allocated by the string.

bool empty (  )  const throw ()

Indicates whether the string is empty.

allocator_type get_allocator (  )  const

Returns an instance of the allocator type.

bool equal ( class_type const &  rhs  )  const throw ()

Evaluates whether two strings are equal.

bool equal ( value_type const *  rhs,
size_type  cchRhs 
) const throw ()

Evaluates whether two strings are equal.

ss_sint_t compare ( size_type  pos,
size_type  cch,
value_type const *  s,
size_type  cchRhs 
) const throw ()

Compares this with the given string.

ss_sint_t compare ( size_type  pos,
size_type  cch,
value_type const *  s 
) const throw ()

Compares this with the given string.

ss_sint_t compare ( value_type const *  s  )  const throw ()

Compares this with the given string.

ss_sint_t compare ( size_type  pos,
size_type  cch,
class_type const &  rhs,
size_type  posRhs,
size_type  cchRhs 
) const throw ()

Compares this with the given string.

ss_sint_t compare ( size_type  pos,
size_type  cch,
class_type const &  rhs 
) const throw ()

Compares this with the given string.

ss_sint_t compare ( class_type const &  rhs  )  const throw ()

Compares this with the given string.

const_reference operator[] ( size_type  index  )  const

Returns non-mutable (const) reference at the given index.

Note:
Follows the convention of std::basic_string in returning a reference to char_type() if index == size(). This reference will not be part of the block constituting the string's viewed area.

const_reference at ( size_type  index  )  const

Returns non-mutable (const) reference at the given index.

Note:
Throws std::out_of_range if index >= size()

value_type const* c_str (  )  const

Returns null-terminated non-mutable (const) pointer to string data.

Note:
This returns a nul-terminated copy of the string. If the view's underlying string changes after this point, this will not be reflected in the value returned by c_str(), until such time as refresh() is called.

If the view's parameterisation is with a no-throw allocator, behaviour is undefined in con

value_type const* data (  )  const throw ()

Returns non-mutable (const) pointer to string data.

value_type const* base (  )  const throw ()

Returns value of base pointer.

const_reference front (  )  const

Returns the first character in the string.

Note:
It is up to the user to ensure that the string is not empty

const_reference back (  )  const

Returns the last character in the string.

Note:
It is up to the user to ensure that the string is not empty

size_type copy ( value_type dest,
size_type  cch,
size_type  pos = 0 
) const

Copies elements into the given destination.

const_iterator begin (  )  const

Begins the iteration.

Returns:
A non-mutable (const) iterator representing the start of the sequence

const_iterator end (  )  const

Ends the iteration.

Returns:
A non-mutable (const) iterator representing the end of the sequence


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

Generated on Thu Jun 10 08:59:00 2010 for STLSoft by  doxygen 1.5.6