View of a UTF-8 character string. More...
Public Member Functions | |
| StringView ()=default | |
| Creates a view of an empty string. | |
| StringView (const char *str) ARCCORE_NOEXCEPT | |
| Creates a view from str encoded in UTF-8. str may be null. | |
| StringView (std::string_view str) ARCCORE_NOEXCEPT | |
| Creates a string from str in UTF-8 encoding. | |
| constexpr | StringView (Span< const Byte > str) ARCCORE_NOEXCEPT |
| Creates a string from str in UTF-8 encoding. | |
| constexpr | StringView (const StringView &str)=default |
| Copy constructor. | |
| constexpr StringView & | operator= (const StringView &str)=default |
| Copies the view str into this instance. | |
| StringView & | operator= (const char *str) ARCCORE_NOEXCEPT |
| Creates a view from str encoded in UTF-8. | |
| StringView & | operator= (std::string_view str) ARCCORE_NOEXCEPT |
| Creates a view from str encoded in UTF-8. | |
| constexpr StringView & | operator= (Span< const Byte > str) ARCCORE_NOEXCEPT |
| Creates a view from str encoded in UTF-8. | |
| ~StringView ()=default | |
| Frees resources. | |
| constexpr Span< const Byte > | bytes () const ARCCORE_NOEXCEPT |
| Returns the conversion of the instance in UTF-8 encoding. | |
| constexpr Int64 | length () const ARCCORE_NOEXCEPT |
| Length in bytes of the character string. | |
| constexpr Int64 | size () const ARCCORE_NOEXCEPT |
| Length in bytes of the character string. | |
| constexpr bool | empty () const ARCCORE_NOEXCEPT |
| True if the string is null or empty. | |
| std::string_view | toStdStringView () const ARCCORE_NOEXCEPT |
| Returns an STL view of the current view. | |
| void | writeBytes (std::ostream &o) const |
| Writes the string in UTF-8 format to the stream o. | |
| StringView | subView (Int64 pos) const |
| Substring starting at position pos. | |
| StringView | subView (Int64 pos, Int64 len) const |
| Substring starting at position pos and of length len. | |
Private Attributes | |
| Span< const Byte > | m_v |
Friends | |
| std::ostream & | operator<< (std::ostream &o, const StringView &str) |
| StringView output operator. | |
| bool | operator== (const StringView &a, const StringView &b) |
| Compares two views. | |
| bool | operator!= (const StringView &a, const StringView &b) |
| Compares two Unicode strings. | |
| bool | operator== (const char *a, const StringView &b) |
| Compares two Unicode strings. | |
| bool | operator!= (const char *a, const StringView &b) |
| Compares two Unicode strings. | |
| bool | operator== (const StringView &a, const char *b) |
| Compares two Unicode strings. | |
| bool | operator!= (const StringView &a, const char *b) |
| Compares two Unicode strings. | |
| bool | operator< (const StringView &a, const StringView &b) |
| Compares two Unicode strings. | |
View of a UTF-8 character string.
This class is similar to std::string_view in C++17 in that it only holds a pointer to memory managed by another class. Therefore, instances of this class should not be kept. The main difference lies in the encoding, which must be UTF-8 with this class.
Definition at line 43 of file StringView.h.
|
inline |
Creates a view from str encoded in UTF-8. str may be null.
Definition at line 50 of file StringView.h.
References StringView().
|
inline |
Creates a string from str in UTF-8 encoding.
Definition at line 53 of file StringView.h.
Creates a string from str in UTF-8 encoding.
Definition at line 56 of file StringView.h.
Returns the conversion of the instance in UTF-8 encoding.
Definition at line 93 of file StringView.h.
Referenced by Arcane::StringVariableReplace::_countChar(), Arcane::Convert::Impl::StringViewToDoubleConverter::_getDoubleValueWithFromChars(), Arcane::StringVariableReplace::_splitString(), Arcane::MeshUtils::dumpSynchronizerTopologyJSON(), Arcane::ParameterOptionAddr::ParameterOptionAddr(), and Arcane::StringVariableReplace::replaceWithCmdLineArgs().
|
inlineconstexpr |
True if the string is null or empty.
Definition at line 102 of file StringView.h.
References size().
Referenced by Arcane::builtInGetValue(), Arcane::StringVariableReplace::replaceWithCmdLineArgs(), Arcane::Accelerator::AcceleratorRuntimeInitialisationInfo::setAcceleratorRuntime(), Arcane::Convert::ScalarType< T >::tryParse(), and Arcane::Convert::ScalarType< T >::tryParseIfNotEmpty().
|
inlineconstexpr |
Length in bytes of the character string.
Definition at line 96 of file StringView.h.
Referenced by Arcane::StringVariableReplace::_splitString(), and subView().
|
inline |
Creates a view from str encoded in UTF-8.
Definition at line 63 of file StringView.h.
References operator=(), and StringView().
|
inlineconstexpr |
Creates a view from str encoded in UTF-8.
Definition at line 75 of file StringView.h.
References StringView().
|
inline |
Creates a view from str encoded in UTF-8.
Definition at line 69 of file StringView.h.
References StringView().
|
inlineconstexpr |
Length in bytes of the character string.
Definition at line 99 of file StringView.h.
Referenced by Arcane::Convert::Impl::StringViewToDoubleConverter::_getDoubleValue(), empty(), and Arcane::Convert::ScalarType< Int32 >::tryParse().
| StringView Arcane::StringView::subView | ( | Int64 | pos | ) | const |
Substring starting at position pos.
Definition at line 36 of file StringView.cc.
References length(), StringView(), and subView().
Referenced by Arcane::StringVariableReplace::_splitString(), Arcane::ParameterOptionElementsCollection::addParameter(), Arcane::ParameterOptionAddr::ParameterOptionAddr(), and subView().
| StringView Arcane::StringView::subView | ( | Int64 | pos, |
| Int64 | len ) const |
Substring starting at position pos and of length len.
Definition at line 45 of file StringView.cc.
References StringView().
|
inline |
Returns an STL view of the current view.
Definition at line 109 of file StringView.h.
Referenced by operator<, and operator==.
| void Arcane::StringView::writeBytes | ( | std::ostream & | o | ) | const |
Writes the string in UTF-8 format to the stream o.
Definition at line 27 of file StringView.cc.
Referenced by operator<<.
|
friend |
Compares two Unicode strings.
| true | if they are different, |
| false | if they are equal. \relate String |
Definition at line 149 of file StringView.h.
References operator==, and StringView().
|
friend |
Compares two Unicode strings.
| true | if they are different, |
| false | if they are equal. \relate String |
Definition at line 165 of file StringView.h.
References operator==, and StringView().
|
friend |
Compares two Unicode strings.
| true | if they are different, |
| false | if they are equal. \relate String |
Definition at line 130 of file StringView.h.
References operator==, and StringView().
|
friend |
Compares two Unicode strings.
| true | if a<b |
| false | otherwise. \relate String |
Definition at line 93 of file StringView.cc.
References StringView(), and toStdStringView().
|
friend |
StringView output operator.
Definition at line 56 of file StringView.cc.
References operator<<, StringView(), and writeBytes().
Referenced by operator<<.
|
friend |
Compares two Unicode strings.
| true | if they are equal, |
| false | otherwise. \relate String |
Definition at line 77 of file StringView.cc.
References operator==, and StringView().
|
friend |
Compares two Unicode strings.
| true | if they are equal, |
| false | otherwise. \relate String |
Definition at line 85 of file StringView.cc.
References operator==, and StringView().
|
friend |
Compares two views.
| true | if they are equal, |
| false | otherwise. |
Definition at line 66 of file StringView.cc.
References operator==, StringView(), and toStdStringView().
Referenced by operator!=, operator!=, operator!=, operator==, operator==, and operator==.
Definition at line 191 of file StringView.h.