u5e
UnicodeTextC++Library
Public Member Functions | Public Attributes | List of all members
u5e::basic_encodedstring< Encoding, NativeString > Class Template Reference

basic encoding support over string-like objects. More...

#include <u5e/basic_encodedstring.hpp>

Public Types

typedef u5e::codepoint_traits traits_type
 
typedef u5e::codepoint value_type
 
typedef u5e::codepoint_traits::pos_type size_type
 
typedef u5e::codepoint_traits::off_type difference_type
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef NativeString::pointer pointer
 
typedef NativeString::const_pointer const_pointer
 
typedef Encoding::template iterator< NativeString > iterator
 
typedef Encoding::template const_iterator< NativeString > const_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 basic_encodedstring ()=default
 
 basic_encodedstring (const NativeString &s)
 
basic_encodedstringoperator= (const basic_encodedstring &other)
 
NativeString::iterator native_begin ()
 
NativeString::iterator native_end ()
 
NativeString::const_iterator native_cbegin ()
 
NativeString::const_iterator native_cend ()
 
iterator codepoint_begin ()
 
iterator codepoint_end ()
 
const_iterator codepoint_cbegin ()
 
const_iterator codepoint_cend ()
 
basic_grapheme_iterator< basic_encodedstringgrapheme_begin ()
 
basic_grapheme_iterator< basic_encodedstringgrapheme_end ()
 
template<typename StorageType >
basic_encodedstringappend (typename basic_encodedstring< Encoding, StorageType >::const_iterator first, typename basic_encodedstring< Encoding, StorageType >::const_iterator last)
 
basic_encodedstringappend (const_iterator first, const_iterator last)
 
template<typename StorageType >
basic_encodedstringappend (basic_grapheme_iterator< basic_encodedstring< Encoding, StorageType >> &first, basic_grapheme_iterator< basic_encodedstring< Encoding, StorageType >> &last)
 
basic_encodedstringappend (basic_grapheme_iterator< basic_encodedstring > &first, basic_grapheme_iterator< basic_encodedstring > &last)
 
template<typename StorageType >
basic_encodedstringappend_from_utf32ne (typename basic_encodedstring< utf32ne, StorageType >::const_iterator first, typename basic_encodedstring< utf32ne, StorageType >::const_iterator last)
 

Public Attributes

NativeString native_string
 Raw buffer as specified by the native type. More...
 

Detailed Description

template<typename Encoding, typename NativeString>
class u5e::basic_encodedstring< Encoding, NativeString >

basic encoding support over string-like objects.

u5e::basic_encodedstring implements encoding support on top of a string-like object, it is implemented by simply wrapping the native string type in order to provide a customized iterator that offers codepoint-by-codepoint access instead of iterating over the native type.

Template Parameters
EncodingText is always represented in a specific encoding, there is no such thing as a "natural", or "native" representation of text, for that reason, the encoding is a part of the type.
NativeStringIn order to re-use the string support, this will always be implemented as a wrapper around an native string-like type. The idea is that the C++ string libraries operate on unencoded memory, while the u5e types offer a layer on top of that for the purposes of implementing unicode in a type-safe way. Note that this applies to any 'string-like' object, such as string or string_view.

Definition at line 37 of file basic_encodedstring.hpp.

Member Typedef Documentation

template<typename Encoding , typename NativeString >
typedef Encoding::template const_iterator<NativeString> u5e::basic_encodedstring< Encoding, NativeString >::const_iterator

The Encoding template argument must provide iterator and const_iterator member types. Those should iterate over codepoints, regardless of the encoding and the native type.

The iterator and const_iterator member types must be themselves templates that take the NativeString type as a template argument.

Definition at line 68 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef NativeString::const_pointer u5e::basic_encodedstring< Encoding, NativeString >::const_pointer

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 52 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef const value_type& u5e::basic_encodedstring< Encoding, NativeString >::const_reference

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 50 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef std::reverse_iterator<const_iterator> u5e::basic_encodedstring< Encoding, NativeString >::const_reverse_iterator

Delegated to std::reverse_iterator

Definition at line 76 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef u5e::codepoint_traits::off_type u5e::basic_encodedstring< Encoding, NativeString >::difference_type

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 48 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef Encoding::template iterator<NativeString> u5e::basic_encodedstring< Encoding, NativeString >::iterator

The Encoding template argument must provide iterator and const_iterator member types. Those should iterate over codepoints, regardless of the encoding and the native type.

The iterator and const_iterator member types must be themselves templates that take the NativeString type as a template argument.

Definition at line 66 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef NativeString::pointer u5e::basic_encodedstring< Encoding, NativeString >::pointer

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 51 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef value_type& u5e::basic_encodedstring< Encoding, NativeString >::reference

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 49 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef std::reverse_iterator<iterator> u5e::basic_encodedstring< Encoding, NativeString >::reverse_iterator

Delegated to std::reverse_iterator

Definition at line 75 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef u5e::codepoint_traits::pos_type u5e::basic_encodedstring< Encoding, NativeString >::size_type

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 47 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef u5e::codepoint_traits u5e::basic_encodedstring< Encoding, NativeString >::traits_type

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 45 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
typedef u5e::codepoint u5e::basic_encodedstring< Encoding, NativeString >::value_type

