![]() |
TSDuck v3.46-4965
MPEG Transport Stream Toolkit
|
#include <tsUString.h>


Classes | |
| class | RegisterChronoUnit |
Public Types | |
| enum | HexaFlags { HEXA = 0x0001 , ASCII = 0x0002 , OFFSET = 0x0004 , WIDE_OFFSET = 0x0008 , SINGLE_LINE = 0x0010 , BPL = 0x0020 , C_STYLE = 0x0040 , BINARY = 0x0080 , BIN_NIBBLE = 0x0100 , COMPACT = 0x0200 } |
| using | SuperClass = std::u16string |
Public Member Functions | |
| UString () noexcept(noexcept(allocator_type())) | |
| UString (const ::WCHAR *s, const allocator_type &alloc=allocator_type()) | |
| UString (const ::WCHAR *s, size_type count, const allocator_type &alloc=allocator_type()) | |
| UString (const allocator_type &alloc) noexcept | |
| UString (const char *utf8) | |
| UString (const char *utf8, size_type count) | |
| UString (const fs::path &p) | |
| template<typename CHARTYPE, std::size_t SIZE> | |
| UString (const std::array< CHARTYPE, SIZE > &arr, const allocator_type &alloc=allocator_type()) | |
| template<typename CHARTYPE, std::size_t SIZE, typename INT> requires std::integral<INT> | |
| UString (const std::array< CHARTYPE, SIZE > &arr, INT count, const allocator_type &alloc=allocator_type()) | |
| UString (const std::string &utf8) | |
| template<typename CHARTYPE> | |
| UString (const std::vector< CHARTYPE > &vec, const allocator_type &alloc=allocator_type()) | |
| template<typename CHARTYPE, typename INT> requires std::integral<INT> | |
| UString (const std::vector< CHARTYPE > &vec, INT count, const allocator_type &alloc=allocator_type()) | |
| UString (const SuperClass &other) | |
| UString (const SuperClass &other, size_type pos, size_type count, const allocator_type &alloc=allocator_type()) | |
| UString (const UChar *s, const allocator_type &alloc=allocator_type()) | |
| UString (const UChar *s, size_type count, const allocator_type &alloc=allocator_type()) | |
| template<class InputIt> | |
| UString (InputIt first, InputIt last, const allocator_type &alloc=allocator_type()) | |
| UString (size_type count, UChar ch, const allocator_type &alloc=allocator_type()) | |
| UString (std::initializer_list< UChar > init, const allocator_type &alloc=allocator_type()) | |
| UString (SuperClass &&other) noexcept | |
| void | appendDump (const ByteBlock &bb, uint32_t flags=HEXA, size_type indent=0, size_type line_width=DEFAULT_HEXA_LINE_WIDTH, size_type init_offset=0, size_type inner_indent=0) |
| void | appendDump (const void *data, size_type size, uint32_t flags=HEXA, size_type indent=0, size_type line_width=DEFAULT_HEXA_LINE_WIDTH, size_type init_offset=0, size_type inner_indent=0) |
| void | appendUTF8 (ByteBlock &utf8) const |
| void | appendUTF8 (std::string &utf8) const |
| template<typename CHARTYPE, std::size_t SIZE> | |
| UString & | assign (const std::array< CHARTYPE, SIZE > &arr) |
| template<typename CHARTYPE, std::size_t SIZE, typename INT> requires std::integral<INT> | |
| UString & | assign (const std::array< CHARTYPE, SIZE > &arr, INT count) |
| template<typename CHARTYPE> | |
| UString & | assign (const std::vector< CHARTYPE > &vec) |
| template<typename CHARTYPE, typename INT> requires std::integral<INT> | |
| UString & | assign (const std::vector< CHARTYPE > &vec, INT count) |
| UString & | assignFromUTF8 (const char *utf8) |
| UString & | assignFromUTF8 (const char *utf8, size_type count) |
| UString & | assignFromUTF8 (const std::string &utf8) |
| UString & | assignFromWChar (const std::wstring &wstr) |
| UString & | assignFromWChar (const wchar_t *wstr) |
| UString & | assignFromWChar (const wchar_t *wstr, size_type count) |
| void | combineDiacritical () |
| size_t | commonPrefixSize (const UString &str, CaseSensitivity cs=CASE_SENSITIVE) const |
| size_t | commonSuffixSize (const UString &str, CaseSensitivity cs=CASE_SENSITIVE) const |
| int | constantTimeCompare (const UString &secret) const |
| bool | contains (const UString &substring, CaseSensitivity cs=CASE_SENSITIVE) const |
| bool | contains (UChar c) const |
| void | convertFromHTML () |
| void | convertFromJSON () |
| void | convertToHTML (const UString &convert=UString()) |
| void | convertToJSON () |
| void | convertToLower () |
| void | convertToUpper () |
| void | decomposeDiacritical () |
| size_type | displayPosition (size_type count, size_type from=0, StringDirection direction=LEFT_TO_RIGHT) const |
| bool | ends_with (const std::u16string_view &suffix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type end=NPOS) const |
| bool | ends_with (const UChar *suffix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type end=NPOS) const |
| bool | ends_with (const UString &suffix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type end=NPOS) const |
| bool | ends_with (UChar suffix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type end=NPOS) const |
| template<class CONTAINER> | |
| CONTAINER::const_iterator | findSimilar (const CONTAINER &container, size_t this_pos=0) const |
| template<class... Args> | |
| void | format (const UChar *fmt, Args &&... args) |
| template<class... Args> | |
| void | format (const UString &fmt, Args &&... args) |
| UString | fromHTML () const |
| UString | fromJSON () const |
| template<class CONTAINER> | |
| void | fromQuotedLine (CONTAINER &container, const UString "e_characters=DEFAULT_QUOTE_CHARACTERS, const UString &special_characters=DEFAULT_SPECIAL_CHARACTERS) const |
| bool | getLine (std::istream &strm) |
| bool | hexaDecode (ByteBlock &result, bool c_style=false) const |
| bool | hexaDecodeAppend (ByteBlock &result, bool c_style=false) const |
| void | indent (size_t size) |
| template<class CONTAINER> | |
| bool | isContainedSimilarIn (const CONTAINER &container, size_t this_pos=0) const |
| bool | isInteger (const UString &thousand_separators=UString()) const |
| template<class CONTAINER> | |
| UString | join (const CONTAINER &container, bool remove_empty=false) const |
| template<class ITERATOR> | |
| UString | join (ITERATOR begin, ITERATOR end, bool remove_empty=false) const |
| void | justify (const UString &right, size_type width, UChar pad=SPACE, size_t spaces_around_pad=0) |
| void | justifyCentered (size_type width, UChar pad=SPACE, bool truncate=false, size_t spaces_around_pad=0) |
| void | justifyLeft (size_type width, UChar pad=SPACE, bool truncate=false, size_t spaces_before_pad=0) |
| void | justifyRight (size_type width, UChar pad=SPACE, bool truncate=false, size_t spaces_after_pad=0) |
| UChar * | last () |
| const UChar * | last () const |
| operator fs::path () const | |
| bool | operator== (const fs::path &other) const |
| void | quoted (UChar quote_character=u'\'', const UString &special_characters=DEFAULT_SPECIAL_CHARACTERS, bool force_quote=false, UChar non_print=u'?') |
| template<class CONTAINER> | |
| void | quotedLine (const CONTAINER &container, UChar quote_character=u'\'', const UString &special_characters=DEFAULT_SPECIAL_CHARACTERS) |
| void | remove (const UString &substr) |
| void | remove (UChar c) |
| void | removePrefix (const UString &prefix, CaseSensitivity cs=CASE_SENSITIVE) |
| void | removeSuffix (const UString &suffix, CaseSensitivity cs=CASE_SENSITIVE) |
| void | reverse () |
| bool | save (const fs::path &file_name, bool append=false, bool enforce_last_line_feed=false) const |
| template<class... Args> | |
| bool | scan (const UChar *fmt, Args &&... args) const |
| template<class... Args> | |
| bool | scan (const UString &fmt, Args &&... args) const |
| template<class... Args> | |
| bool | scan (size_t &extracted_count, size_type &end_index, const UChar *fmt, Args &&... args) const |
| template<class... Args> | |
| bool | scan (size_t &extracted_count, size_type &end_index, const UString &fmt, Args &&... args) const |
| bool | similar (const UChar *other, size_t this_pos=0, size_t other_pos=0) const |
| bool | similar (const UString &other, size_t this_pos=0, size_t other_pos=0) const |
| bool | similar (const void *addr, size_type size, size_t this_pos=0, size_t other_pos=0) const |
| bool | similarAfterLast (const UChar *other, UChar separator) const |
| bool | similarAfterLast (const UString &other, UChar separator) const |
| bool | similarAfterLast (const void *addr, size_type size, UChar separator) const |
| template<class CONTAINER> | |
| void | split (CONTAINER &container, UChar separator=COMMA, bool trim_spaces=true, bool remove_empty=false) const |
| template<class CONTAINER> | |
| void | splitAppend (CONTAINER &container, UChar separator=COMMA, bool trim_spaces=true, bool remove_empty=false) const |
| template<class CONTAINER> | |
| void | splitBlocks (CONTAINER &container, UChar starts_with=u'[', UChar ends_with=u']', bool trim_spaces=true) const |
| template<class CONTAINER> | |
| void | splitBlocksAppend (CONTAINER &container, UChar starts_with=u'[', UChar ends_with=u']', bool trim_spaces=true) const |
| template<class CONTAINER> | |
| void | splitLines (CONTAINER &container, size_type max_width, const UString &other_separators=UString(), const UString &next_margin=UString(), bool force_split=false) const |
| template<class CONTAINER> | |
| void | splitLinesAppend (CONTAINER &container, size_type max_width, const UString &other_separators=UString(), const UString &next_margin=UString(), bool force_split=false) const |
| template<class CONTAINER> | |
| void | splitShellStyle (CONTAINER &container) const |
| template<class CONTAINER> | |
| void | splitShellStyleAppend (CONTAINER &container) const |
| bool | starts_with (const std::u16string_view &prefix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type start=0) const |
| bool | starts_with (const UChar *prefix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type start=0) const |
| bool | starts_with (const UString &prefix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type start=0) const |
| bool | starts_with (UChar prefix, CaseSensitivity cs=CASE_SENSITIVE, bool skip_spaces=false, size_type start=0) const |
| void | substitute (const UString &value, const UString &replacement) |
| void | substitute (UChar value, UChar replacement) |
| int | superCompare (const UChar *other, uint32_t flags=SCOMP_DEFAULT, size_t this_pos=0, size_t other_pos=0) const |
| int | superCompare (const UString &other, uint32_t flags=SCOMP_DEFAULT, size_t this_pos=0, size_t other_pos=0) const |
| bool | toBool (bool &value) const |
| template<class Rep, class Period> | |
| bool | toChrono (cn::duration< Rep, Period > &value, const UString &thousand_separators=UString(), const cn::duration< Rep, Period > &min_value=cn::duration< Rep, Period >::min(), const cn::duration< Rep, Period > &max_value=cn::duration< Rep, Period >::max()) const |
| UString | toCombinedDiacritical () const |
| UString | toDecomposedDiacritical () const |
| template<typename FLT> requires std::floating_point<FLT> | |
| bool | toFloat (FLT &value, FLT min_value=std::numeric_limits< FLT >::lowest(), FLT max_value=std::numeric_limits< FLT >::max()) const |
| UString | toHTML (const UString &convert=UString()) const |
| UString | toIndented (size_t size) const |
| template<typename INT> requires std::integral<INT> | |
| bool | toInteger (INT &value, const UString &thousand_separators=UString(), size_type decimals=0, const UString &decimal_separators=u".", INT min_value=std::numeric_limits< INT >::min(), INT max_value=std::numeric_limits< INT >::max()) const |
| template<class CONTAINER> requires std::integral<typename CONTAINER::value_type> | |
| bool | toIntegers (CONTAINER &container, const UString &thousand_separators=UString(), const UString &list_separators=UString(u",; "), size_type decimals=0, const UString &decimal_separators=UString(u"."), typename CONTAINER::value_type min_value=std::numeric_limits< typename CONTAINER::value_type >::min(), typename CONTAINER::value_type max_value=std::numeric_limits< typename CONTAINER::value_type >::max()) const |
| UString | toJSON () const |
| UString | toJustified (const UString &right, size_type width, UChar pad=SPACE, size_t spaces_around_pad=0) const |
| UString | toJustifiedCentered (size_type width, UChar pad=SPACE, bool truncate=false, size_t spaces_around_pad=0) const |
| UString | toJustifiedLeft (size_type width, UChar pad=SPACE, bool truncate=false, size_t spaces_before_pad=0) const |
| UString | toJustifiedRight (size_type width, UChar pad=SPACE, bool truncate=false, size_t spaces_after_pad=0) const |
| UString | toLower () const |
| UString | toQuoted (UChar quote_character=u'\'', const UString &special_characters=DEFAULT_SPECIAL_CHARACTERS, bool force_quote=false, UChar non_print=u'?') const |
| UString | toRemoved (const UString &substr) const |
| UString | toRemoved (UChar c) const |
| UString | toRemovedPrefix (const UString &prefix, CaseSensitivity cs=CASE_SENSITIVE) const |
| UString | toRemovedSuffix (const UString &suffix, CaseSensitivity cs=CASE_SENSITIVE) const |
| UString | toReversed () const |
| UString | toSplitLines (size_type max_width, const UString &other_separators=UString(), const UString &next_margin=UString(), bool force_split=false, const UString &line_separator=UString(1, LINE_FEED)) const |
| UString | toSubstituted (const UString &value, const UString &replacement) const |
| UString | toSubstituted (UChar value, UChar replacement) const |
| UString | toTrimmed (bool leading=true, bool trailing=true, bool sequences=false) const |
| bool | toTristate (Tristate &value) const |
| UString | toTruncatedWidth (size_type max_width, StringDirection direction=LEFT_TO_RIGHT) const |
| UString | toUnquoted (const UString "e_characters=DEFAULT_QUOTE_CHARACTERS) const |
| UString | toUpper () const |
| std::string | toUTF8 () const |
| void | toUTF8 (ByteBlock &utf8) const |
| void | toUTF8 (std::string &utf8) const |
| void | trim (bool leading=true, bool trailing=true, bool sequences=false) |
| template<typename INT> requires std::integral<INT> | |
| void | trimLength (INT length, bool trim_trailing_spaces=true) |
| void | truncateWidth (size_type max_width, StringDirection direction=LEFT_TO_RIGHT) |
| void | unquoted (const UString "e_characters=DEFAULT_QUOTE_CHARACTERS) |
| ::WCHAR * | wc_str () |
| const ::WCHAR * | wc_str () const |
| size_type | width () const |
Static Public Member Functions | |
| static UString | AfterBytes (const std::streampos &position) |
| template<class CONTAINER> | |
| static CONTAINER & | Append (CONTAINER &container, int argc, char *const argv[]) |
| template<class CONTAINER> | |
| static CONTAINER & | Append (CONTAINER &container, int argc, const char *const argv[]) |
| template<class CONTAINER> | |
| static CONTAINER & | Assign (CONTAINER &container, int argc, char *const argv[]) |
| template<class CONTAINER> | |
| static CONTAINER & | Assign (CONTAINER &container, int argc, const char *const argv[]) |
| static UString | BoolNamesList () |
| template<class Rep, class Period> | |
| static UString | Chrono (const cn::duration< Rep, Period > &value, bool short_format=false, const UString &separator=DEFAULT_THOUSANDS_SEPARATOR, bool force_sign=false) |
| template<class DURATION> requires std::integral<typename DURATION::rep> | |
| static UString | ChronoUnit (bool short_format=false, bool plural=false) |
| static UString | ChronoUnit (std::intmax_t num, std::intmax_t den, bool short_format=false, bool plural=false) |
| static void | ConvertUTF16ToUTF8 (const UChar *&in_start, const UChar *in_end, char *&out_start, char *out_end) |
| static void | ConvertUTF8ToUTF16 (const char *&in_start, const char *in_end, UChar *&out_start, UChar *out_end) |
| template<class CONTAINER> requires ts::int_enum<typename CONTAINER::value_type> | |
| static UString | Decimal (const CONTAINER &values, const UString &separator=UString(u", "), bool force_sign=false) |
| template<typename INT> requires ts::int_enum<INT> | |
| static UString | Decimal (INT value, size_type min_width=0, bool right_justified=true, const UString &separator=DEFAULT_THOUSANDS_SEPARATOR, bool force_sign=false, UChar pad=SPACE) |
| static UString | Dump (const ByteBlock &bb, uint32_t flags=HEXA, size_type indent=0, size_type line_width=DEFAULT_HEXA_LINE_WIDTH, size_type init_offset=0, size_type inner_indent=0) |
| static UString | Dump (const void *data, size_type size, uint32_t flags=HEXA, size_type indent=0, size_type line_width=DEFAULT_HEXA_LINE_WIDTH, size_type init_offset=0, size_type inner_indent=0) |
| template<class Rep, class Period> | |
| static UString | Duration (const cn::duration< Rep, Period > &value, bool with_days=false) |
| static const UString & | EMPTY () |
| static const std::string & | EMPTY8 () |
| static UString | Float (double value, size_type width=0, size_type precision=0, bool force_sign=false) |
| template<class... Args> | |
| static UString | Format (const UChar *fmt, Args &&... args) |
| template<class... Args> | |
| static UString | Format (const UString &fmt, Args &&... args) |
| static UString | FromUTF8 (const char *utf8) |
| static UString | FromUTF8 (const char *utf8, size_type count) |
| static UString | FromUTF8 (const std::string &utf8) |
| static UString | FromWChar (const std::wstring &wstr) |
| static UString | FromWChar (const wchar_t *wstr) |
| static UString | FromWChar (const wchar_t *wstr, size_type count) |
| template<typename INT> requires std::integral<INT> | |
| static UString | Hexa (INT value, size_type width=0, const UString &separator=UString(), bool use_prefix=true, bool use_upper=true) |
| template<typename INT> requires std::integral<INT> | |
| static UString | HexaMin (INT value, size_type min_width=0, const UString &separator=UString(), bool use_prefix=true, bool use_upper=true) |
| static UString | HumanSize (int64_t value, const UString &units=u"B", bool force_sign=false) |
| template<class CONTAINER> | |
| static UString | Join (const CONTAINER &container, const UString &separator=UString(u", "), bool remove_empty=false) |
| template<class CONTAINER> | |
| static UString | Join (const CONTAINER &container, UChar separator, bool remove_empty=false) |
| template<class ITERATOR> | |
| static UString | Join (ITERATOR begin, ITERATOR end, const UString &separator=UString(u", "), bool remove_empty=false) |
| template<class ITERATOR> | |
| static UString | Join (ITERATOR begin, ITERATOR end, UChar separator, bool remove_empty=false) |
| template<class CONTAINER> | |
| static bool | Load (CONTAINER &container, const fs::path &file_name, size_t max_lines=NPOS) |
| template<class CONTAINER> | |
| static bool | Load (CONTAINER &container, std::istream &strm, size_t max_lines=NPOS) |
| template<class CONTAINER> | |
| static bool | LoadAppend (CONTAINER &container, const fs::path &file_name, size_t max_lines=NPOS) |
| template<class CONTAINER> | |
| static bool | LoadAppend (CONTAINER &container, std::istream &strm, size_t max_lines=NPOS) |
| static UString | OnOff (bool b) |
| template<class Rep1, class Period1, class Rep2, class Period2> | |
| static UString | Percentage (const cn::duration< Rep1, Period1 > &value, const cn::duration< Rep2, Period2 > &total) |
| template<typename Int1, typename Int2> requires std::integral<Int1> && std::integral<Int2> | |
| static UString | Percentage (Int1 value, Int2 total) |
| static UString | Range (UChar first, UChar last) |
| template<class CONTAINER> | |
| static bool | Save (const CONTAINER &container, const fs::path &file_name, bool append=false) |
| template<class CONTAINER> | |
| static bool | Save (const CONTAINER &container, std::ostream &strm) |
| template<class ITERATOR> | |
| static bool | Save (ITERATOR begin, ITERATOR end, const fs::path &file_name, bool append=false) |
| template<class ITERATOR> | |
| static bool | Save (ITERATOR begin, ITERATOR end, std::ostream &strm) |
| static int | SuperCompare (const UChar *s1, const UChar *s2, uint32_t flags=SCOMP_DEFAULT, size_t s1_pos=0, size_t s2_pos=0) |
| template<class CONTAINER> | |
| static UString | ToQuotedLine (const CONTAINER &container, UChar quote_character=u'\'', const UString &special_characters=DEFAULT_SPECIAL_CHARACTERS) |
| static UString | TristateNamesList () |
| static UString | TristateOnOff (Tristate b) |
| static UString | TristateTrueFalse (Tristate b) |
| static UString | TristateYesNo (Tristate b) |
| static UString | TrueFalse (bool b) |
| static UString | YesNo (bool b) |
Static Public Attributes | |
| static constexpr size_type | DEFAULT_HEXA_LINE_WIDTH = 78 |
| static constexpr const UChar * | DEFAULT_QUOTE_CHARACTERS = u"\"'" |
| static constexpr const UChar * | DEFAULT_SPECIAL_CHARACTERS = u"\"'`;$*?&(){}[]" |
| static constexpr const UChar * | DEFAULT_THOUSANDS_SEPARATOR = u"," |
| static constexpr const UChar * | EOL |
| static constexpr size_t | MAX_FIELD_WIDTH = 4096 |
| static constexpr const char * | UTF8_BOM = "\xEF\xBB\xBF" |
| static constexpr size_type | UTF8_BOM_SIZE = 3 |
| static constexpr size_type | UTF8_CHAR_MAX_SIZE = 4 |
An implementation of UTF-16 strings.
This class is an extension of std::u16string with additional services.
The class UString implements Java-like Unicode strings. Each character uses 16 bits of storage. Formally, UString uses UTF-16 representation. This means that all characters from all modern languages can be represented as one single character. Characters from archaic languages may need two UTF-16 values, called a "surrogate pair".
The element of a UString is a UChar (or char16_t). Nul-terminated strings of UChar are implicitly converted to UString when necessary. Be aware that strings literals of char16_t are prefixed by a letter u as illustrated below:
Some interesting features in class UString are:
(*) Implicit conversions from UTF-8 C-strings (const char*) and std::string are disabled by default. You may enabled implicit conversions by defining TS_ALLOW_IMPLICIT_UTF8_CONVERSION before including tsUString.h. Thus, there is no need to explicitly invoke FromUTF8() all the time. However, leaving the implicit conversions disabled has some advantages like flagging useless and costly UTF-8 conversions, for instance when string literals are incorrectly spelled as illustrated below:
Warning for maintainers: The standard classes std::u16string and std::basic_string do not have virtual destructors. The means that if a UString is destroyed through, for instance, a std::u16string*, the destructor for the class UString will not be invoked. This is not a problem as long as the UString subclass does not have any field to destroy, which is the case for the current implementation. When modifying the UString class, make sure to avoid any issue with the absence of virtual destructor in the parent class.
| using ts::UString::SuperClass = std::u16string |
Explicit reference to superclass.
Flags for the Hexa() family of methods.
|
inlinenoexcept |
Default constructor.
|
inlineexplicitnoexcept |
Constructor using an allocator.
| [in] | alloc | Allocator. |
|
inline |
Copy constructor.
| [in] | other | Other instance to copy. |
|
inlinenoexcept |
Move constructor.
| [in,out] | other | Other instance to move. Upon return, other is left in valid, but unspecified state. |
|
inline |
Constructor using a repetition of the same character.
| [in] | count | Initial size of the string. |
| [in] | ch | Character to repeat count times. |
| [in] | alloc | Allocator. |
|
inline |
Constructor using a substring. The object receives the substring other [pos, pos + count). If count == npos or if the requested substring lasts past the end of the string, the resulting substring is [pos, size()).
| [in] | other | Other instance to partially copy. |
| [in] | pos | Initial position to copy in other. |
| [in] | count | Number of character to copy. |
| [in] | alloc | Allocator. |
|
inline |
Constructor using a Unicode string.
| [in] | s | Address of a string. Can be a null pointer if count is zero, in which case the string is empty. |
| [in] | count | Number of characters to copy from s. That number of characters is always copied, including null characters. |
| [in] | alloc | Allocator. |
|
inline |
Constructor using a null-terminated Unicode string.
| [in] | s | Address of a null-terminated string. Can be a null pointer, in which case the string is empty. |
| [in] | alloc | Allocator. |
| ts::UString::UString | ( | const std::vector< CHARTYPE > & | vec, |
| INT | count, | ||
| const allocator_type & | alloc = allocator_type() ) |
Constructor using a std::vector of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| INT | An integer type. |
| [in] | vec | The vector of characters. |
| [in] | count | Maximum number of characters to include in the string. Stop before the first nul character before max. Can be of any integer type, including a signed type. |
| [in] | alloc | Allocator. |
| ts::UString::UString | ( | const std::vector< CHARTYPE > & | vec, |
| const allocator_type & | alloc = allocator_type() ) |
Constructor using a std::vector of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| [in] | vec | The vector of characters. Nul-terminated string. |
| [in] | alloc | Allocator. |
| ts::UString::UString | ( | const std::array< CHARTYPE, SIZE > & | arr, |
| INT | count, | ||
| const allocator_type & | alloc = allocator_type() ) |
Constructor using a std::array of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| SIZE | The size of the array. |
| INT | An integer type. |
| [in] | arr | The array of characters. |
| [in] | count | Maximum number of characters to include in the string. Stop before the first nul character before max. Can be of any integer type, including a signed type. |
| [in] | alloc | Allocator. |
| ts::UString::UString | ( | const std::array< CHARTYPE, SIZE > & | arr, |
| const allocator_type & | alloc = allocator_type() ) |
Constructor using a std::array of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| SIZE | The size of the array. |
| [in] | arr | The array of characters. Nul-terminated string. |
| [in] | alloc | Allocator. |
|
inline |
Constructor from iterators. Constructs the string with the contents of the range [first, @ last).
| InputIt | An iterator type to containers of Char. If InputIt is an integral type, equivalent to String(static_cast<size_type>(first), static_cast<Char>(last), alloc). |
| [in] | first | Iterator to the first position to copy. |
| [in] | last | Iterator after the last position to copy. |
| [in] | alloc | Allocator. |
|
inline |
Constructor from an initializer list.
| [in] | init | Initializer list of Char. |
| [in] | alloc | Allocator. |
| ts::UString::UString | ( | const ::WCHAR * | s, |
| size_type | count, | ||
| const allocator_type & | alloc = allocator_type() ) |
Constructor using a Windows Unicode string (Windows-specific).
| [in] | s | Address of a string. Can be a null pointer if count is zero, in which case the string is empty. |
| [in] | count | Number of characters to copy from s. That number of characters is always copied, including null characters. |
| [in] | alloc | Allocator. |
| ts::UString::UString | ( | const ::WCHAR * | s, |
| const allocator_type & | alloc = allocator_type() ) |
Constructor using a null-terminated Windows Unicode string (Windows-specific).
| [in] | s | Address of a null-terminated string. Can be a null pointer, in which case the string is empty. |
| [in] | alloc | Allocator. |
|
inline |
Constructor from an UTF-8 string. Available only when the macro TS_ALLOW_IMPLICIT_UTF8_CONVERSION is externally defined.
| [in] | utf8 | A string in UTF-8 representation. |
|
inline |
Constructor from an UTF-8 string. Available only when the macro TS_ALLOW_IMPLICIT_UTF8_CONVERSION is externally defined.
| [in] | utf8 | Address of a nul-terminated string in UTF-8 representation. |
|
inline |
Constructor from an UTF-8 string. Available only when the macro TS_ALLOW_IMPLICIT_UTF8_CONVERSION is externally defined.
| [in] | utf8 | Address of a string in UTF-8 representation. |
| [in] | count | Size in bytes of the UTF-8 string (not necessarily a number of characters). |
|
inline |
Constructor from a std::filesystem::path.
| [in] | p | A standard path instance. |
|
static |
A static empty string. Can be used when a reference to a static empty string is required.
|
static |
A static empty 8-bit string. Can be used when a reference to a static empty string is required.
Build a string containing a range of characters.
| [in] | first | First character in range. |
| [in] | last | Last character in range. |
| const ::WCHAR * ts::UString::wc_str | ( | ) | const |
Get the address of the underlying null-terminated Unicode string (Windows-specific).
| ::WCHAR * ts::UString::wc_str | ( | ) |
Get the address of the underlying null-terminated Unicode string (Windows-specific).
|
static |
Convert an UTF-8 string into UTF-16.
| [in] | utf8 | A string in UTF-8 representation. |
|
static |
Convert an UTF-8 string into UTF-16.
| [in] | utf8 | Address of a nul-terminated string in UTF-8 representation. |
|
static |
Convert an UTF-8 string into UTF-16.
| [in] | utf8 | Address of a string in UTF-8 representation. |
| [in] | count | Size in bytes of the UTF-8 string (not necessarily a number of characters). |
|
inline |
Convert an UTF-8 string into this object.
| [in] | utf8 | A string in UTF-8 representation. |
| UString & ts::UString::assignFromUTF8 | ( | const char * | utf8 | ) |
Convert an UTF-8 string into this object.
| [in] | utf8 | Address of a nul-terminated string in UTF-8 representation. |
| UString & ts::UString::assignFromUTF8 | ( | const char * | utf8, |
| size_type | count ) |
Convert an UTF-8 string into this object.
| [in] | utf8 | Address of a string in UTF-8 representation. Can be null. |
| [in] | count | Size in bytes of the UTF-8 string (not necessarily a number of characters). |
| std::string ts::UString::toUTF8 | ( | ) | const |
Convert this UTF-16 string into UTF-8.
| void ts::UString::toUTF8 | ( | std::string & | utf8 | ) | const |
Convert this UTF-16 string into UTF-8.
| [out] | utf8 | The equivalent UTF-8 string. |
| void ts::UString::toUTF8 | ( | ByteBlock & | utf8 | ) | const |
Convert this UTF-16 string into UTF-8 data.
| [out] | utf8 | The equivalent UTF-8 data. |
| void ts::UString::appendUTF8 | ( | std::string & | utf8 | ) | const |
Convert this UTF-16 string into UTF-8 and append in a 8-bit string.
| [in,out] | utf8 | Where to append the equivalent UTF-8 string. |
| void ts::UString::appendUTF8 | ( | ByteBlock & | utf8 | ) | const |
Convert this UTF-16 string into UTF-8 data and append in a byte block.
| [in,out] | utf8 | Where to append the equivalent UTF-8 data. |
|
static |
General routine to convert from UTF-16 to UTF-8. Stop when the input buffer is empty or the output buffer is full, whichever comes first. Invalid input values are silently ignored and skipped.
| [in,out] | in_start | Address of the input UTF-16 buffer to convert. Updated upon return to point after the last converted character. |
| [in] | in_end | Address after the end of the input UTF-16 buffer. |
| [in,out] | out_start | Address of the output UTF-8 buffer to fill. Updated upon return to point after the last converted character. |
| [in] | out_end | Address after the end of the output UTF-8 buffer to fill. |
|
static |
General routine to convert from UTF-8 to UTF-16. Stop when the input buffer is empty or the output buffer is full, whichever comes first. Invalid input values are silently ignored and skipped.
| [in,out] | in_start | Address of the input UTF-8 buffer to convert. Updated upon return to point after the last converted character. |
| [in] | in_end | Address after the end of the input UTF-8 buffer. |
| [in,out] | out_start | Address of the output UTF-16 buffer to fill. Updated upon return to point after the last converted character. |
| [in] | out_end | Address after the end of the output UTF-16 buffer to fill. |
Assign from a std::vector of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| INT | An integer type. |
| [in] | vec | The vector of characters. |
| [in] | count | Maximum number of characters to include in the string. Stop before the first nul character before max. Can be of any integer type, including a signed type. |
| UString & ts::UString::assign | ( | const std::vector< CHARTYPE > & | vec | ) |
Assign from a std::vector of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| [in] | vec | The vector of characters. Nul-terminated string. |
Assign from a std::array of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| SIZE | The size of the array. |
| INT | An integer type. |
| [in] | arr | The array of characters. |
| [in] | count | Maximum number of characters to include in the string. Stop before the first nul character before max. Can be of any integer type, including a signed type. |
| UString & ts::UString::assign | ( | const std::array< CHARTYPE, SIZE > & | arr | ) |
Assign from a std::array of 16-bit characters of any type.
| CHARTYPE | A 16-bit character or integer type. |
| SIZE | The size of the array. |
| [in] | arr | The array of characters. Nul-terminated string. |
|
static |
Convert a C++ "wide string" into UTF-16.
| [in] | wstr | A C++ "wide string". |
|
static |
Convert a C++ "wide string" into UTF-16.
| [in] | wstr | Address of a nul-terminated "wide string". Can be null. |
|
static |
Convert a C++ "wide string" into UTF-16.
| [in] | wstr | Address of a "wide string". Can be null. |
| [in] | count | Number of characters in wstr. |
|
inline |
Convert a C++ "wide string" into this object.
| [in] | wstr | A C++ "wide string". |
|
inline |
Convert a C++ "wide string" into this object.
| [in] | wstr | Address of a nul-terminated "wide string". Can be null. |
| UString & ts::UString::assignFromWChar | ( | const wchar_t * | wstr, |
| size_type | count ) |
Convert a C++ "wide string" into this object.
| [in] | wstr | Address of a "wide string". Can be null. |
| [in] | count | Number of characters in wstr. |
|
inline |
Conversion operator from ts::UString to std::filesystem::path
|
inline |
Comparison operator with std::filesystem::path.
| [in] | other | A path to compare. |
|
inline |
Get the address after the last character in the string.
|
inline |
Get the address after the last character in the string.
| size_type ts::UString::width | ( | ) | const |
Get the display width in characters. Any combining diacritical character is not counted in the width since it is combined with the preceding character. Similarly, any surrogate pair is considered as one single character. As a general rule, width() is always lower than or equal to length(), the number of characters in the string.
| size_type ts::UString::displayPosition | ( | size_type | count, |
| size_type | from = 0, | ||
| StringDirection | direction = LEFT_TO_RIGHT ) const |
Count displayed positions inside a string. Any combining diacritical character is not counted in display position. Similarly, any surrogate pair is considered as one single character.
| [in] | count | Number of display positions to move. |
| [in] | from | Starting index in the string. This is an index, not a display position. |
| [in] | direction | Direction to move when counting display positions. When counting RIGHT_TO_LEFT, from is the position after the right-most character. |
| void ts::UString::truncateWidth | ( | size_type | max_width, |
| StringDirection | direction = LEFT_TO_RIGHT ) |
Truncate this string to a given display width. Any combining diacritical character is not counted in display position. Similarly, any surrogate pair is considered as one single character.
| [in] | max_width | Maximum display width, after which the string is truncated. |
| [in] | direction | Direction to move when counting width. When RIGHT_TO_LEFT, the width is counted from the end of the string and the beginning of the string is truncated. |
| UString ts::UString::toTruncatedWidth | ( | size_type | max_width, |
| StringDirection | direction = LEFT_TO_RIGHT ) const |
Return a copy of this string, truncated to a given display width. Any combining diacritical character is not counted in display position. Similarly, any surrogate pair is considered as one single character.
| [in] | max_width | Maximum display width, after which the string is truncated. |
| [in] | direction | Direction to move when counting width. When RIGHT_TO_LEFT, the width is counted from the end of the string and the beginning of the string is truncated. |
| void ts::UString::reverse | ( | ) |
Reverse the order of characters in the string.
| void ts::UString::trimLength | ( | INT | length, |
| bool | trim_trailing_spaces = true ) |
Reduce the size of the string to a given length from an alien integer type. This method is useful when the string has been used as an input buffer.
| INT | An integer type. |
| [in] | length | New size of the string. Ignored if negative or greater than the current string length. |
| [in] | trim_trailing_spaces | If true, also remove any trailing space. |
| UString ts::UString::toReversed | ( | ) | const |
Return a copy of the string where characters are reversed.
| void ts::UString::trim | ( | bool | leading = true, |
| bool | trailing = true, | ||
| bool | sequences = false ) |
Trim leading and / or trailing space characters.
| [in] | leading | If true (the default), remove all space characters at the beginning of the string. |
| [in] | trailing | If true (the default), remove all space characters at the end of the string. |
| [in] | sequences | If true (disabled by default), replace all space characters sequences in the middle of the string by one single space character. |
| UString ts::UString::toTrimmed | ( | bool | leading = true, |
| bool | trailing = true, | ||
| bool | sequences = false ) const |
Return a copy of the string where leading and / or trailing spaces are trimmed.
| [in] | leading | If true (the default), remove all space characters at the beginning of the string. |
| [in] | trailing | If true (the default), remove all space characters at the end of the string. |
| [in] | sequences | If true (disabled by default), replace all space characters sequences in the middle of the string by one single space character. |
| void ts::UString::convertToLower | ( | ) |
Convert the string to lower-case.
| void ts::UString::convertToUpper | ( | ) |
Convert the string to uper-case.
| UString ts::UString::toLower | ( | ) | const |
Return a lower-case version of the string.
| UString ts::UString::toUpper | ( | ) | const |
Return an upper-case version of the string.
| void ts::UString::combineDiacritical | ( | ) |
Combine all possible diacritical marks. All sequences of two characters, letter and non-spacing diacritical marks, which can be grouped into once single precombined character are substituted with this precombined character.
| UString ts::UString::toCombinedDiacritical | ( | ) | const |
Return a string with all possible diacritical marks combined.
| void ts::UString::decomposeDiacritical | ( | ) |
Decompose all precombined characters. All precombined characters are replaced by two characters, the base letter and the non-spacing diacritical mark.
| UString ts::UString::toDecomposedDiacritical | ( | ) | const |
Return a string with all precombined characters decomposed.
| void ts::UString::remove | ( | const UString & | substr | ) |
Remove all occurrences of a substring.
| [in] | substr | Substring to remove. |
| void ts::UString::remove | ( | UChar | c | ) |
Remove all occurrences of a character.
| [in] | c | Character to remove. |
Remove all occurrences of a substring.
| [in] | substr | Substring to remove. |
Remove all occurrences of a character.
| [in] | c | Character to remove. |
Substitute all occurrences of a string with another one.
| [in] | value | Value to search. |
| [in] | replacement | Replacement string for value. |
Substitute all occurrences of a character with another one.
| [in] | value | Value to search. |
| [in] | replacement | Replacement for value. |
Return a copy of the string where all occurrences of a string are substituted with another one.
| [in] | value | Value to search. |
| [in] | replacement | Replacement string for value. |
Return a copy of the string where all occurrences of a character are substituted with another one.
| [in] | value | Value to search. |
| [in] | replacement | Replacement for value. |
| void ts::UString::removePrefix | ( | const UString & | prefix, |
| CaseSensitivity | cs = CASE_SENSITIVE ) |
Remove a prefix in string.
| [in] | prefix | A prefix to remove, if present at the beginning of the string. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| void ts::UString::removeSuffix | ( | const UString & | suffix, |
| CaseSensitivity | cs = CASE_SENSITIVE ) |
Remove a suffix in string.
| [in] | suffix | A suffix to remove, if present at the end of the string. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| UString ts::UString::toRemovedPrefix | ( | const UString & | prefix, |
| CaseSensitivity | cs = CASE_SENSITIVE ) const |
Remove a prefix in string.
| [in] | prefix | A prefix to remove, if present at the beginning of the string. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| UString ts::UString::toRemovedSuffix | ( | const UString & | suffix, |
| CaseSensitivity | cs = CASE_SENSITIVE ) const |
Remove a suffix in string.
| [in] | suffix | A suffix to remove, if present at the end of the string. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| void ts::UString::indent | ( | size_t | size | ) |
Indent all lines in the string.
| [in] | size | Number of spaces to add at the beginning of each line. |
| UString ts::UString::toIndented | ( | size_t | size | ) | const |
Indent all lines in the string.
| [in] | size | Number of spaces to add at the beginning of each line. |
| bool ts::UString::starts_with | ( | const UString & | prefix, |
| CaseSensitivity | cs = CASE_SENSITIVE, | ||
| bool | skip_spaces = false, | ||
| size_type | start = 0 ) const |
Check if the string starts with a specified prefix.
| [in] | prefix | A string prefix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore initial spaces in this string. |
| [in] | start | Start index where to match the prefix. |
|
inline |
Check if the string starts with a specified prefix.
| [in] | prefix | A string prefix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore initial spaces in this string. |
| [in] | start | Start index where to match the prefix. |
|
inline |
Check if the string starts with a specified prefix.
| [in] | prefix | A string prefix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore initial spaces in this string. |
| [in] | start | Start index where to match the prefix. |
|
inline |
Check if the string starts with a specified prefix.
| [in] | prefix | A string prefix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore initial spaces in this string. |
| [in] | start | Start index where to match the prefix. |
| bool ts::UString::contains | ( | UChar | c | ) | const |
Check if a string contains a specified character.
| [in] | c | A character to check. |
| bool ts::UString::contains | ( | const UString & | substring, |
| CaseSensitivity | cs = CASE_SENSITIVE ) const |
Check if a string contains a specified substring.
| [in] | substring | A substring to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| bool ts::UString::ends_with | ( | const UString & | suffix, |
| CaseSensitivity | cs = CASE_SENSITIVE, | ||
| bool | skip_spaces = false, | ||
| size_type | end = NPOS ) const |
Check if a string ends with a specified suffix.
| [in] | suffix | A string suffix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore trailing spaces in this string. |
| [in] | end | Last logical character to check in the string. By default, use the end of string. |
|
inline |
Check if a string ends with a specified suffix.
| [in] | suffix | A string suffix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore trailing spaces in this string. |
| [in] | end | Last logical character to check in the string. By default, use the end of string. |
|
inline |
Check if a string ends with a specified suffix.
| [in] | suffix | A string suffix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore trailing spaces in this string. |
| [in] | end | Last logical character to check in the string. By default, use the end of string. |
|
inline |
Check if a string ends with a specified suffix.
| [in] | suffix | A string suffix to check. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| [in] | skip_spaces | If true, ignore trailing spaces in this string. |
| [in] | end | Last logical character to check in the string. By default, use the end of string. |
| size_t ts::UString::commonPrefixSize | ( | const UString & | str, |
| CaseSensitivity | cs = CASE_SENSITIVE ) const |
Compute the number of similar leading characters in two strings.
| [in] | str | A string to compare with this string. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
| size_t ts::UString::commonSuffixSize | ( | const UString & | str, |
| CaseSensitivity | cs = CASE_SENSITIVE ) const |
Compute the number of similar trailing characters in two strings.
| [in] | str | A string to compare with this string. |
| [in] | cs | Indicate if the comparison is case-sensitive. |
|
inline |
Split the string into segments based on a separator character (comma by default).
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString which receives the segments of the splitted string. |
| [in] | separator | The character which is used to separate the segments. |
| [in] | trim_spaces | If true (the default), each segment is trimmed, i.e. all leading and trailing space characters are removed. |
| [in] | remove_empty | If true, empty segments are ignored |
| void ts::UString::splitAppend | ( | CONTAINER & | container, |
| UChar | separator = COMMA, | ||
| bool | trim_spaces = true, | ||
| bool | remove_empty = false ) const |
Split the string into segments based on a separator character (comma by default).
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString which receives the segments of the splitted string. The strings are appended to the container without erasing previous content. |
| [in] | separator | The character which is used to separate the segments. |
| [in] | trim_spaces | If true (the default), each segment is trimmed, i.e. all leading and trailing space characters are removed. |
| [in] | remove_empty | If true, empty segments are ignored |
|
inline |
Split the string into shell-style arguments. Spaces are used as argument delimiters. Arguments can be quoted using single or double quotes. Any character can be escaped using a backslash.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString which receives the segments of the splitted string. |
| void ts::UString::splitShellStyleAppend | ( | CONTAINER & | container | ) | const |
Split the string into shell-style arguments. Spaces are used as argument delimiters. Arguments can be quoted using single or double quotes. Any character can be escaped using a backslash.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString which receives the segments of the splitted string. The strings are appended to the container without erasing previous content. |
|
inline |
Split a string into segments which are identified by their starting / ending characters (respectively "[" and "]" by default).
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString which receives the segments of the splitted string. |
| [in] | starts_with | The character which is used to identify the start of a segment of input. |
| [in] | ends_with | The character which is used to identify the end of a segment of input. |
| [in] | trim_spaces | If true (the default), each segment is trimmed, i.e. all leading and trailing space characters are removed. |
| void ts::UString::splitBlocksAppend | ( | CONTAINER & | container, |
| UChar | starts_with = u'[', | ||
| UChar | ends_with = u']', | ||
| bool | trim_spaces = true ) const |
Split a string into segments which are identified by their starting / ending characters (respectively "[" and "]" by default).
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString which receives the segments of the splitted string. The strings are appended to the container without erasing previous content. |
| [in] | starts_with | The character which is used to identify the start of a segment of input. |
| [in] | ends_with | The character which is used to identify the end of a segment of input. |
| [in] | trim_spaces | If true (the default), each segment is trimmed, i.e. all leading and trailing space characters are removed. |
|
inline |
Split a string into multiple lines which are not longer than a specified maximum width. The splits occur on spaces or after any character in other_separators.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString which receives the lines of the splitted string. |
| [in] | max_width | Maximum width of each resulting line. |
| [in] | other_separators | A string containing all characters which are acceptable as line break points (in addition to space characters which are always potential line break points). |
| [in] | next_margin | A string which is prepended to all lines after the first one. |
| [in] | force_split | If true, longer lines without separators are split at the maximum width (by default, longer lines without separators are not split, resulting in lines longer than max_width). |
| void ts::UString::splitLinesAppend | ( | CONTAINER & | container, |
| size_type | max_width, | ||
| const UString & | other_separators = UString(), | ||
| const UString & | next_margin = UString(), | ||
| bool | force_split = false ) const |
Split a string into multiple lines which are not longer than a specified maximum width. The splits occur on spaces or after any character in other_separators.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString which receives the lines of the splitted string. The strings are appended to the container without erasing previous content. |
| [in] | max_width | Maximum width of each resulting line. |
| [in] | other_separators | A string containing all characters which are acceptable as line break points (in addition to space characters which are always potential line break points). |
| [in] | next_margin | A string which is prepended to all lines after the first one. |
| [in] | force_split | If true, longer lines without separators are split at the maximum width (by default, longer lines without separators are not split, resulting in lines longer than max_width). |
| UString ts::UString::toSplitLines | ( | size_type | max_width, |
| const UString & | other_separators = UString(), | ||
| const UString & | next_margin = UString(), | ||
| bool | force_split = false, | ||
| const UString & | line_separator = UString(1, LINE_FEED) ) const |
Split a string into multiple lines which are not longer than a specified maximum width. The splits occur on spaces or after any character in other_separators.
| [in] | max_width | Maximum width of each resulting line. |
| [in] | other_separators | A string containing all characters which are acceptable as line break points (in addition to space characters which are always potential line break points). |
| [in] | next_margin | A string which is prepended to all lines after the first one. |
| [in] | force_split | If true, longer lines without separators are split at the maximum width (by default, longer lines without separators are not split, resulting in lines longer than max_width). |
| [in] | line_separator | The sequence of characters for line feed. |
| UString ts::UString::join | ( | ITERATOR | begin, |
| ITERATOR | end, | ||
| bool | remove_empty = false ) const |
Join a part of a container of strings into one big string. This string is used as separator between the strings to join. The strings are accessed through iterators in the container. All strings are concatenated into one big string.
| ITERATOR | An iterator class over UString as defined by the C++ Standard Template Library (STL). |
| [in] | begin | An iterator pointing to the first string. |
| [in] | end | An iterator pointing after the last string. |
| [in] | remove_empty | If true, empty segments are ignored |
|
inline |
Join a container of strings into one big string. This string is used as separator between the strings to join. All strings from the container are concatenated into one big string.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString containing all strings to concatenate. |
| [in] | remove_empty | If true, empty segments are ignored |
|
inlinestatic |
Join a part of a container of strings into one big string. The strings are accessed through iterators in the container. All strings are concatenated into one big string.
| ITERATOR | An iterator class over UString as defined by the C++ Standard Template Library (STL). |
| [in] | begin | An iterator pointing to the first string. |
| [in] | end | An iterator pointing after the last string. |
| [in] | separator | A string to insert between all segments. |
| [in] | remove_empty | If true, empty segments are ignored |
|
inlinestatic |
Join a part of a container of strings into one big string. The strings are accessed through iterators in the container. All strings are concatenated into one big string.
| ITERATOR | An iterator class over UString as defined by the C++ Standard Template Library (STL). |
| [in] | begin | An iterator pointing to the first string. |
| [in] | end | An iterator pointing after the last string. |
| [in] | separator | A character to insert between all segments. |
| [in] | remove_empty | If true, empty segments are ignored |
|
inlinestatic |
Join a container of strings into one big string. All strings from the container are concatenated into one big string.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString containing all strings to concatenate. |
| [in] | separator | A string to insert between all segments. |
| [in] | remove_empty | If true, empty segments are ignored |
|
inlinestatic |
Join a container of strings into one big string. All strings from the container are concatenated into one big string.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString containing all strings to concatenate. |
| [in] | separator | A character to insert between all segments. |
| [in] | remove_empty | If true, empty segments are ignored |
| void ts::UString::justifyLeft | ( | size_type | width, |
| UChar | pad = SPACE, | ||
| bool | truncate = false, | ||
| size_t | spaces_before_pad = 0 ) |
Left-justify (pad and optionally truncate) string. If this string is shorter than the specified width, pad characters are appended to the string up to the specified width.
| [in] | width | The required width of the result string. |
| [in] | pad | The character to append to the string. |
| [in] | truncate | If true and this string is longer than width, it is truncated to width character. If false, this string is never truncated, possibly resulting in a string longer than width. |
| [in] | spaces_before_pad | Number of spaces before padding. |
| UString ts::UString::toJustifiedLeft | ( | size_type | width, |
| UChar | pad = SPACE, | ||
| bool | truncate = false, | ||
| size_t | spaces_before_pad = 0 ) const |
Return a left-justified (padded and optionally truncated) string. If this string is shorter than the specified width, pad characters are appended to the string up to the specified width.
| [in] | width | The required width of the result string. |
| [in] | pad | The character to append to the string. |
| [in] | truncate | If true and this string is longer than width, it is truncated to width character. If false, this string is never truncated, possibly resulting in a string longer than width. |
| [in] | spaces_before_pad | Number of spaces before padding. |
| void ts::UString::justifyRight | ( | size_type | width, |
| UChar | pad = SPACE, | ||
| bool | truncate = false, | ||
| size_t | spaces_after_pad = 0 ) |
Right-justified (pad and optionally truncate) string. If this string is shorter than the specified width, pad characters are prepended to the string up to the specified width.
| [in] | width | The required width of the result string. |
| [in] | pad | The character to prepend to the string. |
| [in] | truncate | If true and this string is longer than width, the beginning of str is truncated. If false, this string is never truncated, possibly resulting in a string longer than width. |
| [in] | spaces_after_pad | Number of spaces after padding. |
| UString ts::UString::toJustifiedRight | ( | size_type | width, |
| UChar | pad = SPACE, | ||
| bool | truncate = false, | ||
| size_t | spaces_after_pad = 0 ) const |
Return a right-justified (padded and optionally truncated) string. If this string is shorter than the specified width, pad characters are prepended to the string up to the specified width.
| [in] | width | The required width of the result string. |
| [in] | pad | The character to prepend to the string. |
| [in] | truncate | If true and this string is longer than width, the beginning of str is truncated. If false, this string is never truncated, possibly resulting in a string longer than width. |
| [in] | spaces_after_pad | Number of spaces after padding. |
| void ts::UString::justifyCentered | ( | size_type | width, |
| UChar | pad = SPACE, | ||
| bool | truncate = false, | ||
| size_t | spaces_around_pad = 0 ) |
Centered-justified (pad and optionally truncate) string. If this string is shorter than the specified width, pad characters are prepended and appended to the string up to the specified width.
| [in] | width | The required width of the result string. |
| [in] | pad | The pad character for the string. |
| [in] | truncate | If true and this string is longer than width, this string is truncated to width character. If false, this string is never truncated, possibly resulting in a string longer than width. |
| [in] | spaces_around_pad | Number of spaces around padding. |
| UString ts::UString::toJustifiedCentered | ( | size_type | width, |
| UChar | pad = SPACE, | ||
| bool | truncate = false, | ||
| size_t | spaces_around_pad = 0 ) const |
Return a centered-justified (padded and optionally truncated) string. If this string is shorter than the specified width, pad characters are prepended and appended to the string up to the specified width.
| [in] | width | The required width of the result string. |
| [in] | pad | The pad character for the string. |
| [in] | truncate | If true and this string is longer than width, this string is truncated to width character. If false, this string is never truncated, possibly resulting in a string longer than width. |
| [in] | spaces_around_pad | Number of spaces around padding. |
| void ts::UString::justify | ( | const UString & | right, |
| size_type | width, | ||
| UChar | pad = SPACE, | ||
| size_t | spaces_around_pad = 0 ) |
Justify string, pad in the middle. If the this string and right components are collectively shorter than the specified width, pad characters are inserted between left and right, up to the specified width.
| [in] | right | The right part of the string to justify. This string is used as left part. |
| [in] | width | The required width of the result string. |
| [in] | pad | The character to insert between the two parts. |
| [in] | spaces_around_pad | Number of spaces around padding. |
| UString ts::UString::toJustified | ( | const UString & | right, |
| size_type | width, | ||
| UChar | pad = SPACE, | ||
| size_t | spaces_around_pad = 0 ) const |
Return a justified string, pad in the middle. If the this string and right components are collectively shorter than the specified width, pad characters are inserted between left and right, up to the specified width.
| [in] | right | The right part of the string to justify. This string is used as left part. |
| [in] | width | The required width of the result string. |
| [in] | pad | The character to insert between the two parts. |
| [in] | spaces_around_pad | Number of spaces around padding. |
| void ts::UString::quoted | ( | UChar | quote_character = u'\'', |
| const UString & | special_characters = DEFAULT_SPECIAL_CHARACTERS, | ||
| bool | force_quote = false, | ||
| UChar | non_print = u'?' ) |
Replace the string with a "quoted" version of it. If this string contains any space character or any character from special_characters, then the string is replaced with a value surrounded by the quote_character and all special characters are properly escaped using a backslash.
| [in] | quote_character | The character to be used as quote. |
| [in] | special_characters | The list of special characters. The quote_character is implicitly part of special_characters. |
| [in] | force_quote | If true, force quote, even if the content does not require it. |
| [in] | non_print | Replacement character for all non-printable characters. |
| UString ts::UString::toQuoted | ( | UChar | quote_character = u'\'', |
| const UString & | special_characters = DEFAULT_SPECIAL_CHARACTERS, | ||
| bool | force_quote = false, | ||
| UChar | non_print = u'?' ) const |
Return a "quoted" version of this string.
| [in] | quote_character | The character to be used as quote. |
| [in] | special_characters | The list of special characters. The quote_character is implicitly part of special_characters. |
| [in] | force_quote | If true, force quote, even if the content does not require it. |
| [in] | non_print | Replacement character for all non-printable characters. |
| void ts::UString::quotedLine | ( | const CONTAINER & | container, |
| UChar | quote_character = u'\'', | ||
| const UString & | special_characters = DEFAULT_SPECIAL_CHARACTERS ) |
Convert a container of strings into one big string where all elements are properly quoted when necessary. This string object receives the final line with quoted elements.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString containing all elements. |
| [in] | quote_character | The character to be used as quote. |
| [in] | special_characters | The list of special characters. The quote_character is implicitly part of special_characters. |
|
static |
Convert a container of strings into one big string where all elements are properly quoted when necessary.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString containing all elements. |
| [in] | quote_character | The character to be used as quote. |
| [in] | special_characters | The list of special characters. The quote_character is implicitly part of special_characters. |
| void ts::UString::fromQuotedLine | ( | CONTAINER & | container, |
| const UString & | quote_characters = DEFAULT_QUOTE_CHARACTERS, | ||
| const UString & | special_characters = DEFAULT_SPECIAL_CHARACTERS ) const |
Split this string in space-separated possibly-quoted elements.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString receiving all unquoted elements. |
| [in] | quote_characters | All characters which are recognized as quote at the beginning of an element. |
| [in] | special_characters | The list of special characters. The quote_character is implicitly part of special_characters. |
| void ts::UString::unquoted | ( | const UString & | quote_characters = DEFAULT_QUOTE_CHARACTERS | ) |
Remove matching pairs of quotes at beginning and end of string. This is done recursively (e.g. "'"abcd"'" -> abcd).
| [in] | quote_characters | All characters which are recognized as quote. |
| UString ts::UString::toUnquoted | ( | const UString & | quote_characters = DEFAULT_QUOTE_CHARACTERS | ) | const |
Return a version of the string with matching pairs of quotes at beginning and end removed.
| [in] | quote_characters | All characters which are recognized as quote. |
Convert the string into a suitable HTML representation.
| [in] | convert | A string containing all characters to convert into their corresponding HTML entities. If empty, all characters are converted. |
Return the string in a suitable HTML representation.
| [in] | convert | A string containing all characters to convert into their corresponding HTML entities. If empty, all characters are converted. |
| void ts::UString::convertFromHTML | ( | ) |
Convert all HTML entities in the string into plain characters.
| UString ts::UString::fromHTML | ( | ) | const |
Return the string with all HTML entities converted into plain characters.
| void ts::UString::convertToJSON | ( | ) |
Convert the string into a suitable JSON representation. The characters to escape are converted with backslashes.
| UString ts::UString::toJSON | ( | ) | const |
Return the string in a suitable JSON representation.
| void ts::UString::convertFromJSON | ( | ) |
Convert all JSON backslash sequences in the string into plain characters.
| UString ts::UString::fromJSON | ( | ) | const |
Return the string with all JSON backslash sequences converted into plain characters.
|
static |
Format a boolean value as "yes" or "no".
| [in] | b | A boolean value. |
|
static |
Format a boolean value as "true" or "false".
| [in] | b | A boolean value. |
|
static |
Format a boolean value as "on" or "off".
| [in] | b | A boolean value. |
Format a tristate value as "yes", "no", "maybe".
| [in] | b | A tristate value. |
Format a tristate value as "true", "false", "unknown".
| [in] | b | A tristate value. |
Format a tristate value as "on", "off", "unknown".
| [in] | b | A tristate value. |
|
static |
Build an error message fragment indicating the number of bytes previously read in a binary file.
| [in] | position | A stream position. |
|
static |
Format a human-readable size using MB, kB or B as appropriate.
| [in] | value | A size value in basic units. This is a signed value. |
| [in] | units | A string for the units. The default is "B" (for bytes). |
| [in] | force_sign | If true, use a '+' sign for positive value. |
|
static |
Format a percentage string.
| [in] | value | An integer value, a portion of total. |
| [in] | total | The total value. |
|
static |
Format a percentage string between duration values.
| [in] | value | A duration value, a portion of total. |
| [in] | total | The total duration value. |
|
inline |
Compare two strings using various comparison options.
| [in] | other | Other string to compare. |
| [in] | flags | A bitmask of StringComparison values. By default, use a strict comparison. |
| [in] | this_pos | Starting position in this string. If it points beyond the end of string, consider the string as empty. |
| [in] | other_pos | Starting position in string other. If it points beyond the end of string, consider the string as empty. |
|
inline |
Compare two strings using various comparison options.
| [in] | other | Address of a nul-terminated UTF-16 string. |
| [in] | flags | A bitmask of StringComparison values. By default, use a strict comparison. |
| [in] | this_pos | Starting position in this string. If it points beyond the end of string, consider the string as empty. |
| [in] | other_pos | Starting position in string other. If it points beyond the end of string, consider the string as empty. |
|
static |
Compare two strings using various comparison options.
| [in] | s1 | Address of a nul-terminated UTF-16 string. |
| [in] | s2 | Address of a nul-terminated UTF-16 string. |
| [in] | flags | A bitmask of StringComparison values. By default, use a strict comparison. |
| [in] | s1_pos | Starting position in string s1. If it points beyond the end of s1, consider s1 as an empty string. |
| [in] | s2_pos | Starting position in string s2. If it points beyond the end of s2, consider s2 as an empty string. |
|
inline |
Check if two strings are identical, case-insensitive and ignoring blanks.
| [in] | other | Other string to compare. |
| [in] | this_pos | Starting position in this string. If it points beyond the end of string, consider the string as empty. |
| [in] | other_pos | Starting position in string other. If it points beyond the end of string, consider the string as empty. |
|
inline |
Check if two strings are identical, case-insensitive and ignoring blanks.
| [in] | other | Other string to compare. |
| [in] | this_pos | Starting position in this string. If it points beyond the end of string, consider the string as empty. |
| [in] | other_pos | Starting position in string other. If it points beyond the end of string, consider the string as empty. |
| bool ts::UString::similar | ( | const void * | addr, |
| size_type | size, | ||
| size_t | this_pos = 0, | ||
| size_t | other_pos = 0 ) const |
Check if two strings are identical, case-insensitive and ignoring blanks.
| [in] | addr | Address of second string in UTF-8 representation. |
| [in] | size | Size in bytes of second string. |
| [in] | this_pos | Starting position in this string. If it points beyond the end of string, consider the string as empty. |
| [in] | other_pos | Starting position in string other. If it points beyond the end of string, consider the string as empty. |
Check if two strings are identical, case-insensitive and ignoring blanks, after a delimiter character.
| [in] | other | Other string to compare. |
| [in] | separator | Compare the part of the strings after the last occurrence of that character. If separator is not found in a string, use the complete string. |
Check if two strings are identical, case-insensitive and ignoring blanks, after a delimiter character.
| [in] | other | Other string to compare. |
| [in] | separator | Compare the part of the strings after the last occurrence of that character. If separator is not found in a string, use the complete string. |
| bool ts::UString::similarAfterLast | ( | const void * | addr, |
| size_type | size, | ||
| UChar | separator ) const |
Check if two strings are identical, case-insensitive and ignoring blanks, after a delimiter character.
| [in] | addr | Address of second string in UTF-8 representation. |
| [in] | size | Size in bytes of second string. |
| [in] | separator | Compare the part of the strings after the last occurrence of that character. If separator is not found in a string, use the complete string. |
| bool ts::UString::isContainedSimilarIn | ( | const CONTAINER & | container, |
| size_t | this_pos = 0 ) const |
Check if a container of strings contains something similar to this string.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString. |
| [in] | this_pos | Starting position in this string. If it points beyond the end of string, consider the string as empty. |
| CONTAINER::const_iterator ts::UString::findSimilar | ( | const CONTAINER & | container, |
| size_t | this_pos = 0 ) const |
Locate into a map or multimap an element with a similar string.
| CONTAINER | A map container class using UString as key. |
| [in] | container | A map container with UString keys. |
| [in] | this_pos | Starting position in this string. If it points beyond the end of string, consider the string as empty. |
| int ts::UString::constantTimeCompare | ( | const UString & | secret | ) | const |
Compare two strings in constant time. This method is useful to compare a public string (this string, typically an entered password or authentication token) to a secret string (typically the secret password or token). The execution time of this method only depends on the content of this object, not the content of secret. This method is slower than a direct comparison but it executes in constant time.
| [in] | secret | A secret string to compare. |
| bool ts::UString::save | ( | const fs::path & | file_name, |
| bool | append = false, | ||
| bool | enforce_last_line_feed = false ) const |
Save this string into a file, in UTF-8 format.
| [in] | file_name | The name of the text file where to save this string. If the file path is empty or "-", write to the standard output. |
| [in] | append | If true, append this string at the end of the file. If false (the default), overwrite the file if it already existed. |
| [in] | enforce_last_line_feed | If true and this string does not end with a line feed, force a final line feed. |
|
static |
Save strings from a container into a file, in UTF-8 format, one per line. The strings must be located in a container and are accessed through iterators.
| ITERATOR | An iterator class over UString as defined by the C++ Standard Template Library (STL). |
| [in] | begin | An iterator pointing to the first string. |
| [in] | end | An iterator pointing after the last string. |
| [in] | file_name | The name of the text file where to save the strings. If the file path is empty or "-", write to the standard output. |
| [in] | append | If true, append the strings at the end of the file. If false (the default), overwrite the file if it already existed. |
|
static |
Save strings from a container into a file, in UTF-8 format, one per line.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString containing all strings to save. |
| [in] | file_name | The name of the text file where to save the strings. If the file path is empty or "-", write to the standard output. |
| [in] | append | If true, append the strings at the end of the file. If false (the default), overwrite the file if it already existed. |
|
static |
Save strings from a container into a stream, in UTF-8 format, one per line. The strings must be located in a container and are accessed through iterators.
| ITERATOR | An iterator class over UString as defined by the C++ Standard Template Library (STL). |
| [in] | begin | An iterator pointing to the first string. |
| [in] | end | An iterator pointing after the last string. |
| [in] | strm | Output stream. |
|
static |
Save strings from a container into a file, in UTF-8 format, one per line.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in] | container | A container of UString containing all strings to save. |
| [in] | strm | Output stream. |
|
static |
Load all lines of a text file in UTF-8 format as UString's into a container.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString receiving all lines of the file. Each line of the text file is a separate string. |
| [in] | file_name | The name of the text file from where to load the strings. |
| [in] | max_lines | Maximum number of lines to read. Unlimited by default. |
|
static |
Load all lines of a text file in UTF-8 format as UString's and append them in a container.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString receiving all lines of the file. Each line of the text file is a separate string. |
| [in] | file_name | The name of the text file from where to load the strings. Each line of the text file is inserted as a separate string. |
| [in] | max_lines | Maximum number of lines to read. Unlimited by default. |
|
static |
Load all lines of a text file in UTF-8 format as UString's into a container.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString receiving all lines of the file. Each line of the text file is a separate string. |
| [in,out] | strm | A standard text stream in input mode. Each line of the text file is inserted as a separate string. |
| [in] | max_lines | Maximum number of lines to read. Unlimited by default. |
|
static |
Load all lines of a text file in UTF-8 format as UString's and append them in a container.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString receiving all lines of the file. Each line of the text file is a separate string. |
| [in,out] | strm | A standard text stream in input mode. Each line of the text file is inserted as a separate string. |
| [in] | max_lines | Maximum number of lines to read. Unlimited by default. |
| bool ts::UString::getLine | ( | std::istream & | strm | ) |
Read one UTF-8 line from a text file and load it into this object.
| [in,out] | strm | A standard stream in input mode. |
| bool ts::UString::toBool | ( | bool & | value | ) | const |
Convert a string into a bool value.
This string must contain the representation of an integer value in decimal or hexadecimal (prefix 0x) or one of "false", "true", "yes", "no", "on", "off" (not case sensitive).
| [out] | value | The returned decoded value. On error value contains false. |
|
static |
Get the list of valid strings for bool values.
| bool ts::UString::toTristate | ( | Tristate & | value | ) | const |
Convert a string into a Tristate value.
This string must contain the representation of an integer value in decimal or hexadecimal (prefix 0x) or one of "false", "true", "yes", "no", "on", "off", "maybe", "unknown" (not case sensitive).
| [out] | value | The returned decoded value. On error value contains MAYBE. |
|
static |
Check if the string is a syntactically valid integer.
| [in] | thousand_separators | A string of characters which are interpreted as thousands separators and are ignored. Any character from the thousand_separators string is interpreted as a separator. Note that this implies that the optional thousands separators may have one character only. |
| bool ts::UString::toInteger | ( | INT & | value, |
| const UString & | thousand_separators = UString(), | ||
| size_type | decimals = 0, | ||
| const UString & | decimal_separators = u".", | ||
| INT | min_value = std::numeric_limits< INT >::min(), | ||
| INT | max_value = std::numeric_limits< INT >::max() ) const |
Convert a string into an integer.
This string must contain the representation of an integer value in decimal or hexadecimal (prefix 0x). Hexadecimal values are case-insensitive, including the 0x prefix. Leading and trailing spaces are ignored. Optional thousands separators are ignored.
| INT | An integer type, any size, signed or unsigned. The toInteger function decodes integer values of this type. |
| [out] | value | The returned decoded value. On error (invalid string), value contains what could be decoded up to the first invalid character. |
| [in] | thousand_separators | A string of characters which are interpreted as thousands separators and are ignored. Any character from the thousand_separators string is interpreted as a separator. Note that this implies that the optional thousands separators may have one character only. |
| [in] | decimals | Reference number of decimal digits. When decimals is greater than zero, the result is automatically adjusted by the corresponding power of ten. For instance, when decimals is 3, u"12" returns 12000, u"12.34" returns 12340 and "12.345678" returns 12345. All extra decimals are accepted but ignored. |
| [in] | decimal_separators | A string of characters which are interpreted as decimal point. A decimal point is allowed only in base 10. |
| [in] | min_value | minimum allowed value for the decoded integer. |
| [in] | max_value | maximum allowed value for the decoded integer. |
| bool ts::UString::toIntegers | ( | CONTAINER & | container, |
| const UString & | thousand_separators = UString(), | ||
| const UString & | list_separators = UString(u",; "), | ||
| size_type | decimals = 0, | ||
| const UString & | decimal_separators = UString(u"."), | ||
| typename CONTAINER::value_type | min_value = std::numeric_limits< typename CONTAINER::value_type >::min(), | ||
| typename CONTAINER::value_type | max_value = std::numeric_limits< typename CONTAINER::value_type >::max() ) const |
Convert a string containing a list of integers into a container of integers.
This string must contain the representation of integer values in decimal or hexadecimal (prefix 0x). Hexadecimal values are case-insensitive, including the 0x prefix. Leading and trailing spaces are ignored. Optional thousands separators are ignored. The various integer values in the string are separated using list delimiters.
| CONTAINER | A container class of any integer type as defined by the C++ Standard Template Library (STL). |
| [out] | container | The returned decoded values. The previous content of the container is discarded. The integer values are added in the container in the order of the decoded string. On error (invalid string), container contains what could be decoded up to the first invalid character. |
| [in] | thousand_separators | A string of characters which are interpreted as thousands separators and are ignored. Any character from the thousand_separators string is interpreted as a separator. Note that this implies that the optional thousands separators may have one character only. |
| [in] | list_separators | A string of characters which are interpreted as list separators. Distinct integer values must be separated by one or more of these separators. Any character from the listSeparators string is interpreted as a separator. Note that this implies that the list separators may have one character only. |
| [in] | decimals | Reference number of decimal digits. When decimals is greater than zero, the result is automatically adjusted by the corresponding power of ten. For instance, when decimals is 3, u"12" returns 12000, u"12.34" returns 12340 and "12.345678" returns 12345. All extra decimals are accepted but ignored. |
| [in] | decimal_separators | A string of characters which are interpreted as decimal point. A decimal point is allowed only in base 10. |
| [in] | min_value | minimum allowed value for the decoded integers. |
| [in] | max_value | maximum allowed value for the decoded integers. |
| bool ts::UString::toFloat | ( | FLT & | value, |
| FLT | min_value = std::numeric_limits< FLT >::lowest(), | ||
| FLT | max_value = std::numeric_limits< FLT >::max() ) const |
Convert a string into a floating-point.
This string must contain the representation of a floating-point value.
| FLT | A floating-point type. The toFloat() function decodes floating-point values of this type. |
| [out] | value | The returned decoded value. |
| [in] | min_value | Minimum allowed value for the decoded value. |
| [in] | max_value | Maximum allowed value for the decoded value. |
|
static |
Format a string containing a decimal value.
| INT | An integer type. |
| [in] | value | The integer value to format. |
| [in] | min_width | Minimum width of the returned string. Padded with spaces if larger than the number of characters in the formatted number. |
| [in] | right_justified | If true (the default), return a right-justified string. When false, return a left-justified string. Ignored if min_width is lower than the number of characters in the formatted number. |
| [in] | separator | Separator string for groups of thousands, a comma by default. |
| [in] | force_sign | If true, force a '+' sign for positive values. |
| [in] | pad | The padding character to adjust the width. |
|
static |
Format a string containing a list of decimal values.
| CONTAINER | A container class of any integer type as defined by the C++ Standard Template Library (STL). |
| [in] | values | The integer values to format. |
| [in] | separator | Separator string between values, a comma by default. |
| [in] | force_sign | If true, force a '+' sign for positive values. |
|
static |
Format a string containing an hexadecimal value.
| INT | An integer type. |
| [in] | value | The integer value to format. |
| [in] | width | Width of the formatted number, not including the optional prefix and separator. By default, use the "natural" size of INT (e.g. 8 for 32-bit integer). |
| [in] | separator | Separator string for groups of 4 digits, empty by default. |
| [in] | use_prefix | If true, prepend the standard hexa prefix "0x". |
| [in] | use_upper | If true, use upper-case hexadecimal digits. |
|
static |
Format a string containing an hexadecimal value. This version differ from Hexa() in the interpretation of the @ min_width argument.
| INT | An integer type. |
| [in] | value | The integer value to format. |
| [in] | min_width | Minimum width of the returned string, including the optional prefix and separator. By default, use the "natural" size of INT (e.g. 8 for 32-bit integer) plus prefix and separator. |
| [in] | separator | Separator string for groups of 4 digits, empty by default. |
| [in] | use_prefix | If true, prepend the standard hexa prefix "0x". |
| [in] | use_upper | If true, use upper-case hexadecimal digits. |
|
static |
Format a string containing a floating point value.
| [in] | value | The floating point value to format. |
| [in] | width | Width of the formatted number, not including the optional prefix and separator. |
| [in] | precision | Precision to use after the decimal point. Default is 6 digits when set to zero. |
| [in] | force_sign | If true, force a '+' sign for positive values. |
| bool ts::UString::toChrono | ( | cn::duration< Rep, Period > & | value, |
| const UString & | thousand_separators = UString(), | ||
| const cn::duration< Rep, Period > & | min_value = cn::duration< Rep, Period >::min(), | ||
| const cn::duration< Rep, Period > & | max_value = cn::duration< Rep, Period >::max() ) const |
Convert a string into a std::chrono::duration value. No suffix is decoded. The string shall contain an integer value which is interpreted in units of the temaplte std::chrono::duration type.
| [out] | value | The returned decoded value. On error (invalid string), value contains what could be decoded up to the first invalid character. |
| [in] | thousand_separators | A string of characters which are interpreted as thousands separators and are ignored. Any character from the thousand_separators string is interpreted as a separator. Note that this implies that the optional thousands separators may have one character only. |
| [in] | min_value | minimum allowed value for the decoded value. |
| [in] | max_value | maximum allowed value for the decoded value. |
|
inlinestatic |
Format a string containing a std::chrono::duration value, with units. This function returns one single value, e.g. "12345 ms". Use Duration() for a string with hours, minutes, seconds, milliseconds.
| [in] | value | The chrono value to format. |
| [in] | short_format | When true, use short unit format (e.g. "ms"). By default, use a full unit name (e.g. "millisecond"). |
| [in] | separator | Separator string for groups of thousands, a comma by default. |
| [in] | force_sign | If true, force a '+' sign for positive values. |
|
inlinestatic |
Format a string representing a std::chrono::duration value, with hours, minutes, seconds, milliseconds.
| [in] | value | The chrono value to format. |
| [in] | with_days | When true, add a number of days when necessary. By default, use number of hours above 24. |
|
inlinestatic |
Format the name of an instance of std::chrono::duration.
| DURATION | An instance of std::chrono::duration. |
| [in] | short_format | When true, use short unit format (e.g. "ms"). By default, use a full unit name (e.g. "millisecond"). |
| [in] | plural | When true, use the plural form (full unit name only, e.g. "milliseconds"). |
|
static |
Format the name of an instance of std::chrono::duration based on its ratio values.
| [in] | num | Ratio numerator. |
| [in] | den | Ratio denominator. |
| [in] | short_format | When true, use short unit format (e.g. "ms"). By default, use a full unit name (e.g. "millisecond"). |
| [in] | plural | When true, use the plural form (full unit name only, e.g. "milliseconds"). |
Format a string using a template and arguments.
The formatted string is appended to this string object.
This method is similar in principle to printf(). The fmt paramter is used as a format or template where sequences starting with '%' are place-holders for arguments. The main different with printf() is that the argument list is typed, thanks to C++ features. Thus, the risk of mismatch or crash is eliminated. When a '%' sequence is formatted, the presence and type of the corresponding argument is known. For this reason, the syntax of the '%' sequences is simplified.
The available '%' sequences are:
%s : String. Treated as %d if the argument is an integer. Print true or false if the argument is a bool. With std::chrono::duration value, add the unit (e.g. "seconds", "milliseconds", etc.)%c : Character. Use integer argument as Unicode code point. Treated as %s if the argument is a string.%d : Integer in decimal. Treated as %s if the argument is a string. If argument os a fixed point value, print its integral part.%x : Integer in lowercase hexadecimal. Treated as %s if the argument is a string.%X : Integer in uppercase hexadecimal. Treated as %s if the argument is a string.%n : Integer in "normalized" hexadecimal and decimal format. Equivalent to 0xX (%<d). Treated as %s if the argument is a string.%f : Floating or fixed point value. Treated as %s if the argument is a string.%% : Insert a literal %.The allowed options, between the '%' and the letter are, in this order:
< : Reuse previous argument value, do not advance in argument list.- : Left-justified (right-justified by default).+ : Force a '+' sign with positive decimal integers or floating point values (%d or %f only).0 : Zero padding for integers. This is the default with %x and %X.%x or %X, the default width is the "natural" width of the parameter (e.g. 8 digits for a uint32_t value without thousands separator).. digits : Starting with a dot. Maximum field width for strings or precision for floating point values. Ignored for integers.' : For integer conversions, use a separator for groups of thousands.! : Short format. With std::chrono::duration value, use "ms" instead of "milliseconds", etc.* : Can be used instead of digits. The integer value is taken from the argument list.The field width is limited to MAX_FIELD_WIDTH characters.
Since the argument list is typed, it is possible to mix integers and strings of various types and sizes. Example:
displays:
Incorrect format specifiers are silently ignored. Extraneous or missing parameters are also silently ignored. Incorrect types are fixed when possible. To report all these discrepancies, define the environment variable TSDUCK_FORMAT_DEBUG and error messages will be reported on standard error.
Sample incorrect formats or combination of arguments:
To report errors which are otherwise silently fixed:
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
Format a string using a template and arguments. The formatted string is appended to this string object.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlinestatic |
Format a string using a template and arguments.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlinestatic |
Format a string using a template and arguments.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inline |
Scan this string for integer or character values using a template and arguments.
This method is similar in principle to scanf(). The fmt paramter is used as a format or template where sequences starting with '%' are place-holders for arguments. The main different with scanf() is that the argument list is typed, thanks to C++ features. Thus, the risk of mismatch or crash is eliminated. When a '%' sequence is matched, the presence and type of the corresponding argument is known. For this reason, the syntax of the '%' sequences is simplified.
All spaces in the input string are ignored. A sequence of space characters only forces a separation between two fields. Other characters in fmt, outside '' sequences, must match the corresponding character in the input string. Scanning the input string stops when a match fails.
The available '%' sequences are:
%d : Matches an integer in decimal or hexadecimal. If the field starts with 0x or 0X, the value is interpreted as hexadecimal. Decimal otherwise.%i : Same as %d.%x : Matches an integer in hexadecimal, case-insensitive, without 0x or 0X prefix.%X : Same as %x.%f : Matches a floating point value.%c : Matches the next non-space character. The Unicode code point is returned.%% : Matches a literal %.The allowed options, between the '%' and the letter are, in this order:
' : For decimal integer conversions, ignore separator for groups of thousands.| [out] | extracted_count | The number of successfully extracted values. |
| [out] | end_index | The index in this string after the last extracted value. |
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of output arguments to receive extracted values. The args list is built from pointers to integer data of any size, signed or unsigned. |
|
inline |
Scan this string for integer or character values using a template and arguments.
| [out] | extracted_count | The number of successfully extracted values. |
| [out] | end_index | The index in this string after the last extracted value. |
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of output arguments to receive extracted values. The args list is built from pointers to integer data of any size, signed or unsigned. |
Scan this string for integer or character values using a template and arguments.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of output arguments to receive extracted values. The args list is built from pointers to integer data of any size, signed or unsigned. |
|
inline |
Scan this string for integer or character values using a template and arguments.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of output arguments to receive extracted values. The args list is built from pointers to integer data of any size, signed or unsigned. |
|
static |
Build a multi-line string containing the hexadecimal dump of a memory area.
| [in] | data | Starting address of the memory area to dump. |
| [in] | size | Size in bytes of the memory area to dump. |
| [in] | flags | A combination of option flags indicating how to format the data. This is typically the result of or'ed values from the enum type HexaFlags. |
| [in] | indent | Each line is indented by this number of characters. |
| [in] | line_width | Maximum number of characters per line. If the flag BPL is specified, line_width is interpreted as the number of displayed byte values per line. |
| [in] | init_offset | If the flag OFFSET is specified, an offset in the memory area is displayed at the beginning of each line. In this case, init_offset specified the offset value for the first byte. |
| [in] | inner_indent | Add this indentation before hexa/ascii dump, after offset. |
|
static |
Build a multi-line string containing the hexadecimal dump of a memory area.
| [in] | bb | Byte block to dump. |
| [in] | flags | A combination of option flags indicating how to format the data. This is typically the result of or'ed values from the enum type HexaFlags. |
| [in] | indent | Each line is indented by this number of characters. |
| [in] | line_width | Maximum number of characters per line. If the flag BPL is specified, line_width is interpreted as the number of displayed byte values per line. |
| [in] | init_offset | If the flag OFFSET is specified, an offset in the memory area is displayed at the beginning of each line. In this case, init_offset specified the offset value for the first byte. |
| [in] | inner_indent | Add this indentation before hexa/ascii dump, after offset. |
| void ts::UString::appendDump | ( | const void * | data, |
| size_type | size, | ||
| uint32_t | flags = HEXA, | ||
| size_type | indent = 0, | ||
| size_type | line_width = DEFAULT_HEXA_LINE_WIDTH, | ||
| size_type | init_offset = 0, | ||
| size_type | inner_indent = 0 ) |
Append a multi-line string containing the hexadecimal dump of a memory area.
| [in] | data | Starting address of the memory area to dump. |
| [in] | size | Size in bytes of the memory area to dump. |
| [in] | flags | A combination of option flags indicating how to format the data. This is typically the result of or'ed values from the enum type HexaFlags. |
| [in] | indent | Each line is indented by this number of characters. |
| [in] | line_width | Maximum number of characters per line. If the flag BPL is specified, line_width is interpreted as the number of displayed byte values per line. |
| [in] | init_offset | If the flag OFFSET is specified, an offset in the memory area is displayed at the beginning of each line. In this case, init_offset specified the offset value for the first byte. |
| [in] | inner_indent | Add this indentation before hexa/ascii dump, after offset. |
| void ts::UString::appendDump | ( | const ByteBlock & | bb, |
| uint32_t | flags = HEXA, | ||
| size_type | indent = 0, | ||
| size_type | line_width = DEFAULT_HEXA_LINE_WIDTH, | ||
| size_type | init_offset = 0, | ||
| size_type | inner_indent = 0 ) |
Append a multi-line string containing the hexadecimal dump of a memory area.
| [in] | bb | Byte block to dump. |
| [in] | flags | A combination of option flags indicating how to format the data. This is typically the result of or'ed values from the enum type HexaFlags. |
| [in] | indent | Each line is indented by this number of characters. |
| [in] | line_width | Maximum number of characters per line. If the flag BPL is specified, line_width is interpreted as the number of displayed byte values per line. |
| [in] | init_offset | If the flag OFFSET is specified, an offset in the memory area is displayed at the beginning of each line. In this case, init_offset specified the offset value for the first byte. |
| [in] | inner_indent | Add this indentation before hexa/ascii dump, after offset. |
| bool ts::UString::hexaDecode | ( | ByteBlock & | result, |
| bool | c_style = false ) const |
Interpret this string as a sequence of hexadecimal digits (ignore blanks).
| [out] | result | Decoded bytes. |
| [in] | c_style | If true, allow "C-style" aggregate (ignore commas, braces and "0x"). |
| bool ts::UString::hexaDecodeAppend | ( | ByteBlock & | result, |
| bool | c_style = false ) const |
Interpret this string as a sequence of hexadecimal digits (ignore blanks).
| [in,out] | result | The decoded bytes are added at the end of the previous content. |
| [in] | c_style | If true, allow "C-style" aggregate (ignore commas, braces and "0x"). |
|
static |
Append an array of C-strings to a container of strings. All C-strings from an array are appended at the end of a container. The argc / argv pair is typically received by a main program from a command line.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString. |
| [in] | argc | The number of C-strings in argv. |
| [in] | argv | An array of C-strings. |
|
inlinestatic |
Append an array of C-strings to a container of strings. All C-strings from an array are appended at the end of a container. The argc / argv pair is typically received by a main program from a command line.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [in,out] | container | A container of UString. |
| [in] | argc | The number of C-strings in argv. |
| [in] | argv | An array of C-strings. |
|
inlinestatic |
Assign an array of C-strings to a container of strings. The container is assigned using all C-strings from an array. The argc / argv pair is typically received by a main program from a command line.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString. |
| [in] | argc | The number of C-strings in argv. |
| [in] | argv | An array of C-strings. |
|
inlinestatic |
Assign an array of C-strings to a container of strings. The container is assigned using all C-strings from an array. The argc / argv pair is typically received by a main program from a command line.
| CONTAINER | A container class of UString as defined by the C++ Standard Template Library (STL). |
| [out] | container | A container of UString. |
| [in] | argc | The number of C-strings in argv. |
| [in] | argv | An array of C-strings. |
|
staticconstexpr |
The 3-byte so-called "UTF-8 Byte Order Mark".
|
staticconstexpr |
Size in bytes of the so-called "UTF-8 Byte Order Mark".
|
staticconstexpr |
Maximum size in bytes of an UTF-8 encoded character.
|
staticconstexpr |
End-of-line sequence for the operating system.
|
staticconstexpr |
Default separator string for groups of thousands, a comma.
|
staticconstexpr |
Default line width for the Hexa() family of methods.
|
staticconstexpr |
The default list of characters to be protected by quoted().
|
staticconstexpr |
The default list of acceptable quote characters.
|
staticconstexpr |
Maximum allowed field width in format strings.