Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::basic_string_literal< CharT, TraitsT > Singleton Reference

String literal wrapper. More...

#include <string_literal_fwd.hpp>

Public Types

typedef CharT value_type
 
typedef TraitsT traits_type
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef const value_typeconst_pointer
 
typedef value_type const & const_reference
 
typedef const value_typeconst_iterator
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 
typedef std::basic_string
< value_type, traits_type
string_type
 Corresponding STL string type. More...
 

Public Member Functions

 basic_string_literal () BOOST_NOEXCEPT
 Constructor. More...
 
template<typename T , size_type LenV>
 basic_string_literal (T(&p)[LenV]) BOOST_NOEXCEPT
 Constructor from a string literal. More...
 
 basic_string_literal (basic_string_literal const &that) BOOST_NOEXCEPT
 Copy constructor. More...
 
this_typeoperator= (this_type const &that) BOOST_NOEXCEPT
 Assignment operator. More...
 
template<typename T , size_type LenV>
enable_if< is_same< T, const
value_type >, this_type & >
::type 
operator= (T(&p)[LenV]) BOOST_NOEXCEPT
 Assignment from a string literal. More...
 
bool operator== (this_type const &that) const BOOST_NOEXCEPT
 Lexicographical comparison (equality) More...
 
bool operator== (const_pointer str) const BOOST_NOEXCEPT
 Lexicographical comparison (equality) More...
 
bool operator== (string_type const &that) const
 Lexicographical comparison (equality) More...
 
bool operator< (this_type const &that) const BOOST_NOEXCEPT
 Lexicographical comparison (less ordering) More...
 
bool operator< (const_pointer str) const BOOST_NOEXCEPT
 Lexicographical comparison (less ordering) More...
 
bool operator< (string_type const &that) const
 Lexicographical comparison (less ordering) More...
 
bool operator> (this_type const &that) const BOOST_NOEXCEPT
 Lexicographical comparison (greater ordering) More...
 
bool operator> (const_pointer str) const BOOST_NOEXCEPT
 Lexicographical comparison (greater ordering) More...
 
bool operator> (string_type const &that) const
 Lexicographical comparison (greater ordering) More...
 
const_reference operator[] (size_type i) const BOOST_NOEXCEPT
 Subscript operator. More...
 
const_reference at (size_type i) const
 Checked subscript. More...
 
const_pointer c_str () const BOOST_NOEXCEPT
 
const_pointer data () const BOOST_NOEXCEPT
 
size_type size () const BOOST_NOEXCEPT
 
size_type length () const BOOST_NOEXCEPT
 
bool empty () const BOOST_NOEXCEPT
 
const_iterator begin () const BOOST_NOEXCEPT
 
const_iterator end () const BOOST_NOEXCEPT
 
const_reverse_iterator rbegin () const BOOST_NOEXCEPT
 
const_reverse_iterator rend () const BOOST_NOEXCEPT
 
string_type str () const
 
void clear () BOOST_NOEXCEPT
 The method clears the literal. More...
 
void swap (this_type &that) BOOST_NOEXCEPT
 The method swaps two literals. More...
 
this_typeassign (this_type const &that) BOOST_NOEXCEPT
 Assignment from another literal. More...
 
template<typename T , size_type LenV>
enable_if< is_same< T, const
value_type >, this_type & >
::type 
assign (T(&p)[LenV]) BOOST_NOEXCEPT
 Assignment from another literal. More...
 
size_type copy (value_type *str, size_type n, size_type pos=0) const
 The method copies the literal or its portion to an external buffer. More...
 
int compare (size_type pos, size_type n, const_pointer str, size_type len) const
 Lexicographically compares the argument string to a part of this string. More...
 
int compare (size_type pos, size_type n, const_pointer str) const BOOST_NOEXCEPT
 Lexicographically compares the argument string to a part of this string. More...
 
int compare (size_type pos, size_type n, this_type const &that) const BOOST_NOEXCEPT
 Lexicographically compares the argument string literal to a part of this string. More...
 
int compare (const_pointer str, size_type len) const BOOST_NOEXCEPT
 Lexicographically compares the argument string to this string. More...
 
int compare (const_pointer str) const BOOST_NOEXCEPT
 Lexicographically compares the argument string to this string. More...
 
int compare (this_type const &that) const BOOST_NOEXCEPT
 Lexicographically compares the argument string to this string. More...
 

Detailed Description

