Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::String Class Reference

Unicode character string. More...

#include <arccore/base/String.h>

Public Member Functions

 String ()
 Creates a null string.
 String (const char *str)
 Creates a string from str in UTF-8 encoding.
 String (char *str)
 Creates a string from str in UTF-8 encoding.
 String (const char *str, bool do_alloc)
 Creates a string from str in UTF-8 encoding.
 String (const char *str, Integer len)
 Creates a string from str in UTF-8 encoding.
 String (std::string_view str)
 Creates a string from str in UTF-8 encoding.
 String (StringView str)
 Creates a string from str in UTF-8 encoding.
 String (const std::string &str)
 Creates a string from str in UTF-8 encoding.
 String (const UCharConstArrayView &ustr)
 Creates a string from str in UTF-16 encoding.
 String (const Span< const Byte > &ustr)
 Creates a string from str in UTF-8 encoding.
 String (StringImpl *impl)
 Creates a string from str in UTF-8 encoding.
 String (const String &str)
 Creates a string from str.
 String (String &&str)
 Creates a string from str.
Stringoperator= (const String &str)
 Copies str into this instance.
Stringoperator= (String &&str)
 Copies str into this instance.
Stringoperator= (StringView str)
 Copies str into this instance.
Stringoperator= (const char *str)
 References str encoded in UTF-8 in this instance.
Stringoperator= (std::string_view str)
 Copies str encoded in UTF-8 into this instance.
Stringoperator= (const std::string &str)
 Copies str encoded in UTF-8 into this instance.
 ~String ()
 Frees resources.
 operator StringView () const
 Returns a view of the current string.
ConstArrayView< UCharutf16 () const
 Returns the conversion of the instance into UTF-16 encoding.
ByteConstArrayView utf8 () const
 Returns the conversion of the instance into UTF-8 encoding.
Span< const Bytebytes () const
 Returns the conversion of the instance into UTF-8 encoding.
const char * localstr () const
 Returns the conversion of the instance into UTF-8 encoding.
std::string_view toStdStringView () const
 Returns an STL view of the current string.
StringView view () const
 Returns a view of the current string.
String clone () const
 Clones this string.
String upper () const
 Transforms all characters in the string to uppercase.
String lower () const
 Transforms all characters in the string to lowercase.
bool null () const
 Returns true if the string is null.
Integer len () const
 Returns the length of the string in 32 bits.
Int64 length () const
 Returns the length of the string.
bool empty () const
 True if the string is empty (null or "").
Int32 hashCode () const
 Calculates a hash value for this character string.
void writeBytes (std::ostream &o) const
 Writes the string in UTF-8 format to the stream o.
String operator+ (const char *str) const
String operator+ (std::string_view str) const
String operator+ (const std::string &str) const
String operator+ (const String &str) const
String operator+ (unsigned long v) const
String operator+ (unsigned int v) const
String operator+ (double v) const
String operator+ (long double v) const
String operator+ (int v) const
String operator+ (long v) const
String operator+ (unsigned long long v) const
String operator+ (long long v) const
String operator+ (const APReal &v) const
bool contains (const String &s) const
 Indicates if the string contains s.
bool startsWith (const String &s) const
 Indicates if the string starts with the characters of s.
bool endsWith (const String &s) const
 Indicates if the string ends with the characters of s.
String substring (Int64 pos) const
 Substring starting at position pos.
String substring (Int64 pos, Int64 len) const
 Substring starting at position pos and of length len.
template<typename StringContainer>
void split (StringContainer &str_array, char c) const
 Splits the string based on the character c.
void internalDump (std::ostream &ostr) const
 Displays the internal information of the class.

Static Public Member Functions

static String fromUtf8 (Span< const Byte > bytes)
static String replaceWhiteSpace (const String &rhs)
 Performs whitespace character normalization.
static String collapseWhiteSpace (const String &rhs)
 Performs whitespace character normalization.
