|
libcrn
3.9.5
A document image processing library
|
A UTF32 character string class. More...
#include <CRNString.h>
Inheritance diagram for crn::String:
Collaboration diagram for crn::String:Public Member Functions | |
| String ()=default | |
| Default constructor (empty string) More... | |
| virtual | ~String () override=default |
| String (const std::u32string &s) | |
| Constructor from a std wide string. More... | |
| String (std::u32string &&s) noexcept | |
| Constructor from a std wide string. More... | |
| String (char32_t *s) | |
| Constructor from a wide cstring. More... | |
| String (const char32_t *s) | |
| Constructor from a wide cstring. More... | |
| String (const String &s) | |
| Copy constructor. More... | |
| String (char32_t c, size_t n=1) | |
| Constructor from a wide char. More... | |
| String (const StringUTF8 &s) | |
| Constructor from a UTF8 string. More... | |
| String (const Prop3 &p) | |
| Constructor from a Prop3. More... | |
| String (char *s) | |
| Constructor from a cstring. More... | |
| String (const char *s) | |
| Constructor from a cstring. More... | |
| String (const std::string &s) | |
| Constructor from a std string. More... | |
| String (char c, size_t n=1) | |
| Constructor from a char. More... | |
| String (int i) | |
| Constructor from an int. More... | |
| String (unsigned int i) | |
| Constructor from an unsigned int. More... | |
| String (long i) | |
| Constructor from an long. More... | |
| String (unsigned long i) | |
| Constructor from an unsigned long. More... | |
| String (float f) | |
| Constructor from a float. More... | |
| String (double d) | |
| Constructor from a double. More... | |
| String (long double d) | |
| Constructor from a long double. More... | |
| String (long long i) | |
| Constructor from an long. More... | |
| String (unsigned long long i) | |
| Constructor from an unsigned long. More... | |
| template<typename T > | |
| String (const std::complex< T > &c) | |
| Constructor from a complex. More... | |
| String (String &&)=default | |
| String & | operator= (String &&)=default |
| std::u32string & | Std ()&noexcept |
| Conversion to std u32string. More... | |
| const std::u32string & | Std () const &noexcept |
| Conversion to std u32string. More... | |
| std::u32string | Std ()&& |
| Conversion to std u32string. More... | |
| const char32_t * | CWStr () const noexcept |
| Conversion to wide cstring. More... | |
| const char * | CStr () const |
| Conversion to UTF8 cstring. More... | |
| Prop3 | ToProp3 () const |
| Conversion to Prop3. More... | |
| int | ToInt () const |
| Conversion to int. More... | |
| unsigned int | ToUInt () const |
| Conversion to unsigned int. More... | |
| long | ToLong () const |
| Conversion to long. More... | |
| unsigned long | ToULong () const |
| Conversion to unsigned long. More... | |
| float | ToFloat () const |
| Conversion to float. More... | |
| double | ToDouble () const |
| Conversion to double. More... | |
| long double | ToLongDouble () const |
| Conversion to long double. More... | |
| long long | ToLongLong () const |
| Conversion to long long. More... | |
| unsigned long long | ToULongLong () const |
| Conversion to unsigned long long. More... | |
| int64_t | ToInt64 () const |
| Conversion to int64_t. More... | |
| uint64_t | ToUInt64 () const |
| Conversion to uint64_t. More... | |
| size_t | Size () const noexcept |
| Returns the length of the string. More... | |
| size_t | Length () const noexcept |
| Returns the length of the string. More... | |
| bool | operator! () const noexcept |
| Checks if the string is empty. More... | |
| bool | IsEmpty () const noexcept |
| Checks if the string is empty. More... | |
| bool | IsNotEmpty () const noexcept |
| Checks if the string is not empty. More... | |
| char32_t & | operator[] (size_t index) |
| Access to a character. More... | |
| const char32_t & | operator[] (size_t index) const |
| Access to a character. More... | |
| String & | operator= (const String &s) |
| Copies from another string. More... | |
| String & | operator+= (const String &s) |
| Appends a string. More... | |
| String & | Insert (size_t pos, const String &s) |
| Inserts a string. More... | |
| String & | Crop (size_t pos, size_t n=0) |
| Crops the string. More... | |
| String & | Erase (size_t pos, size_t n=0) |
| Erases a part of the string. More... | |
| String & | Replace (const String &s, size_t pos, size_t n=0) |
| Replaces a part of the string. More... | |
| String & | ReplaceSuffix (const String &old_suffix, const String &new_suffix) |
| Replaces suffix by another pattern if present. More... | |
| String & | ReplaceSuffix (const size_t n, const String &new_suffix) |
| Replaces last characters of the string by a given pattern. More... | |
| String & | DeleteSuffix (const String &suffix) |
| Delete suffix if found. More... | |
| std::vector< String > | WhichSuffixes (const std::vector< String > &suffixes) const |
| Returns suffixes found within a collection. More... | |
| std::vector< String > | WhichPrefixes (const std::vector< String > &prefixes) const |
| Returns prefixes found within a collection. More... | |
| std::vector< String > | WhichSubstrings (const std::vector< String > &substrings) const |
| Returns substring found within a collection. More... | |
| String & | Replace (char32_t from, char32_t to) |
| Replaces all occurrences of a character with another. More... | |
| String & | ToUpper () |
| Converts the string to uppercase. More... | |
| String & | FirstCharacterToUpper () |
| Converts the first character of string to uppercase. More... | |
| String & | ToLower () |
| Converts the string to lowercase. More... | |
| String | SubString (size_t pos, size_t n=0) const |
| Extracts a part of the string. More... | |
| size_t | Find (const String &s, size_t from_pos=0) const |
| Finds the first occurrence of a string. More... | |
| size_t | FindAnyOf (const String &s, size_t from_pos=0) const |
| Finds the first occurrence of character in a list. More... | |
| size_t | FindNotOf (const String &s, size_t from_pos=0) const |
| Finds the first occurrence of character not in a list. More... | |
| size_t | BackwardFind (const String &s, size_t last_pos=NPos()) const |
| Finds the last occurrence of a string. More... | |
| size_t | BackwardFindAnyOf (const String &s, size_t from_pos=NPos()) const |
| Finds the last occurrence of character in a list. More... | |
| size_t | BackwardFindNotOf (const String &s, size_t from_pos=NPos()) const |
| Finds the last occurrence of character not in a list. More... | |
| bool | StartsWith (const String &s) const |
| Check if string has a given prefix. More... | |
| bool | EndsWith (const String &s) const |
| Check if string has a given suffix. More... | |
| bool | EndsWith (const std::vector< String > &suffixes) const |
| Check if string has suffix among some given ones. More... | |
| std::vector< String > | Split (const String &sep) const |
| Splits the string in multiple strings delimited by a set of separators. More... | |
| int | EditDistance (const String &s) const |
| Edit distance. More... | |
| void | ShrinkToFit () |
| Optimizes the memory usage. More... | |
| void | Swap (String &str) noexcept |
| Swaps two strings. More... | |
| void | Deserialize (xml::Element &el) |
| Initializes the object from an XML element. Unsafe. More... | |
| xml::Element | Serialize (xml::Element &parent) const |
| Dumps the object to an XML element. Unsafe. More... | |
Public Member Functions inherited from crn::Object | |
| virtual | ~Object ()=default |
Static Public Member Functions | |
| static int & | Precision () noexcept |
| Precision of the floating point conversion. More... | |
| static size_t | NPos () noexcept |
| Last position in a string. More... | |
| static String | CreateUniqueId (size_t len=8) |
| Generates an almost unique id. More... | |
A UTF32 character string class.
class String Convenience UTF32 string class.
Definition at line 61 of file CRNString.h.
|
default |
Default constructor (empty string)
|
overridevirtualdefault |
|
inline |
Constructor from a std wide string.
Definition at line 71 of file CRNString.h.
|
inlinenoexcept |
Constructor from a std wide string.
Definition at line 73 of file CRNString.h.
|
inline |
Constructor from a wide cstring.
Definition at line 75 of file CRNString.h.
|
inline |
Constructor from a wide cstring.
Definition at line 77 of file CRNString.h.
|
inline |
Copy constructor.
Definition at line 79 of file CRNString.h.
| String::String | ( | char32_t | c, |
| size_t | n = 1 |
||
| ) |
Constructor from a wide char.
Constructor from a character
| [in] | c | the character to use |
| [in] | n | the number of characters to add |
Definition at line 58 of file CRNString.cpp.
| String::String | ( | const StringUTF8 & | s | ) |
Constructor from a UTF8 string.
Constructor from an UTF8 string
| [in] | s | the string to convert |
Definition at line 68 of file CRNString.cpp.
| String::String | ( | const Prop3 & | p | ) |
Constructor from a Prop3.
Constructor from a Prop3
| [in] | p | the Prop3 to convert |
Definition at line 77 of file CRNString.cpp.
| String::String | ( | char * | s | ) |
Constructor from a cstring.
Constructor from a cstring
| [in] | s | the string to convert |
Definition at line 92 of file CRNString.cpp.
| String::String | ( | const char * | s | ) |
Constructor from a cstring.
Constructor from a cstring
| [in] | s | the string to convert |
Definition at line 102 of file CRNString.cpp.
| String::String | ( | const std::string & | s | ) |
Constructor from a std string.
Constructor from a std string
| [in] | s | the string to convert |
Definition at line 112 of file CRNString.cpp.
| String::String | ( | char | c, |
| size_t | n = 1 |
||
| ) |
Constructor from a char.
Constructor from a character
| [in] | c | the character to use |
| [in] | n | the number of characters to add |
Definition at line 123 of file CRNString.cpp.
|
inline |
Constructor from an int.
Definition at line 95 of file CRNString.h.
|
inline |
Constructor from an unsigned int.
Definition at line 97 of file CRNString.h.
|
inline |
Constructor from an long.
Definition at line 99 of file CRNString.h.
|
inline |
Constructor from an unsigned long.
Definition at line 101 of file CRNString.h.
|
inline |
Constructor from a float.
Definition at line 103 of file CRNString.h.
|
inline |
Constructor from a double.
Definition at line 105 of file CRNString.h.
|
inline |
Constructor from a long double.
Definition at line 107 of file CRNString.h.
|
inline |
Constructor from an long.
Definition at line 109 of file CRNString.h.
|
inline |
Constructor from an unsigned long.
Definition at line 111 of file CRNString.h.
|
inline |
Constructor from a complex.
Definition at line 113 of file CRNString.h.
|
default |
Finds the last occurrence of a string.
Finds the last occurrence of a string
| ExceptionDomain | index out of bounds |
| [in] | s | the string to search |
| [in] | last_pos | the position of the beginning, NPos for the end. |
Definition at line 651 of file CRNString.cpp.
Finds the last occurrence of character in a list.
Finds the last occurrence of a character in a list
| ExceptionDomain | index out of bounds |
| [in] | s | the list |
| [in] | last_pos | the position of the beginning, NPos for the end. |
Definition at line 674 of file CRNString.cpp.
Finds the last occurrence of character not in a list.
Finds the last occurrence of a character not in a list
| ExceptionDomain | index out of bounds |
| [in] | s | the list |
| [in] | last_pos | the position of the beginning, NPos for the end. |
Definition at line 695 of file CRNString.cpp.
|
static |
Generates an almost unique id.
Generates an almost unique id
| [in] | len | the length of the string |
Definition at line 799 of file CRNString.cpp.
| String & String::Crop | ( | size_t | pos, |
| size_t | n = 0 |
||
| ) |
Crops the string.
Crops the string
| [in] | pos | the position of the beginning |
| [in] | n | the number of characters to keep. 0 for all remaining characters. |
Definition at line 247 of file CRNString.cpp.
| const char * String::CStr | ( | ) | const |
Conversion to UTF8 cstring.
Conversion to a cstring
Definition at line 167 of file CRNString.cpp.
|
inlinenoexcept |
Conversion to wide cstring.
Definition at line 128 of file CRNString.h.
Delete suffix if found.
Delete suffix if found
| ExceptionInvalidArgument | null suffix to delete |
| [in] | suffix | the suffix to be dropped |
Definition at line 354 of file CRNString.cpp.
| void String::Deserialize | ( | xml::Element & | el | ) |
Initializes the object from an XML element. Unsafe.
Initializes the object from an XML element. Unsafe.
| ExceptionInvalidArgument | not a String |
| ExceptionDomain | no CDATA found |
| [in] | el | the XML element to read |
Definition at line 738 of file CRNString.cpp.
| int String::EditDistance | ( | const String & | s | ) | const |
Edit distance.
Edit distance
| [in] | s | the string to compare |
Definition at line 714 of file CRNString.cpp.
| bool String::EndsWith | ( | const String & | s | ) | const |
Check if string has a given suffix.
Check if string ends with a certain suffix
| [in] | s | the suffix to be searched |
Definition at line 562 of file CRNString.cpp.
| bool String::EndsWith | ( | const std::vector< String > & | suffixes | ) | const |
Check if string has suffix among some given ones.
Check if string ends with a suffix in a given collection
| [in] | suffixes | the suffix to be searched |
Definition at line 587 of file CRNString.cpp.
| String & String::Erase | ( | size_t | pos, |
| size_t | n = 0 |
||
| ) |
Erases a part of the string.
Erases a part of the string
| ExceptionDomain | index out of bounds |
| [in] | pos | the position of the beginning |
| [in] | n | the number of characters to erase. 0 for all remaining characters. |
Definition at line 262 of file CRNString.cpp.
| size_t String::Find | ( | const String & | s, |
| size_t | from_pos = 0 |
||
| ) | const |
Finds the first occurrence of a string.
Finds the first occurrence of a string
| ExceptionDomain | index out of bounds |
| [in] | s | the string to search |
| [in] | from_pos | the position of the beginning |
Definition at line 509 of file CRNString.cpp.
| size_t String::FindAnyOf | ( | const String & | s, |
| size_t | from_pos = 0 |
||
| ) | const |
Finds the first occurrence of character in a list.
Finds the first occurrence of a character in a list
| ExceptionDomain | index out of bounds |
| [in] | s | the list |
| [in] | from_pos | the position of the beginning |
Definition at line 611 of file CRNString.cpp.
| size_t String::FindNotOf | ( | const String & | s, |
| size_t | from_pos = 0 |
||
| ) | const |
Finds the first occurrence of character not in a list.
Finds the first occurrence of a character not in a list
| ExceptionDomain | index out of bounds |
| [in] | s | the list |
| [in] | from_pos | the position of the beginning |
Definition at line 631 of file CRNString.cpp.
| String & String::FirstCharacterToUpper | ( | ) |
Converts the first character of string to uppercase.
Converts first character of the string to uppercase.
Definition at line 481 of file CRNString.cpp.
Inserts a string.
Inserts a string
| ExceptionDomain | index out of bounds |
| [in] | pos | the position of the insertion. 0 for begining, NPos for end. |
| [in] | s | the string to insert |
Definition at line 195 of file CRNString.cpp.
|
inlinenoexcept |
Checks if the string is empty.
Definition at line 166 of file CRNString.h.
|
inlinenoexcept |
Checks if the string is not empty.
Definition at line 168 of file CRNString.h.
|
inlinenoexcept |
Returns the length of the string.
Definition at line 162 of file CRNString.h.
|
staticnoexcept |
Last position in a string.
Last position in a string
Definition at line 47 of file CRNString.cpp.
|
inlinenoexcept |
Checks if the string is empty.
Definition at line 164 of file CRNString.h.
Appends a string.
Definition at line 179 of file CRNString.h.
Copies from another string.
Definition at line 176 of file CRNString.h.
| char32_t & String::operator[] | ( | size_t | index | ) |
Access to a character.
Access to a character
| ExceptionDomain | index out of bounds |
| [in] | index | the index of the character in the string |
Definition at line 137 of file CRNString.cpp.
| const char32_t & String::operator[] | ( | size_t | index | ) | const |
Access to a character.
Access to a character
| ExceptionDomain | index out of bounds |
| [in] | index | the index of the character in the string |
Definition at line 154 of file CRNString.cpp.
|
staticnoexcept |
Precision of the floating point conversion.
Precision of the floating point conversion
Definition at line 38 of file CRNString.cpp.
Replaces a part of the string.
Replaces a part of the string
| ExceptionDomain | index out of bounds |
| [in] | s | the string to insert |
| [in] | pos | the position of the beginning |
| [in] | n | the number of characters to erase. 0 for all remaining characters. |
Definition at line 286 of file CRNString.cpp.
| String & String::Replace | ( | char32_t | from, |
| char32_t | to | ||
| ) |
Replaces all occurrences of a character with another.
Replaces all occurrences of a character with another
| [in] | from | the character to replace |
| [in] | to | the replacement character |
Definition at line 456 of file CRNString.cpp.
Replaces suffix by another pattern if present.
Replaces suffix by another pattern if present
| ExceptionInvalidArgument | null suffix to search |
| [in] | old_suffix | the suffix to be repaced |
| [in] | new_suffix | the new pattern |
Definition at line 304 of file CRNString.cpp.
Replaces last characters of the string by a given pattern.
Replaces last characters by a given pattern
| [in] | n | the number of character to erase at the end of the word |
| [in] | new_suffix | the pattern to append |
Definition at line 332 of file CRNString.cpp.
| xml::Element String::Serialize | ( | xml::Element & | parent | ) | const |
Dumps the object to an XML element. Unsafe.
Dumps the object to an XML element. Unsafe.
| [in] | parent | the parent element to which we will add the new element |
Definition at line 759 of file CRNString.cpp.
| void String::ShrinkToFit | ( | ) |
Optimizes the memory usage.
Optimizes the memory usage
Definition at line 788 of file CRNString.cpp.
|
inlinenoexcept |
Returns the length of the string.
Definition at line 160 of file CRNString.h.
Splits the string in multiple strings delimited by a set of separators.
Splits the string in multiple strings delimited by a set of separators
| [in] | sep | a list of separators |
Definition at line 772 of file CRNString.cpp.
| bool String::StartsWith | ( | const String & | s | ) | const |
Check if string has a given prefix.
Check if string begins with a certain prefix
| [in] | s | the prefix to be searched |
Definition at line 533 of file CRNString.cpp.
|
inlinenoexcept |
Conversion to std u32string.
Definition at line 122 of file CRNString.h.
|
inlinenoexcept |
Conversion to std u32string.
Definition at line 124 of file CRNString.h.
|
inline |
Conversion to std u32string.
Definition at line 126 of file CRNString.h.
| String String::SubString | ( | size_t | pos, |
| size_t | n = 0 |
||
| ) | const |
Extracts a part of the string.
Extracts a part of the string
| ExceptionDomain | index out of bounds |
| [in] | pos | the position of the beginning |
| [in] | n | the number of characters to keep. 0 for all remaining characters. |
Definition at line 220 of file CRNString.cpp.
|
inlinenoexcept |
Swaps two strings.
Definition at line 254 of file CRNString.h.
|
inline |
Conversion to double.
Definition at line 144 of file CRNString.h.
|
inline |
Conversion to float.
Definition at line 142 of file CRNString.h.
|
inline |
Conversion to int.
Definition at line 134 of file CRNString.h.
|
inline |
Conversion to int64_t.
Definition at line 152 of file CRNString.h.
|
inline |
Conversion to long.
Definition at line 138 of file CRNString.h.
|
inline |
Conversion to long double.
Definition at line 146 of file CRNString.h.
|
inline |
Conversion to long long.
Definition at line 148 of file CRNString.h.
| String & String::ToLower | ( | ) |
Converts the string to lowercase.
Converts the string to lowercase.
Definition at line 493 of file CRNString.cpp.
| Prop3 String::ToProp3 | ( | ) | const |
Conversion to Prop3.
Conversion to Prop3
Definition at line 176 of file CRNString.cpp.
|
inline |
Conversion to unsigned int.
Definition at line 136 of file CRNString.h.
|
inline |
Conversion to uint64_t.
Definition at line 154 of file CRNString.h.
|
inline |
Conversion to unsigned long.
Definition at line 140 of file CRNString.h.
|
inline |
Conversion to unsigned long long.
Definition at line 150 of file CRNString.h.
| String & String::ToUpper | ( | ) |
Converts the string to uppercase.
Converts the string to uppercase.
Definition at line 469 of file CRNString.cpp.
Returns prefixes found within a collection.
Returns prefix within a collection (void String if not found)
| [in] | prefixes | collection of prefixes to try |
Definition at line 405 of file CRNString.cpp.
Returns substring found within a collection.
Returns substrings within a collection (void String if not found)
| [in] | substrings | collection of substrings to try |
Definition at line 430 of file CRNString.cpp.
Returns suffixes found within a collection.
Returns suffix within a collection (void String if not found)
| [in] | suffixes | collection of suffixes to try |
Definition at line 380 of file CRNString.cpp.
1.8.6