template<typename CharT, typename TraitsT>
singleton boost::basic_string_literal< CharT, TraitsT >

String literal wrapper.

The basic_string_literal is a thin wrapper around a constant string literal. It provides interface similar to STL strings, but because of read-only nature of string literals, lacks ability to modify string contents. However, basic_string_literal objects can be assigned to and cleared.

The main advantage of this class comparing to other string classes is that it doesn't dynamically allocate memory and therefore is fast, thin and exception safe.

Member Typedef Documentation

template<typename CharT, typename TraitsT>
typedef const value_type* boost::basic_string_literal< CharT, TraitsT >::const_iterator
template<typename CharT, typename TraitsT>
typedef const value_type* boost::basic_string_literal< CharT, TraitsT >::const_pointer
template<typename CharT, typename TraitsT>
typedef value_type const& boost::basic_string_literal< CharT, TraitsT >::const_reference
template<typename CharT, typename TraitsT>
typedef std::reverse_iterator< const_iterator > boost::basic_string_literal< CharT, TraitsT >::const_reverse_iterator
template<typename CharT, typename TraitsT>
typedef std::ptrdiff_t boost::basic_string_literal< CharT, TraitsT >::difference_type
template<typename CharT, typename TraitsT>
typedef std::size_t boost::basic_string_literal< CharT, TraitsT >::size_type
template<typename CharT, typename TraitsT>
typedef std::basic_string< value_type, traits_type > boost::basic_string_literal< CharT, TraitsT >::string_type

Corresponding STL string type.

template<typename CharT, typename TraitsT>
typedef TraitsT boost::basic_string_literal< CharT, TraitsT >::traits_type
template<typename CharT, typename TraitsT>
typedef CharT boost::basic_string_literal< CharT, TraitsT >::value_type

Constructor & Destructor Documentation

template<typename CharT, typename TraitsT>
boost::basic_string_literal< CharT, TraitsT >::basic_string_literal ( )
inline

Constructor.

Postcondition
empty() == true

References boost::basic_string_literal< CharT, TraitsT >::clear().

template<typename CharT, typename TraitsT>
template<typename T , size_type LenV>
boost::basic_string_literal< CharT, TraitsT >::basic_string_literal ( T(&)  p[LenV])
inline

Constructor from a string literal.

Postcondition
*this == p
Parameters
pA zero-terminated constant sequence of characters
template<typename CharT, typename TraitsT>
boost::basic_string_literal< CharT, TraitsT >::basic_string_literal ( basic_string_literal< CharT, TraitsT > const &  that)
inline

Copy constructor.

Postcondition
*this == that
Parameters
thatSource literal to copy string from

Member Function Documentation

template<typename CharT, typename TraitsT>
this_type& boost::basic_string_literal< CharT, TraitsT >::assign ( this_type const &  that)
inline

Assignment from another literal.

Postcondition
*this == that
Parameters
thatSource literal to copy string from

Referenced by boost::basic_string_literal< CharT, TraitsT >::operator=().

template<typename CharT, typename TraitsT>
template<typename T , size_type LenV>
enable_if< is_same< T, const value_type >, this_type& >::type boost::basic_string_literal< CharT, TraitsT >::assign ( T(&)  p[LenV])
inline

Assignment from another literal.

Postcondition
*this == p
Parameters
pA zero-terminated constant sequence of characters

References boost::multiprecision::backends::p.

template<typename CharT, typename TraitsT>
const_reference boost::basic_string_literal< CharT, TraitsT >::at ( size_type  i) const
inline

Checked subscript.

Parameters
iRequested character index
Returns
Constant reference to the requested character

Throws: An std::exception-based exception if index i is out of string boundaries

References BOOST_THROW_EXCEPTION, and boost::multiprecision::backends::i.

template<typename CharT, typename TraitsT>
const_iterator boost::basic_string_literal< CharT, TraitsT >::begin ( void  ) const
inline
Returns
Iterator that points to the first character of the literal

Referenced by boost::basic_string_literal< CharT, TraitsT >::rend().

template<typename CharT, typename TraitsT>
const_pointer boost::basic_string_literal< CharT, TraitsT >::c_str ( ) const
inline
Returns
Pointer to the beginning of the literal

Referenced by boost::operator<<(), and boost::expressions::aux::parse_named_scope_format().

template<typename CharT, typename TraitsT>
void boost::basic_string_literal< CharT, TraitsT >::clear ( void  )
inline

The method clears the literal.

Postcondition
empty() == true