static String fromNumber (unsigned long v)
static String fromNumber (unsigned int v)
static String fromNumber (double v)
static String fromNumber (double v, Integer nb_digit_after_point)
static String fromNumber (long double v)
static String fromNumber (int v)
static String fromNumber (long v)
static String fromNumber (unsigned long long v)
static String fromNumber (long long v)
static String fromNumber (const APReal &v)
static String format (const String &str)
static String format (const String &str, const StringFormatterArg &arg1)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3, const StringFormatterArg &arg4)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3, const StringFormatterArg &arg4, const StringFormatterArg &arg5)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3, const StringFormatterArg &arg4, const StringFormatterArg &arg5, const StringFormatterArg &arg6)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3, const StringFormatterArg &arg4, const StringFormatterArg &arg5, const StringFormatterArg &arg6, const StringFormatterArg &arg7)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3, const StringFormatterArg &arg4, const StringFormatterArg &arg5, const StringFormatterArg &arg6, const StringFormatterArg &arg7, const StringFormatterArg &arg8)
static String format (const String &str, const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3, const StringFormatterArg &arg4, const StringFormatterArg &arg5, const StringFormatterArg &arg6, const StringFormatterArg &arg7, const StringFormatterArg &arg8, const StringFormatterArg &arg9)
static String concat (const StringFormatterArg &arg1)
static String concat (const StringFormatterArg &arg1, const StringFormatterArg &arg2)
static String concat (const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3)
static String concat (const StringFormatterArg &arg1, const StringFormatterArg &arg2, const StringFormatterArg &arg3, const StringFormatterArg &arg4)
static String plural (const Integer n, const String &str, const bool with_number=true)
 Standard plural form by adding an 's'.
static String plural (const Integer n, const String &str, const String &str2, const bool with_number=true)
 Special plural form by variant.
static String join (String delim, ConstArrayView< String > strs)

Friends

class StringBuilder
class StringUtilsImpl
bool operator< (const String &a, const String &b)
bool operator== (const String &a, const String &b)
 Compares two unicode strings.
bool operator!= (const String &a, const String &b)
 Compares two unicode strings.
std::ostream & operator<< (std::ostream &o, const String &str)
 String output operator.
std::istream & operator>> (std::istream &o, String &str)
 String input operator.
bool operator== (const char *a, const String &b)
 Compares two unicode strings.
bool operator!= (const char *a, const String &b)
 Compares two unicode strings.
bool operator== (const String &a, const char *b)
 Compares two unicode strings.
bool operator!= (const String &a, const char *b)
 Compares two unicode strings.
String operator+ (const char *a, const String &b)
 Adds two strings.
bool operator< (const String &a, const String &b)

Detailed Description

Unicode character string.

This class allows managing a character string using either UTF-8 or UTF-16 encoding. Note that UTF-16 encoding is obsolete and will be removed in a later version when C++20 is available.

All methods using const char* as arguments assume that the encoding used is UTF-8.

Instances of this class are immutable.

This class is similar to std::string but with the following differences:

  • The String class uses UTF-8 encoding, whereas for std::string, the encoding is undefined.
  • Unlike std::string, it is currently not possible to preserve null characters inside a String.
  • For String, there is a distinction between a null string and an empty string. The String::String() constructor creates a null string, while String::String("") creates an empty string. If the string is null, calls to view() or toStdStringView() return an empty string.

When C++20 is available, the String class will correspond to the std::optional<std::u8string> type.

For performance reasons, when building a string piece by piece, it is preferable to use the 'StringBuilder' class.

Definition at line 69 of file arccore/src/base/arccore/base/String.h.

Constructor & Destructor Documentation

◆ String() [1/13]

◆ String() [2/13]

Arcane::String::String ( const char * str)
inline

Creates a string from str in UTF-8 encoding.