Offer an interface such that the size of the thing you're iterating over is a codepoint, regardless of the native type.

Definition at line 46 of file basic_encodedstring.hpp.

Constructor & Destructor Documentation

template<typename Encoding , typename NativeString >
u5e::basic_encodedstring< Encoding, NativeString >::basic_encodedstring ( )
default

Default constructor, delegated to the native type.

template<typename Encoding , typename NativeString >
u5e::basic_encodedstring< Encoding, NativeString >::basic_encodedstring ( const NativeString &  s)
inline

Implicit conversion from the native type.

Definition at line 99 of file basic_encodedstring.hpp.

Member Function Documentation

template<typename Encoding , typename NativeString >
template<typename StorageType >
basic_encodedstring& u5e::basic_encodedstring< Encoding, NativeString >::append ( typename basic_encodedstring< Encoding, StorageType >::const_iterator  first,
typename basic_encodedstring< Encoding, StorageType >::const_iterator  last 
)
inline

Append from input iterators.

Note that this is only possible from iterators of the same encoding. This will not perform any conversion.

Definition at line 174 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
basic_encodedstring& u5e::basic_encodedstring< Encoding, NativeString >::append ( const_iterator  first,
const_iterator  last 
)
inline

Append from input iterators.

Note that this is only possible from iterators of the same encoding. This will not perform any conversion.

Definition at line 186 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
template<typename StorageType >
basic_encodedstring& u5e::basic_encodedstring< Encoding, NativeString >::append ( basic_grapheme_iterator< basic_encodedstring< Encoding, StorageType >> &  first,
basic_grapheme_iterator< basic_encodedstring< Encoding, StorageType >> &  last 
)
inline

Append from input iterators.

Note that this is only possible from iterators of the same encoding. This will not perform any conversion.

Definition at line 193 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
basic_encodedstring& u5e::basic_encodedstring< Encoding, NativeString >::append ( basic_grapheme_iterator< basic_encodedstring< Encoding, NativeString > > &  first,
basic_grapheme_iterator< basic_encodedstring< Encoding, NativeString > > &  last 
)
inline

Append from input iterators.

Note that this is only possible from iterators of the same encoding. This will not perform any conversion.

Definition at line 202 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
template<typename StorageType >
basic_encodedstring& u5e::basic_encodedstring< Encoding, NativeString >::append_from_utf32ne ( typename basic_encodedstring< utf32ne, StorageType >::const_iterator  first,
typename basic_encodedstring< utf32ne, StorageType >::const_iterator  last 
)
inline

Append from input iterators.

Note that this is only possible from iterators of the same encoding. This will not perform any conversion.

Definition at line 209 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
iterator u5e::basic_encodedstring< Encoding, NativeString >::codepoint_begin ( )
inline

Get begin and end codepoint iterators.

Definition at line 132 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
const_iterator u5e::basic_encodedstring< Encoding, NativeString >::codepoint_cbegin ( )
inline

Get begin and end codepoint iterators.

Definition at line 138 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
const_iterator u5e::basic_encodedstring< Encoding, NativeString >::codepoint_cend ( )
inline

Get begin and end codepoint iterators.

Definition at line 141 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
iterator u5e::basic_encodedstring< Encoding, NativeString >::codepoint_end ( )
inline

Get begin and end codepoint iterators.

Definition at line 135 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
basic_grapheme_iterator<basic_encodedstring> u5e::basic_encodedstring< Encoding, NativeString >::grapheme_begin ( )
inline

Get begin and end grapheme iterators. Graphemes are always built from the const iterators, since graphemes are always immutable.

Definition at line 152 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
basic_grapheme_iterator<basic_encodedstring> u5e::basic_encodedstring< Encoding, NativeString >::grapheme_end ( )
inline

Get begin and end grapheme iterators. Graphemes are always built from the const iterators, since graphemes are always immutable.

Definition at line 157 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
NativeString::iterator u5e::basic_encodedstring< Encoding, NativeString >::native_begin ( )
inline

Get begin and end native iterators.

Definition at line 114 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
NativeString::const_iterator u5e::basic_encodedstring< Encoding, NativeString >::native_cbegin ( )
inline

Get begin and end native iterators.

Definition at line 120 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
NativeString::const_iterator u5e::basic_encodedstring< Encoding, NativeString >::native_cend ( )
inline

Get begin and end native iterators.

Definition at line 123 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
NativeString::iterator u5e::basic_encodedstring< Encoding, NativeString >::native_end ( )
inline

Get begin and end native iterators.

Definition at line 117 of file basic_encodedstring.hpp.

template<typename Encoding , typename NativeString >
basic_encodedstring& u5e::basic_encodedstring< Encoding, NativeString >::operator= ( const basic_encodedstring< Encoding, NativeString > &  other)
inline

Assignment operator, assigns the native type.

Definition at line 106 of file basic_encodedstring.hpp.

Member Data Documentation

template<typename Encoding , typename NativeString >
NativeString u5e::basic_encodedstring< Encoding, NativeString >::native_string

Raw buffer as specified by the native type.

This means that this class is exactly as expensive as whichever native type is being used, it also means this class delegates all memory management to that native type.

This member is public because you should be able to completely manage the native object if you need to.

Definition at line 89 of file basic_encodedstring.hpp.


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