Referenced by boost::basic_string_literal< CharT, TraitsT >::basic_string_literal().

template<typename CharT, typename TraitsT>
int boost::basic_string_literal< CharT, TraitsT >::compare ( size_type  pos,
size_type  n,
const_pointer  str,
size_type  len 
) const
inline

Lexicographically compares the argument string to a part of this string.

Precondition
pos <= size()
Parameters
posStarting position within this string to perform comparison to
nLength of the substring of this string to perform comparison to
strComparand. Must point to a sequence of characters, must not be NULL.
lenNumber of characters in the sequence str.
Returns
Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand.

Throws: An std::exception-based exception if pos is out of range.

References BOOST_THROW_EXCEPTION, boost::python::len(), and boost::n.

Referenced by boost::basic_string_literal< CharT, TraitsT >::compare().

template<typename CharT, typename TraitsT>
int boost::basic_string_literal< CharT, TraitsT >::compare ( size_type  pos,
size_type  n,
const_pointer  str 
) const
inline

Lexicographically compares the argument string to a part of this string.

Precondition
pos <= size()
Parameters
posStarting position within this string to perform comparison to
nLength of the substring of this string to perform comparison to
strComparand. Must point to a zero-terminated sequence of characters, must not be NULL.
Returns
Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand.

Throws: An std::exception-based exception if pos is out of range.

References boost::basic_string_literal< CharT, TraitsT >::compare(), boost::n, and boost::basic_string_literal< CharT, TraitsT >::str().

template<typename CharT, typename TraitsT>
int boost::basic_string_literal< CharT, TraitsT >::compare ( size_type  pos,
size_type  n,
this_type const &  that 
) const
inline

Lexicographically compares the argument string literal to a part of this string.

Precondition
pos <= size()
Parameters
posStarting position within this string to perform comparison to
nLength of the substring of this string to perform comparison to
thatComparand
Returns
Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand.

Throws: An std::exception-based exception if pos is out of range.

References boost::basic_string_literal< CharT, TraitsT >::compare(), and boost::n.

template<typename CharT, typename TraitsT>
int boost::basic_string_literal< CharT, TraitsT >::compare ( const_pointer  str,
size_type  len 
) const
inline

Lexicographically compares the argument string to this string.

Parameters
strComparand. Must point to a sequence of characters, must not be NULL.
lenNumber of characters in the sequence str.
Returns
Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand.

References boost::basic_string_literal< CharT, TraitsT >::compare(), boost::python::len(), and boost::basic_string_literal< CharT, TraitsT >::str().

template<typename CharT, typename TraitsT>
int boost::basic_string_literal< CharT, TraitsT >::compare ( const_pointer  str) const
inline

Lexicographically compares the argument string to this string.

Parameters
strComparand. Must point to a zero-terminated sequence of characters, must not be NULL.
Returns
Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand.

References boost::basic_string_literal< CharT, TraitsT >::compare(), and boost::basic_string_literal< CharT, TraitsT >::str().

template<typename CharT, typename TraitsT>
int boost::basic_string_literal< CharT, TraitsT >::compare ( this_type const &  that) const
inline

Lexicographically compares the argument string to this string.

Parameters
thatComparand
Returns
Zero if the comparand equals this string, a negative value if this string is less than the comparand, a positive value if this string is greater than the comparand.

References boost::basic_string_literal< CharT, TraitsT >::compare().

template<typename CharT, typename TraitsT>
size_type boost::basic_string_literal< CharT, TraitsT >::copy ( value_type str,
size_type  n,
size_type  pos = 0 
) const
inline

The method copies the literal or its portion to an external buffer.

Precondition
pos <= size()
Parameters
strPointer to the external buffer beginning. Must not be NULL. The buffer must have enough capacity to accommodate the requested number of characters.
nMaximum number of characters to copy
posStarting position to start copying from
Returns
Number of characters copied

Throws: An std::exception-based exception if pos is out of range.

References BOOST_THROW_EXCEPTION, boost::filesystem::detail::copy(), boost::python::len(), and boost::n.

template<typename CharT, typename TraitsT>
const_pointer boost::basic_string_literal< CharT, TraitsT >::data ( ) const
inline
Returns
Pointer to the beginning of the literal
template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::empty ( void  ) const
inline
Returns
true if the literal is an empty string, false otherwise
template<typename CharT, typename TraitsT>
const_iterator boost::basic_string_literal< CharT, TraitsT >::end ( void  ) const
inline
Returns
Iterator that points after the last character of the literal

