lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
|
Provides a generic character range type as well as conversion and streaming facilities to both simplify and generalize string passing and handling in your code. More...
Classes | |
struct | char_traits |
Provides common null-terminated character range functionality for the given character type. The default implementation treats characters as arbitrary POD types. More... | |
struct | char_traits< char > |
struct | char_traits< wchar_t > |
class | basic_charbuf |
Character stream buffer class that is required to allow for allocation-free usage of STL streaming facilities. More... | |
class | basic_charstream |
Character stream class that allows for allocation-free usage of STL streaming facilities. More... | |
struct | nullterminated_incompatible |
struct | nullterminated_compatible |
Spezialize this class to make your string class compatible with the nullterminated character range class. More... | |
struct | is_nullterminated_compatible |
Checks if the given type is nullterminated-character-range-compatible. More... | |
struct | is_nullterminated_convertible |
Checks if the given type is either nullterminated-character-range-compatible or a character range. More... | |
struct | assert_nullterminated_compatible |
Asserts that the given type is nullterminated-character-range-compatible. More... | |
class | nullterminated_implicit |
Nullterminated character half-range class that may be IMPLICITLY constructed from arbitrary string classes. May be used in parameter lists, not recommended elsewhere. More... | |
class | nullterminated |
Nullterminated character half-range class that may be constructed from arbitrary string classes. More... | |
class | nullterminated_range_implicit |
Nullterminated character range class that may be constructed IMPLICITLY from arbitrary string classes. May be used in parameter lists, not recommended elsewhere. More... | |
class | nullterminated_range |
Nullterminated character range class that may be constructed from arbitrary string classes. More... | |
class | range |
Iterator range. More... | |
struct | is_range |
Checks if the given type is a range type. More... | |
struct | enable_if_range |
Redefines the given type if Range is a range, empty otherwise. More... | |
struct | enable_if_not_range |
Redefines the given type if Range is not a range, empty otherwise. More... | |
struct | enable_if_range2 |
Redefines the given type if both Range1 and Range2 are ranges, empty otherwise. More... | |
struct | enable_if_not_range2 |
Redefines the given type if either Range1 or Range2 is not a range, empty otherwise. More... | |
struct | range_char_type< Char * > |
struct | range_char_type2< Char *, Chars2 > |
struct | range_char_type2< Chars1, Char * > |
struct | range_char_type2< Char1 *, Char2 * > |
struct | string_traits |
Provides common string functionality for the given string type. More... | |
struct | nullterminated_compatible< std::basic_string< Char, StringTraits, StringAllocator >, Char, NullterminatedTraits > |
Typedefs | |
typedef basic_charstream< char > | charstream |
Character stream class. | |
typedef basic_charstream< wchar_t > | wcharstream |
Wide-character stream class. | |
Functions | |
template<class String , class Range > | |
String | utf8_to_utf16 (const Range &wide) |
Converts the given string from UTF-8 to UTF-16. | |
template<class String > | |
LEAN_INLINE String | utf_to_utf16 (const utf8_ntri &wide) |
Converts the given string from UTF-8 to UTF-16. | |
template<class String , class Range > | |
String | utf16_to_utf8 (const Range &wide) |
Converts the given string from UTF-16 to UTF-8. | |
template<class String > | |
LEAN_INLINE String | utf_to_utf8 (const utf16_ntri &wide) |
Converts the given string from UTF-16 to UTF-8. | |
template<class String , class Range > | |
String | utf8_to_utf32 (const Range &wide) |
Converts the given string from UTF-8 to UTF-32. | |
template<class String > | |
LEAN_INLINE String | utf_to_utf32 (const utf8_ntri &wide) |
Converts the given string from UTF-8 to UTF-32. | |
template<class String , class Range > | |
String | utf32_to_utf8 (const Range &wide) |
Converts the given string from UTF-32 to UTF-8. | |
template<class String , class Range > | |
LEAN_INLINE String | utf_to_utf (const Range &str) |
Converts the given string from UTF to UTF. | |
template<class String > | |
String | char_to_wchar (const char_ntri &narrow, const std::locale &locale=std::locale()) |
Widens the given string using either the given locale or the current global locale. | |
template<class String > | |
LEAN_INLINE String | to_wchar (const char_ntri &narrow, const std::locale &locale=std::locale()) |
Widens the given string using either the given locale or the current global locale. | |
template<class String > | |
String | wchar_to_char (const wchar_ntri &wide, const std::locale &locale=std::locale(), char invalid= '?') |
Narrows the given string using either the given locale or the current global locale. | |
template<class String > | |
LEAN_INLINE String | to_char (const wchar_ntri &wide, const std::locale &locale=std::locale(), char invalid= '?') |
Narrows the given string using either the given locale or the current global locale. | |
template<class String > | |
String | char_to_utf16 (const char_ntri &narrow, const std::locale &locale=std::locale()) |
Widens the given string to UTF-16 using either the given locale or the current global locale. | |
template<class String > | |
LEAN_INLINE String | to_utf16 (const char_ntri &narrow, const std::locale &locale=std::locale()) |
Widens the given string to UTF-16 using either the given locale or the current global locale. | |
template<class String > | |
String | utf16_to_char (const utf16_ntri &wide, const std::locale &locale=std::locale(), char invalid= '?') |
Narrows the given to UTF-16 string using either the given locale or the current global locale. | |
template<class String > | |
LEAN_INLINE String | utf_to_char (const utf16_ntri &wide, const std::locale &locale=std::locale(), char invalid= '?') |
Narrows the given to UTF-16 string using either the given locale or the current global locale. | |
template<class String > | |
String | char_to_utf32 (const char_ntri &narrow, const std::locale &locale=std::locale()) |
Widens the given string to UTF-32 using either the given locale or the current global locale. | |
template<class String > | |
LEAN_INLINE utf32_string | to_utf32 (const char_ntri &narrow, const std::locale &locale=std::locale()) |
Widens the given string to UTF-32 using either the given locale or the current global locale. | |
template<class String > | |
String | utf32_to_char (const utf32_ntri &wide, const std::locale &locale=std::locale(), char invalid= '?') |
Narrows the given UTF-32 string using either the given locale or the current global locale. | |
template<class String > | |
LEAN_INLINE String | to_utf8 (const char_ntri &narrow, const std::locale &locale=std::locale()) |
Widens the given string to UTF-8 using either the given locale or the current global locale. | |
template<class Char , class Traits > | |
LEAN_INLINE nullterminated < Char, Traits > | make_nt (const nullterminated_implicit< Char, Traits > &range) |
Makes an explicit nullterminated (half) range from the given implicit range. | |
template<class Char > | |
LEAN_INLINE nullterminated< Char > | make_nt (const Char *range) |
Makes an explicit nullterminated (half) range from the given implicit range. | |
template<class Char , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_compatible < Compatible, Char, typename nullterminated< Char > ::traits_type >::value, nullterminated< Char > >::type | make_nt (const Compatible &compatible) |
Makes an explicit nullterminated (half) range from the given implicit range. | |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator== (const nullterminated_implicit< Char, Traits > &left, const nullterminated_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator== (const nullterminated_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator== (const Compatible &left, const nullterminated_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator!= (const nullterminated_implicit< Char, Traits > &left, const nullterminated_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator!= (const nullterminated_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator!= (const Compatible &left, const nullterminated_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator< (const nullterminated_implicit< Char, Traits > &left, const nullterminated_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator< (const nullterminated_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator< (const Compatible &left, const nullterminated_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator> (const nullterminated_implicit< Char, Traits > &left, const nullterminated_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator> (const nullterminated_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator> (const Compatible &left, const nullterminated_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator<= (const nullterminated_implicit< Char, Traits > &left, const nullterminated_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator<= (const nullterminated_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator<= (const Compatible &left, const nullterminated_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator>= (const nullterminated_implicit< Char, Traits > &left, const nullterminated_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator>= (const nullterminated_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator>= (const Compatible &left, const nullterminated_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE void | swap (nullterminated_implicit< Char, Traits > &left, nullterminated_implicit< Char, Traits > &right) |
Swaps the elements of two nullterminated character ranges. | |
template<class Char , class Traits > | |
LEAN_INLINE nullterminated_range< Char, Traits > | make_ntr (const nullterminated_range_implicit< Char, Traits > &range) |
Makes an explicit nullterminated range from the given implicit range. | |
template<class Char > | |
LEAN_INLINE nullterminated_range< Char > | make_ntr (const Char *range) |
Makes an explicit nullterminated range from the given implicit range. | |
template<class Char , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_compatible < Compatible, Char, typename nullterminated_range< Char > ::traits_type >::value, nullterminated_range< Char > >::type | make_ntr (const Compatible &compatible) |
Makes an explicit nullterminated range from the given implicit range. | |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator== (const nullterminated_range_implicit< Char, Traits > &left, const nullterminated_range_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator== (const nullterminated_range_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator== (const Compatible &left, const nullterminated_range_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator!= (const nullterminated_range_implicit< Char, Traits > &left, const nullterminated_range_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator!= (const nullterminated_range_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator!= (const Compatible &left, const nullterminated_range_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator< (const nullterminated_range_implicit< Char, Traits > &left, const nullterminated_range_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator< (const nullterminated_range_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator< (const Compatible &left, const nullterminated_range_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator> (const nullterminated_range_implicit< Char, Traits > &left, const nullterminated_range_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator> (const nullterminated_range_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator> (const Compatible &left, const nullterminated_range_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator<= (const nullterminated_range_implicit< Char, Traits > &left, const nullterminated_range_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator<= (const nullterminated_range_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator<= (const Compatible &left, const nullterminated_range_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE bool | operator>= (const nullterminated_range_implicit< Char, Traits > &left, const nullterminated_range_implicit< Char, Traits > &right) |
Comparison operator. | |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator>= (const nullterminated_range_implicit< Char, Traits > &left, const Compatible &right) |
template<class Char , class Traits , class Compatible > | |
LEAN_INLINE enable_if < is_nullterminated_convertible < Compatible, Char, Traits > ::value, bool >::type | operator>= (const Compatible &left, const nullterminated_range_implicit< Char, Traits > &right) |
template<class Char , class Traits > | |
LEAN_INLINE void | swap (nullterminated_range_implicit< Char, Traits > &left, nullterminated_range_implicit< Char, Traits > &right) |
Swaps the elements of two null-terminated character ranges. | |
template<class Iterator > | |
LEAN_INLINE range< Iterator > | make_range (Iterator begin, Iterator end) |
Makes a range from the given pair of iterators. | |
template<class Char > | |
LEAN_INLINE range< Char * > | make_char_range (Char *nts) |
Makes a range from the given null-terminated charcter string. | |
template<class Range > | |
LEAN_INLINE Range & | make_char_range (Range &range) |
Returns an unmodified reference to the given range. (generic convenience overload) | |
template<class Class , class Range > | |
LEAN_INLINE Class | from_range (const Range &range) |
Constructs an object of the given type from the given range. | |
template<class String , class Range > | |
LEAN_INLINE String | string_from_range (const Range &range) |
Constructs an object of the given type from the given range. | |
template<class Type , size_t Size> | |
LEAN_INLINE size_t | ntarraylen (Type(&)[Size]) |
Returns the length of the given null-terminated array. | |
size_t | strmcpy (char *dest, const char *source, size_t maxChars) |
Copies at maximum the given number of characters from source to dest string, always incorporating a terminating null. | |
size_t | wcsmcpy (wchar_t *dest, const wchar_t *source, size_t maxChars) |
Copies at maximum the given number of characters from source to dest string, always incorporating a terminating null. |
Provides a generic character range type as well as conversion and streaming facilities to both simplify and generalize string passing and handling in your code.
LEAN_INLINE std::string lean::strings::utf_to_char | ( | const utf16_ntri & | wide, |
const std::locale & | locale = std::locale() , |
||
char | invalid = '?' |
||
) |
Narrows the given to UTF-16 string using either the given locale or the current global locale.
Narrows the given UTF-8 string using either the given locale or the current global locale.
Narrows the given UTF-32 string using either the given locale or the current global locale.
LEAN_INLINE utf16_ntri lean::strings::utf_to_utf16 | ( | const utf8_ntri & | wide | ) |
Converts the given string from UTF-8 to UTF-16.
Converts the given string from UTF-16 to UTF-16.
Converts the given string from UTF-32 to UTF-16.
LEAN_INLINE utf32_ntri lean::strings::utf_to_utf32 | ( | const utf8_ntri & | wide | ) |
Converts the given string from UTF-8 to UTF-32.
Converts the given string from UTF-32 to UTF-32.
Converts the given string from UTF-16 to UTF-32.
LEAN_INLINE utf8_ntri lean::strings::utf_to_utf8 | ( | const utf16_ntri & | wide | ) |
Converts the given string from UTF-16 to UTF-8.
Converts the given string from UTF-8 to UTF-8.
Converts the given string from UTF-32 to UTF-8.