Warning
Attention, the string is assumed to have infinite constant validity (i.e., it is a compile-time constant string. If the string passed as an argument can be deallocated, use String(std::string_view) instead.

Definition at line 89 of file arccore/src/base/arccore/base/String.h.

◆ String() [3/13]

Arcane::String::String ( char * str)

Creates a string from str in UTF-8 encoding.

Definition at line 127 of file String.cc.

◆ String() [4/13]

Arcane::String::String ( const char * str,
bool do_alloc )

Creates a string from str in UTF-8 encoding.

Definition at line 138 of file String.cc.

◆ String() [5/13]

Arcane::String::String ( const char * str,
Integer len )

Creates a string from str in UTF-8 encoding.

Definition at line 116 of file String.cc.

References len().

◆ String() [6/13]

Arcane::String::String ( std::string_view str)

Creates a string from str in UTF-8 encoding.

Definition at line 59 of file String.cc.

◆ String() [7/13]

Arcane::String::String ( StringView str)

Creates a string from str in UTF-8 encoding.

Definition at line 70 of file String.cc.

References toStdStringView().

◆ String() [8/13]

Arcane::String::String ( const std::string & str)

Creates a string from str in UTF-8 encoding.

Definition at line 48 of file String.cc.

◆ String() [9/13]

Arcane::String::String ( const UCharConstArrayView & ustr)

Creates a string from str in UTF-16 encoding.

Definition at line 82 of file String.cc.

◆ String() [10/13]

Arcane::String::String ( const Span< const Byte > & ustr)

Creates a string from str in UTF-8 encoding.

Definition at line 93 of file String.cc.

◆ String() [11/13]

Arcane::String::String ( StringImpl * impl)
explicit

Creates a string from str in UTF-8 encoding.

Creates a string from str in UTF-8 encoding

Definition at line 104 of file String.cc.

◆ String() [12/13]

Arcane::String::String ( const String & str)

Creates a string from str.

Definition at line 158 of file String.cc.

References String().

◆ String() [13/13]

Arcane::String::String ( String && str)
inline

Creates a string from str.

Definition at line 120 of file arccore/src/base/arccore/base/String.h.

References String().

◆ ~String()

Arcane::String::~String ( )
inline

Frees resources.

Definition at line 158 of file arccore/src/base/arccore/base/String.h.

Member Function Documentation

◆ bytes()

Span< const Byte > Arcane::String::bytes ( ) const

Returns the conversion of the instance into UTF-8 encoding.

bytes().size() corresponds to the length of the character string but the returned view always contains a terminal '\0'.

Warning
The instance remains the owner of the returned value and this value is invalidated by any modification of this instance.

Definition at line 292 of file String.cc.

Referenced by Arcane::ParameterList::addParameterLine(), endsWith(), hashCode(), Arcane::BasicSerializer::put(), Arcane::MeshReaderMng::readMesh(), Arcane::BasicSerializer::reserve(), startsWith(), writeBytes(), and Arcane::TraceMng::writeDirect().

◆ clone()

String Arcane::String::clone ( ) const

Clones this string.

Definition at line 413 of file String.cc.

References String().

◆ collapseWhiteSpace()

String Arcane::String::collapseWhiteSpace ( const String & rhs)
static

Performs whitespace character normalization.

The behavior is identical to replaceWhiteSpace() plus:

  • replacement of all consecutive whitespaces by a single one.
  • removal of whitespaces at the beginning and end of the string. This corresponds to the xs:collapse attribute of XMLSchema 1.0

Definition at line 453 of file String.cc.

References null(), and String().

◆ concat() [1/4]

String Arcane::String::concat ( const StringFormatterArg & arg1)
static

Definition at line 1018 of file String.cc.

◆ concat() [2/4]

String Arcane::String::concat ( const StringFormatterArg & arg1,
const StringFormatterArg & arg2 )
static

Definition at line 1024 of file String.cc.

◆ concat() [3/4]

String Arcane::String::concat ( const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3 )
static

Definition at line 1031 of file String.cc.

◆ concat() [4/4]

String Arcane::String::concat ( const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3,
const StringFormatterArg & arg4 )
static

Definition at line 1039 of file String.cc.

◆ contains()

bool Arcane::String::contains ( const String & s) const

Indicates if the string contains s.

Definition at line 1078 of file String.cc.

References null(), String(), and toStdStringView().

◆ empty()

◆ endsWith()

bool Arcane::String::endsWith ( const String & s) const

Indicates if the string ends with the characters of s.

Definition at line 1094 of file String.cc.

References bytes(), Arcane::SpanImpl< T, SizeType, Extent >::data(), Arcane::SpanImpl< T, SizeType, Extent >::size(), and String().

Referenced by Arcane::Platform::getLoadedSharedLibraryFullPath().

◆ format() [1/10]

String Arcane::String::format ( const String & str)
static

Definition at line 838 of file String.cc.

◆ format() [2/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1 )
static

Definition at line 847 of file String.cc.

◆ format() [3/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2 )
static

Definition at line 858 of file String.cc.

◆ format() [4/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3 )
static

Definition at line 871 of file String.cc.

◆ format() [5/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3,
const StringFormatterArg & arg4 )
static

Definition at line 886 of file String.cc.

◆ format() [6/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3,
const StringFormatterArg & arg4,
const StringFormatterArg & arg5 )
static

Definition at line 903 of file String.cc.

◆ format() [7/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3,
const StringFormatterArg & arg4,
const StringFormatterArg & arg5,
const StringFormatterArg & arg6 )
static

Definition at line 922 of file String.cc.

◆ format() [8/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3,
const StringFormatterArg & arg4,
const StringFormatterArg & arg5,
const StringFormatterArg & arg6,
const StringFormatterArg & arg7 )
static

Definition at line 943 of file String.cc.

◆ format() [9/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3,
const StringFormatterArg & arg4,
const StringFormatterArg & arg5,
const StringFormatterArg & arg6,
const StringFormatterArg & arg7,
const StringFormatterArg & arg8 )
static

Definition at line 966 of file String.cc.

◆ format() [10/10]

String Arcane::String::format ( const String & str,
const StringFormatterArg & arg1,
const StringFormatterArg & arg2,
const StringFormatterArg & arg3,
const StringFormatterArg & arg4,
const StringFormatterArg & arg5,
const StringFormatterArg & arg6,
const StringFormatterArg & arg7,
const StringFormatterArg & arg8,
const StringFormatterArg & arg9 )
static

Definition at line 991 of file String.cc.

◆ fromNumber() [1/10]

String Arcane::String::fromNumber ( const APReal & v)
static

Definition at line 573 of file String.cc.

◆ fromNumber() [2/10]

String Arcane::String::fromNumber ( double v)
static

Definition at line 537 of file String.cc.

◆ fromNumber() [3/10]

String Arcane::String::fromNumber ( double v,
Integer nb_digit_after_point )
static

Definition at line 579 of file String.cc.

◆ fromNumber() [4/10]

String Arcane::String::fromNumber ( int v)
static

Definition at line 549 of file String.cc.

◆ fromNumber() [5/10]

String Arcane::String::fromNumber ( long double v)
static

Definition at line 543 of file String.cc.

◆ fromNumber() [6/10]

String Arcane::String::fromNumber ( long long v)
static

Definition at line 567 of file String.cc.

◆ fromNumber() [7/10]

String Arcane::String::fromNumber ( long v)
static

Definition at line 555 of file String.cc.

◆ fromNumber() [8/10]

String Arcane::String::fromNumber ( unsigned int v)
static

Definition at line 531 of file String.cc.

◆ fromNumber() [9/10]

String Arcane::String::fromNumber ( unsigned long long v)
static

Definition at line 561 of file String.cc.

◆ fromNumber() [10/10]

String Arcane::String::fromNumber ( unsigned long v)
static

Definition at line 525 of file String.cc.

◆ fromUtf8()

String Arcane::String::fromUtf8 ( Span< const Byte > bytes)
static

Definition at line 711 of file String.cc.

◆ hashCode()

Int32 Arcane::String::hashCode ( ) const

Calculates a hash value for this character string.

Definition at line 734 of file String.cc.

References bytes(), and Arcane::SpanImpl< T, SizeType, Extent >::size().

◆ internalDump()

void Arcane::String::internalDump ( std::ostream & ostr) const

Displays the internal information of the class.

This method is only useful for debugging Arccore

Definition at line 720 of file String.cc.

◆ join()

String Arcane::String::join ( String delim,
ConstArrayView< String > strs )
static

Definition at line 1148 of file String.cc.

◆ len()

Integer Arcane::String::len ( ) const

Returns the length of the string in 32 bits.

Definition at line 329 of file String.cc.

References Arcane::arccoreCheckArraySize(), and toStdStringView().

Referenced by Arcane::dom::DOMImplementation::_load(), split(), String(), and substring().

◆ length()

Int64 Arcane::String::length ( ) const

Returns the length of the string.

Definition at line 339 of file String.cc.

References toStdStringView().

Referenced by Arcane::MessagePassing::namedBarrier(), Arcane::BasicSerializer::put(), Arcane::platform::raiseFloatingException(), split(), and substring().

◆ localstr()

const char * Arcane::String::localstr ( ) const

◆ lower()

String Arcane::String::lower ( ) const

Transforms all characters in the string to lowercase.

Definition at line 479 of file String.cc.

References String().

◆ null()

◆ operator StringView()

Arcane::String::operator StringView ( ) const

Returns a view of the current string.

The encoding used is UTF-8.

Warning
The instance remains the owner of the returned value and this value is invalidated by any modification of this instance. The returned view should not be retained.

Definition at line 381 of file String.cc.

References view().

◆ operator+() [1/13]

String Arcane::String::operator+ ( const APReal & v) const

Definition at line 665 of file String.cc.

◆ operator+() [2/13]

String Arcane::String::operator+ ( const char * str) const
inline

Returns the concatenation of this string with the string str encoded in UTF-8

Definition at line 376 of file arccore/src/base/arccore/base/String.h.

References operator+, and String().

◆ operator+() [3/13]

String Arcane::String::operator+ ( const std::string & str) const

Returns the concatenation of this string with the string str encoded in UTF-8

Definition at line 503 of file String.cc.

References String().

◆ operator+() [4/13]

String Arcane::String::operator+ ( const String & str) const

Returns the concatenation of this string with the string str.

Definition at line 515 of file String.cc.

References String().

◆ operator+() [5/13]

String Arcane::String::operator+ ( double v) const

Definition at line 623 of file String.cc.

◆ operator+() [6/13]

String Arcane::String::operator+ ( int v) const

Definition at line 637 of file String.cc.

◆ operator+() [7/13]

String Arcane::String::operator+ ( long double v) const

Definition at line 630 of file String.cc.

◆ operator+() [8/13]

String Arcane::String::operator+ ( long long v) const

Definition at line 658 of file String.cc.

◆ operator+() [9/13]

String Arcane::String::operator+ ( long v) const

Definition at line 644 of file String.cc.

◆ operator+() [10/13]

String Arcane::String::operator+ ( std::string_view str) const

Returns the concatenation of this string with the string str encoded in UTF-8

Definition at line 491 of file String.cc.

References String().

◆ operator+() [11/13]

String Arcane::String::operator+ ( unsigned int v) const

Definition at line 616 of file String.cc.

◆ operator+() [12/13]

String Arcane::String::operator+ ( unsigned long long v) const

Definition at line 651 of file String.cc.

◆ operator+() [13/13]

String Arcane::String::operator+ ( unsigned long v) const

Definition at line 609 of file String.cc.

◆ operator=() [1/6]

String & Arcane::String::operator= ( const char * str)
inline

References str encoded in UTF-8 in this instance.

Warning
Attention, the string is assumed to have infinite constant validity (i.e., it is a compile-time constant string. If the string passed as an argument can be deallocated, use String::operator=(std::string_view) instead.

Definition at line 142 of file arccore/src/base/arccore/base/String.h.

References String().

◆ operator=() [2/6]

String & Arcane::String::operator= ( const std::string & str)

Copies str encoded in UTF-8 into this instance.

Definition at line 216 of file String.cc.

References operator=(), and String().

◆ operator=() [3/6]

String & Arcane::String::operator= ( const String & str)

Copies str into this instance.

Definition at line 171 of file String.cc.

References String().

Referenced by operator=(), operator=(), and operator=().

◆ operator=() [4/6]

String & Arcane::String::operator= ( std::string_view str)

Copies str encoded in UTF-8 into this instance.

Definition at line 207 of file String.cc.

References operator=(), and String().

◆ operator=() [5/6]

String & Arcane::String::operator= ( String && str)

Copies str into this instance.

Definition at line 184 of file String.cc.

References String().

◆ operator=() [6/6]

String & Arcane::String::operator= ( StringView str)

Copies str into this instance.

Definition at line 198 of file String.cc.

References operator=(), and String().

◆ plural() [1/2]

String Arcane::String::plural ( const Integer n,
const String & str,
const bool with_number = true )
static

Standard plural form by adding an 's'.

Definition at line 1051 of file String.cc.

References plural(), and String().

Referenced by plural().

◆ plural() [2/2]

String Arcane::String::plural ( const Integer n,
const String & str,
const String & str2,
const bool with_number = true )
static

Special plural form by variant.

Definition at line 1066 of file String.cc.

References String().

◆ replaceWhiteSpace()

String Arcane::String::replaceWhiteSpace ( const String & rhs)
static

Performs whitespace character normalization.

All whitespace characters are replaced by space characters #x20, namely #xD (Carriage Return), #xA (Line Feed), and #x9 (Tabulation). This corresponds to the xs:replace attribute of XMLSchema 1.0

Definition at line 441 of file String.cc.

References String().

◆ split()

template<typename StringContainer>
void Arcane::String::split ( StringContainer & str_array,
char c ) const
inline

Splits the string based on the character c.

Definition at line 495 of file arccore/src/base/arccore/base/String.h.

References len(), length(), localstr(), and String().

◆ startsWith()

bool Arcane::String::startsWith ( const String & s) const

Indicates if the string starts with the characters of s.

Definition at line 1110 of file String.cc.

References bytes(), Arcane::SpanImpl< T, SizeType, Extent >::data(), Arcane::SpanImpl< T, SizeType, Extent >::size(), and String().

◆ substring() [1/2]

String Arcane::String::substring ( Int64 pos) const

Substring starting at position pos.

Definition at line 1125 of file String.cc.

References length(), String(), and substring().

Referenced by Arcane::ParameterList::addParameterLine(), and substring().

◆ substring() [2/2]

String Arcane::String::substring ( Int64 pos,
Int64 len ) const

Substring starting at position pos and of length len.

Definition at line 1134 of file String.cc.

References len(), and String().

◆ toStdStringView()

std::string_view Arcane::String::toStdStringView ( ) const

Returns an STL view of the current string.

The encoding used is UTF-8.

Warning
The instance remains the owner of the returned value and this value is invalidated by any modification of this instance. The returned view should not be retained.

Definition at line 349 of file String.cc.

References ARCCORE_FATAL.

Referenced by contains(), len(), length(), Arcane::MeshReaderMng::readMesh(), and String().

◆ upper()

String Arcane::String::upper ( ) const

Transforms all characters in the string to uppercase.

Definition at line 467 of file String.cc.

References String().

◆ utf16()

ConstArrayView< UChar > Arcane::String::utf16 ( ) const

Returns the conversion of the instance into UTF-16 encoding.

The returned array always contains a terminal zero if the string is not null-terminated. Therefore, the size of any non-null string is the array size minus 1.

Warning
The instance remains the owner of the returned value and this value is invalidated by any modification of this instance.
Deprecated
Use StringUtils::asUtf16BE() instead. Note that the StringUtils::asUtf16BE() function does not contain a terminal 0x00.

Definition at line 267 of file String.cc.

◆ utf8()

ByteConstArrayView Arcane::String::utf8 ( ) const

Returns the conversion of the instance into UTF-8 encoding.

The returned array always contains a terminal zero if the string is not null-terminated. Therefore, the size of any non-null string is the array size minus 1.

Warning
The instance remains the owner of the returned value and this value is invalidated by any modification of this instance.

Definition at line 276 of file String.cc.

References Arcane::arccoreCheckArraySize().

◆ view()

StringView Arcane::String::view ( ) const

Returns a view of the current string.

The encoding used is UTF-8.

Warning
The instance remains the owner of the returned value and this value is invalidated by any modification of this instance. The returned view should not be retained.

Definition at line 368 of file String.cc.

Referenced by Arcane::builtInGetValue(), and operator StringView().

◆ writeBytes()

void Arcane::String::writeBytes ( std::ostream & o) const

Writes the string in UTF-8 format to the stream o.

Definition at line 1246 of file String.cc.

References bytes(), Arcane::SpanImpl< T, SizeType, Extent >::data(), and Arcane::SpanImpl< T, SizeType, Extent >::size().

Referenced by operator<<.

◆ operator!= [1/3]

bool operator!= ( const char * a,
const String & b )
friend

Compares two unicode strings.

Return values
trueif they are different,
falseif they are equal.

Definition at line 345 of file arccore/src/base/arccore/base/String.h.

References operator==, and String().

◆ operator!= [2/3]

bool operator!= ( const String & a,
const char * b )
friend

Compares two unicode strings.

Return values
trueif they are different,
falseif they are equal.

Definition at line 362 of file arccore/src/base/arccore/base/String.h.

References operator==, and String().

◆ operator!= [3/3]

bool operator!= ( const String & a,
const String & b )
friend

Compares two unicode strings.

Return values
trueif they are different,
falseif they are equal. \relate String

Definition at line 323 of file arccore/src/base/arccore/base/String.h.

References operator==, and String().

◆ operator+

String operator+ ( const char * a,
const String & b )
friend

Adds two strings.

Definition at line 1219 of file String.cc.

References operator+, and String().

Referenced by operator+, and operator+().

◆ operator< [1/2]

bool operator< ( const String & a,
const String & b )
friend

Definition at line 1204 of file String.cc.

◆ operator< [2/2]

bool operator< ( const String & a,
const String & b )
friend

Definition at line 1204 of file String.cc.

◆ operator<<

std::ostream & operator<< ( std::ostream & o,
const String & str )
friend

String output operator.

Definition at line 1231 of file String.cc.

References localstr(), String(), and writeBytes().

◆ operator== [1/3]

bool operator== ( const char * a,
const String & b )
friend

Compares two unicode strings.

Return values
trueif they are equal,
falseotherwise.

Definition at line 1199 of file String.cc.

References operator==, and String().

◆ operator== [2/3]

bool operator== ( const String & a,
const char * b )
friend

Compares two unicode strings.

Return values
trueif they are equal,
falseotherwise.

Definition at line 1193 of file String.cc.

References operator==, and String().

◆ operator== [3/3]

bool operator== ( const String & a,
const String & b )
friend

Compares two unicode strings.

Return values
trueif they are equal,
falseotherwise. \relate String

Definition at line 1164 of file String.cc.

References Arcane::CStringUtils::isEqual(), operator==, and String().

Referenced by operator!=, operator!=, operator!=, operator==, operator==, and operator==.

◆ operator>>

std::istream & operator>> ( std::istream & o,
String & str )
friend

String input operator.

Definition at line 1258 of file String.cc.

References String().

◆ StringBuilder

friend class StringBuilder
friend

Definition at line 74 of file arccore/src/base/arccore/base/String.h.

◆ StringUtilsImpl

friend class StringUtilsImpl
friend

Definition at line 75 of file arccore/src/base/arccore/base/String.h.


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