Referenced by boost::basic_string_literal< CharT, TraitsT >::rbegin().

template<typename CharT, typename TraitsT>
size_type boost::basic_string_literal< CharT, TraitsT >::length ( ) const
inline
Returns
Length of the literal
template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator< ( this_type const &  that) const
inline

Lexicographical comparison (less ordering)

Parameters
thatComparand
Returns
true if this string is less than the comparand, false otherwise
template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator< ( const_pointer  str) const
inline

Lexicographical comparison (less ordering)

Parameters
strComparand. Must point to a zero-terminated sequence of characters, must not be NULL.
Returns
true if this string is less than the comparand, false otherwise

References boost::basic_string_literal< CharT, TraitsT >::str().

template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator< ( string_type const &  that) const
inline

Lexicographical comparison (less ordering)

Parameters
thatComparand
Returns
true if this string is less than the comparand, false otherwise
template<typename CharT, typename TraitsT>
this_type& boost::basic_string_literal< CharT, TraitsT >::operator= ( this_type const &  that)
inline

Assignment operator.

Postcondition
*this == that
Parameters
thatSource literal to copy string from

References boost::basic_string_literal< CharT, TraitsT >::assign().

template<typename CharT, typename TraitsT>
template<typename T , size_type LenV>
enable_if< is_same< T, const value_type >, this_type& >::type boost::basic_string_literal< CharT, TraitsT >::operator= ( T(&)  p[LenV])
inline

Assignment from a string literal.

Postcondition
*this == p
Parameters
pA zero-terminated constant sequence of characters

References boost::basic_string_literal< CharT, TraitsT >::assign(), and boost::multiprecision::backends::p.

template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator== ( this_type const &  that) const
inline

Lexicographical comparison (equality)

Parameters
thatComparand
Returns
true if the comparand string equals to this string, false otherwise
template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator== ( const_pointer  str) const
inline

Lexicographical comparison (equality)

Parameters
strComparand. Must point to a zero-terminated sequence of characters, must not be NULL.
Returns
true if the comparand string equals to this string, false otherwise

References boost::basic_string_literal< CharT, TraitsT >::str().

template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator== ( string_type const &  that) const
inline

Lexicographical comparison (equality)

Parameters
thatComparand
Returns
true if the comparand string equals to this string, false otherwise
template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator> ( this_type const &  that) const
inline

Lexicographical comparison (greater ordering)

Parameters
thatComparand
Returns
true if this string is greater than the comparand, false otherwise
template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator> ( const_pointer  str) const
inline

Lexicographical comparison (greater ordering)

Parameters
strComparand. Must point to a zero-terminated sequence of characters, must not be NULL.
Returns
true if this string is greater than the comparand, false otherwise

References boost::basic_string_literal< CharT, TraitsT >::str().

template<typename CharT, typename TraitsT>
bool boost::basic_string_literal< CharT, TraitsT >::operator> ( string_type const &  that) const
inline

Lexicographical comparison (greater ordering)

Parameters
thatComparand
Returns
true if this string is greater than the comparand, false otherwise
template<typename CharT, typename TraitsT>
const_reference boost::basic_string_literal< CharT, TraitsT >::operator[] ( size_type  i) const
inline

Subscript operator.

Precondition
i < size()
Parameters
iRequested character index
Returns
Constant reference to the requested character

References boost::multiprecision::backends::i.

template<typename CharT, typename TraitsT>
const_reverse_iterator boost::basic_string_literal< CharT, TraitsT >::rbegin ( ) const
inline
Returns
Reverse iterator that points to the last character of the literal

References boost::basic_string_literal< CharT, TraitsT >::end().

template<typename CharT, typename TraitsT>
const_reverse_iterator boost::basic_string_literal< CharT, TraitsT >::rend ( ) const
inline
Returns
Reverse iterator that points before the first character of the literal

References boost::basic_string_literal< CharT, TraitsT >::begin().

template<typename CharT, typename TraitsT>
size_type boost::basic_string_literal< CharT, TraitsT >::size ( void  ) const
inline
Returns
Length of the literal

Referenced by boost::operator<<(), and boost::expressions::aux::parse_named_scope_format().

template<typename CharT, typename TraitsT>
void boost::basic_string_literal< CharT, TraitsT >::swap ( this_type that)
inline

The method swaps two literals.

References boost::multiprecision::backends::p.


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