ROOT 6.16/01 Reference Guide |
Basic string class.
Cannot be stored in a TCollection... use TObjString instead.
The underlying string is stored as a char* that can be accessed via TString::Data(). TString provides Short String Optimization (SSO) so that short strings (<15 on 64-bit and <11 on 32-bit) are contained in the TString internal data structure without the need for mallocing the required space.
Substring operations are provided by the TSubString class, which holds a reference to the original string and its data, along with the offset and length of the substring. To retrieve the substring as a TString, construct a TString from it, eg:
Classes | |
struct | LongStr_t |
struct | RawStr_t |
struct | Rep_t |
struct | ShortStr_t |
union | UStr_t |
Public Types | |
enum | ECaseCompare { kExact , kIgnoreCase } |
enum | EStripType { kLeading = 0x1 , kTrailing = 0x2 , kBoth = 0x3 } |
Public Member Functions | |
TString () | |
TString default ctor. More... | |
TString (char c) | |
Initialize a string with a single character. More... | |
TString (char c, Ssiz_t s) | |
Initialize the first n locations of a TString with character c. More... | |
TString (const char *s) | |
Create TString and initialize it with string cs. More... | |
TString (const char *s, Ssiz_t n) | |
Create TString and initialize it with the first n characters of cs. More... | |
TString (const std::string &s) | |
Create TString and initialize it with string cs. More... | |
TString (const std::string_view &sub) | |
Copy a std::string_view in a TString. More... | |
TString (const TString &s) | |
Copy constructor. More... | |
TString (const TSubString &sub) | |
Copy a TSubString in a TString. More... | |
TString (Ssiz_t ic) | |
Create TString able to contain ic characters. More... | |
TString (TString &&s) noexcept | |
Move constructor. More... | |
virtual | ~TString () |
Delete a TString. More... | |
TString & | Append (char c, Ssiz_t rep=1) |
Append character c rep times to string. More... | |
TString & | Append (const char *cs) |
TString & | Append (const char *cs, Ssiz_t n) |
TString & | Append (const TString &s) |
TString & | Append (const TString &s, Ssiz_t n) |
Double_t | Atof () const |
Return floating-point value contained in string. More... | |
Int_t | Atoi () const |
Return integer value of string. More... | |
Long64_t | Atoll () const |
Return long long value of string. More... | |
Bool_t | BeginsWith (const char *s, ECaseCompare cmp=kExact) const |
Bool_t | BeginsWith (const TString &pat, ECaseCompare cmp=kExact) const |
Ssiz_t | Capacity () const |
Ssiz_t | Capacity (Ssiz_t n) |
Return string capacity. More... | |
TString & | Chop () |
void | Clear () |
Clear string without changing its capacity. More... | |
int | CompareTo (const char *cs, ECaseCompare cmp=kExact) const |
Compare a string to char *cs2. More... | |
int | CompareTo (const TString &st, ECaseCompare cmp=kExact) const |
Compare a string to another string. More... | |
Bool_t | Contains (const char *pat, ECaseCompare cmp=kExact) const |
Bool_t | Contains (const TRegexp &pat) const |
Bool_t | Contains (const TString &pat, ECaseCompare cmp=kExact) const |
Bool_t | Contains (TPRegexp &pat) const |
TString | Copy () const |
Copy a string. More... | |
Int_t | CountChar (Int_t c) const |
Return number of times character c occurs in the string. More... | |
const char * | Data () const |
Bool_t | EndsWith (const char *pat, ECaseCompare cmp=kExact) const |
Return true if string ends with the specified string. More... | |
Bool_t | EqualTo (const char *cs, ECaseCompare cmp=kExact) const |
Bool_t | EqualTo (const TString &st, ECaseCompare cmp=kExact) const |
virtual void | FillBuffer (char *&buffer) const |
Copy string into I/O buffer. More... | |
Ssiz_t | First (char c) const |
Find first occurrence of a character c. More... | |
Ssiz_t | First (const char *cs) const |
Find first occurrence of a character in cs. More... | |
void | Form (const char *fmt,...) |
Formats a string using a printf style format descriptor. More... | |
Bool_t | Gets (FILE *fp, Bool_t chop=kTRUE) |
Read one line from the stream, including the , or until EOF. More... | |
UInt_t | Hash (ECaseCompare cmp=kExact) const |
Return hash value. More... | |
Ssiz_t | Index (const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const |
Ssiz_t | Index (const char *pat, Ssiz_t patlen, Ssiz_t i, ECaseCompare cmp) const |
Search for a string in the TString. More... | |
Ssiz_t | Index (const TRegexp &pat, Ssiz_t *ext, Ssiz_t i=0) const |
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match. More... | |
Ssiz_t | Index (const TRegexp &pat, Ssiz_t i=0) const |
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match. More... | |
Ssiz_t | Index (const TString &s, Ssiz_t i=0, ECaseCompare cmp=kExact) const |
Ssiz_t | Index (const TString &s, Ssiz_t patlen, Ssiz_t i, ECaseCompare cmp) const |
Ssiz_t | Index (TPRegexp &pat, Ssiz_t *ext, Ssiz_t i=0) const |
Find the first occurrence of the regexp in string and return the position. More... | |
Ssiz_t | Index (TPRegexp &pat, Ssiz_t i=0) const |
Find the first occurrence of the regexp in string and return the position. More... | |
TString & | Insert (Ssiz_t pos, const char *s) |
TString & | Insert (Ssiz_t pos, const char *s, Ssiz_t extent) |
TString & | Insert (Ssiz_t pos, const TString &s) |
TString & | Insert (Ssiz_t pos, const TString &s, Ssiz_t extent) |
Bool_t | IsAlnum () const |
Returns true if all characters in string are alphanumeric. More... | |
Bool_t | IsAlpha () const |
Returns true if all characters in string are alphabetic. More... | |
Bool_t | IsAscii () const |
Returns true if all characters in string are ascii. More... | |
Bool_t | IsBin () const |
Returns true if all characters in string are binary digits (0,1). More... | |
Bool_t | IsDec () const |
Returns true if all characters in string are decimal digits (0-9). More... | |
Bool_t | IsDigit () const |
Returns true if all characters in string are digits (0-9) or white spaces, i.e. More... | |
Bool_t | IsFloat () const |
Returns kTRUE if string contains a floating point or integer number. More... | |
Bool_t | IsHex () const |
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F). More... | |
Bool_t | IsInBaseN (Int_t base) const |
Returns true if all characters in string are expressed in the base specified (range=2-36), i.e. More... | |
Bool_t | IsNull () const |
Bool_t | IsOct () const |
Returns true if all characters in string are octal digits (0-7). More... | |
Bool_t | IsWhitespace () const |
Ssiz_t | Last (char c) const |
Find last occurrence of a character c. More... | |
Ssiz_t | Length () const |
Bool_t | MaybeRegexp () const |
Returns true if string contains one of the regexp characters "^$.[]*+?". More... | |
Bool_t | MaybeWildcard () const |
Returns true if string contains one of the wildcard characters "[]*?". More... | |
TString | MD5 () const |
Return the MD5 digest for this string, in a string representation. More... | |
operator const char * () const | |
operator ROOT::Internal::TStringView () const | |
TSubString | operator() (const TRegexp &re) const |
Return the substring found by applying the regexp. More... | |
TSubString | operator() (const TRegexp &re, Ssiz_t start) const |
Return the substring found by applying the regexp starting at start. More... | |
char & | operator() (Ssiz_t i) |
char | operator() (Ssiz_t i) const |
TSubString | operator() (Ssiz_t start, Ssiz_t len) const |
Return sub-string of string starting at start with length len. More... | |
TSubString | operator() (TPRegexp &re) const |
Return the substring found by applying the regexp. More... | |
TSubString | operator() (TPRegexp &re, Ssiz_t start) const |
Return the substring found by applying the regexp starting at start. More... | |
TString & | operator+= (char c) |
TString & | operator+= (const char *s) |
TString & | operator+= (const TString &s) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type & | operator+= (T f) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsSignedNumeral< T >::value, TString >::type & | operator+= (T i) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type & | operator+= (T u) |
TString & | operator= (char s) |
Assign character c to TString. More... | |
TString & | operator= (const char *s) |
Assign string cs to TString. More... | |
TString & | operator= (const std::string &s) |
Assign std::string s to TString. More... | |
TString & | operator= (const std::string_view &s) |
Assign std::string s to TString. More... | |
TString & | operator= (const TString &s) |
Assignment operator. More... | |
TString & | operator= (const TSubString &s) |
Assign a TSubString substr to TString. More... | |
TString & | operator= (TString &&s) noexcept |
Move-Assignment operator. More... | |
char & | operator[] (Ssiz_t i) |
char | operator[] (Ssiz_t i) const |
TString & | Prepend (char c, Ssiz_t rep=1) |
Prepend character c rep times to string. More... | |
TString & | Prepend (const char *cs) |
TString & | Prepend (const char *cs, Ssiz_t n) |
TString & | Prepend (const TString &s) |
TString & | Prepend (const TString &s, Ssiz_t n) |
void | Puts (FILE *fp) |
Write string to the stream. More... | |
virtual void | ReadBuffer (char *&buffer) |
Read string from I/O buffer. More... | |
std::istream & | ReadFile (std::istream &str) |
Replace string with the contents of strm, stopping at an EOF. More... | |
std::istream & | ReadLine (std::istream &str, Bool_t skipWhite=kTRUE) |
Read a line from stream upto newline skipping any whitespace. More... | |
std::istream & | ReadString (std::istream &str) |
Read a line from stream upto \0, including any newline. More... | |
std::istream & | ReadToDelim (std::istream &str, char delim='\n') |
Read up to an EOF, or a delimiting character, whichever comes first. More... | |
std::istream & | ReadToken (std::istream &str) |
Read a token, delimited by whitespace, from the input stream. More... | |
TString & | Remove (EStripType s, char c) |
Remove char c at begin and/or end of string (like Strip()) but modifies directly the string. More... | |
TString & | Remove (Ssiz_t pos) |
TString & | Remove (Ssiz_t pos, Ssiz_t n) |
TString & | Replace (Ssiz_t pos, Ssiz_t n, const char *s) |
TString & | Replace (Ssiz_t pos, Ssiz_t n, const char *s, Ssiz_t ns) |
Remove at most n1 characters from self beginning at pos, and replace them with the first n2 characters of cs. More... | |
TString & | Replace (Ssiz_t pos, Ssiz_t n, const TString &s) |
TString & | Replace (Ssiz_t pos, Ssiz_t n1, const TString &s, Ssiz_t n2) |
TString & | ReplaceAll (const char *s1, const char *s2) |
TString & | ReplaceAll (const char *s1, const TString &s2) |
TString & | ReplaceAll (const char *s1, Ssiz_t ls1, const char *s2, Ssiz_t ls2) |
Find & Replace ls1 symbols of s1 with ls2 symbols of s2 if any. More... | |
TString & | ReplaceAll (const TString &s1, const char *s2) |
TString & | ReplaceAll (const TString &s1, const TString &s2) |
void | Resize (Ssiz_t n) |
Resize the string. Truncate or add blanks as necessary. More... | |
virtual Int_t | Sizeof () const |
Returns size string will occupy on I/O buffer. More... | |
TSubString | Strip (EStripType s=kTrailing, char c=' ') const |
Return a substring of self stripped at beginning and/or end. More... | |
TSubString | SubString (const char *pat, Ssiz_t start=0, ECaseCompare cmp=kExact) const |
Returns a substring matching "pattern", or the null substring if there is no such match. More... | |
TString & | Swap (TString &other) |
TObjArray * | Tokenize (const TString &delim) const |
This function is used to isolate sequential tokens in a TString. More... | |
Bool_t | Tokenize (TString &tok, Ssiz_t &from, const char *delim=" ") const |
Search for tokens delimited by regular expression 'delim' (default " ") in this string; search starts at 'from' and the token is returned in 'tok'. More... | |
void | ToLower () |
Change string to lower-case. More... | |
void | ToUpper () |
Change string to upper case. More... | |
std::string_view | View () const |
Static Public Member Functions | |
static TString | BaseConvert (const TString &s_in, Int_t base_in, Int_t base_out) |
Converts string from base base_in to base base_out. More... | |
static TString | Format (const char *fmt,...) |
Static method which formats a string using a printf style format descriptor and return a TString. More... | |
static Ssiz_t | GetInitialCapacity () |
static Ssiz_t | GetMaxWaste () |
static Ssiz_t | GetResizeIncrement () |
static UInt_t | Hash (const void *txt, Int_t ntxt) |
Calculates hash index from any char string. More... | |
static Ssiz_t | InitialCapacity (Ssiz_t ic=15) |
Set default initial capacity for all TStrings. Default is 15. More... | |
static TString | Itoa (Int_t value, Int_t base) |
Converts an Int_t to a TString with respect to the base specified (2-36). More... | |
static TString | LLtoa (Long64_t value, Int_t base) |
Converts a Long64_t to a TString with respect to the base specified (2-36). More... | |
static Ssiz_t | MaxWaste (Ssiz_t mw=15) |
Set maximum space that may be wasted in a string before doing a resize. More... | |
static TString * | ReadString (TBuffer &b, const TClass *clReq) |
Read TString object from buffer. More... | |
static Ssiz_t | ResizeIncrement (Ssiz_t ri=16) |
Set default resize increment for all TStrings. Default is 16. More... | |
static TString | UItoa (UInt_t value, Int_t base) |
Converts a UInt_t (twice the range of an Int_t) to a TString with respect to the base specified (2-36). More... | |
static TString | ULLtoa (ULong64_t value, Int_t base) |
Converts a ULong64_t (twice the range of an Long64_t) to a TString with respect to the base specified (2-36). More... | |
static void | WriteString (TBuffer &b, const TString *a) |
Write TString object to buffer. More... | |
Static Public Attributes | |
static const Ssiz_t | kNPOS = ::kNPOS |
Protected Types | |
enum | { kAlignment = 16 } |
Protected Member Functions | |
TString (const char *a1, Ssiz_t n1, const char *a2, Ssiz_t n2) | |
String data. More... | |
void | AssertElement (Ssiz_t nc) const |
Check to make sure a string index is in range. More... | |
void | Clobber (Ssiz_t nc) |
Clear string and make sure it has a capacity of nc. More... | |
void | InitChar (char c) |
Initialize a string with a single character. More... | |
Static Protected Member Functions | |
static Ssiz_t | AdjustCapacity (Ssiz_t oldCap, Ssiz_t newCap) |
Calculate a nice capacity greater than or equal to newCap. More... | |
static Ssiz_t | Align (Ssiz_t s) |
static Ssiz_t | Recommend (Ssiz_t s) |
Protected Attributes | |
Rep_t | fRep |
Private Types | |
enum | { kShortMask = 0x80 , kLongMask = 0x80000000 } |
enum | |
enum | { kNwords = sizeof(UStr_t) / sizeof(Ssiz_t) } |
Private Member Functions | |
void | Clone (Ssiz_t nc) |
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current length. More... | |
void | FormImp (const char *fmt, va_list ap) |
Formats a string using a printf style format descriptor. More... | |
Ssiz_t | GetLongCap () const |
char * | GetLongPointer () |
const char * | GetLongPointer () const |
Ssiz_t | GetLongSize () const |
char * | GetPointer () |
const char * | GetPointer () const |
char * | GetShortPointer () |
const char * | GetShortPointer () const |
Ssiz_t | GetShortSize () const |
UInt_t | HashCase () const |
Return a case-sensitive hash value (endian independent). More... | |
UInt_t | HashFoldCase () const |
Return a case-insensitive hash value (endian independent). More... | |
char * | Init (Ssiz_t capacity, Ssiz_t nchar) |
Private member function returning an empty string representation of size capacity and containing nchar characters. More... | |
Bool_t | IsLong () const |
void | SetLongCap (Ssiz_t s) |
void | SetLongPointer (char *p) |
void | SetLongSize (Ssiz_t s) |
void | SetShortSize (Ssiz_t s) |
void | SetSize (Ssiz_t s) |
void | UnLink () const |
void | Zero () |
Static Private Member Functions | |
static Ssiz_t | MaxSize () |
Friends | |
TString | operator+ (char c, const TString &s) |
Add string to char. More... | |
TString | operator+ (const char *cs, const TString &s) |
Use the special concatenation constructor. More... | |
TString | operator+ (const TString &s, char c) |
Add char to string. More... | |
TString | operator+ (const TString &s, const char *cs) |
Use the special concatenation constructor. More... | |
TString | operator+ (const TString &s1, const TString &s2) |
Use the special concatenation constructor. More... | |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type | operator+ (T f, const TString &s) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsSignedNumeral< T >::value, TString >::type | operator+ (T i, const TString &s) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type | operator+ (T u, const TString &s) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type | operator+ (TString s, T f) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsSignedNumeral< T >::value, TString >::type | operator+ (TString s, T i) |
template<class T > | |
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type | operator+ (TString s, T u) |
TBuffer & | operator<< (TBuffer &b, const TString *obj) |
Write TString or derived to TBuffer. More... | |
Bool_t | operator== (const TString &s1, const char *s2) |
Compare TString with a char *. More... | |
Bool_t | operator== (const TString &s1, const TString &s2) |
class | TBufferFile |
class | TStringLong |
class | TSubString |
#include <TString.h>
enum TString::EStripType |
String data.
Special constructor to initialize with the concatenation of a1 and a2.
Definition at line 205 of file TString.cxx.
TString::TString | ( | ) |
TString default ctor.
Definition at line 87 of file TString.cxx.
|
explicit |
Create TString able to contain ic characters.
Definition at line 95 of file TString.cxx.
TString::TString | ( | const TString & | s | ) |
Copy constructor.
Definition at line 161 of file TString.cxx.
|
noexcept |
Move constructor.
Definition at line 175 of file TString.cxx.
TString::TString | ( | const char * | s | ) |
Create TString and initialize it with string cs.
Definition at line 103 of file TString.cxx.
TString::TString | ( | const char * | s, |
Ssiz_t | n | ||
) |
Create TString and initialize it with the first n characters of cs.
Definition at line 126 of file TString.cxx.
TString::TString | ( | const std::string & | s | ) |
Create TString and initialize it with string cs.
Definition at line 116 of file TString.cxx.
TString::TString | ( | char | c | ) |
Initialize a string with a single character.
Definition at line 144 of file TString.cxx.
TString::TString | ( | char | c, |
Ssiz_t | s | ||
) |
Initialize the first n locations of a TString with character c.
Definition at line 152 of file TString.cxx.
TString::TString | ( | const std::string_view & | sub | ) |
Copy a std::string_view in a TString.
Definition at line 185 of file TString.cxx.
TString::TString | ( | const TSubString & | sub | ) |
Copy a TSubString in a TString.
Definition at line 195 of file TString.cxx.
|
virtual |
Delete a TString.
Definition at line 218 of file TString.cxx.
Calculate a nice capacity greater than or equal to newCap.
Definition at line 1136 of file TString.cxx.
Append character c rep times to string.
Definition at line 350 of file TString.cxx.
Check to make sure a string index is in range.
Definition at line 1126 of file TString.cxx.
Double_t TString::Atof | ( | ) | const |
Return floating-point value contained in string.
Examples of valid strings are:
Definition at line 1962 of file TString.cxx.
Int_t TString::Atoi | ( | ) | const |
Return integer value of string.
Valid strings include only digits and whitespace (see IsDigit()), i.e. "123456", "123 456" and "1 2 3 4 56" are all valid integer strings whose Atoi() value is 123456.
Definition at line 1896 of file TString.cxx.
Long64_t TString::Atoll | ( | ) | const |
Return long long value of string.
Valid strings include only digits and whitespace (see IsDigit()), i.e. "123456", "123 456" and "1 2 3 4 56" are all valid integer strings whose Atoll() value is 123456.
Definition at line 1922 of file TString.cxx.
Converts string from base base_in to base base_out.
Supported bases are 2-36. At most 64 bit data can be converted.
Definition at line 2102 of file TString.cxx.
|
inline |
|
inline |
Return string capacity.
If nc != current capacity Clone() the string in a string with the desired capacity.
Definition at line 391 of file TString.cxx.
void TString::Clear | ( | ) |
Clear string without changing its capacity.
Definition at line 1151 of file TString.cxx.
Clear string and make sure it has a capacity of nc.
Definition at line 1159 of file TString.cxx.
Make self a distinct copy with capacity of at least tot, where tot cannot be smaller than the current length.
Preserve previous contents.
Definition at line 1187 of file TString.cxx.
int TString::CompareTo | ( | const char * | cs2, |
ECaseCompare | cmp = kExact |
||
) | const |
Compare a string to char *cs2.
Returns returns zero if the two strings are identical, otherwise returns the difference between the first two differing bytes (treated as unsigned char values, so that ‘\200’ is greater than ‘\0’, for example). Zero-length strings are always identical.
Definition at line 406 of file TString.cxx.
int TString::CompareTo | ( | const TString & | str, |
ECaseCompare | cmp = kExact |
||
) | const |
Compare a string to another string.
Returns returns zero if the two strings are identical, otherwise returns the difference between the first two differing bytes (treated as unsigned char values, so that ‘\200’ is greater than ‘\0’, for example). Zero-length strings are always identical.
Definition at line 436 of file TString.cxx.
|
inline |
|
inline |
TString TString::Copy | ( | ) | const |
Copy a string.
Definition at line 478 of file TString.cxx.
Return number of times character c occurs in the string.
Definition at line 464 of file TString.cxx.
Bool_t TString::EndsWith | ( | const char * | pat, |
ECaseCompare | cmp = kExact |
||
) | const |
Return true if string ends with the specified string.
Definition at line 2152 of file TString.cxx.
|
inline |
|
inline |
|
virtual |
Copy string into I/O buffer.
Reimplemented in TStringLong.
Definition at line 1218 of file TString.cxx.
Ssiz_t TString::First | ( | char | c | ) | const |
Find first occurrence of a character c.
Definition at line 487 of file TString.cxx.
Ssiz_t TString::First | ( | const char * | cs | ) | const |
Find first occurrence of a character in cs.
Definition at line 496 of file TString.cxx.
void TString::Form | ( | const char * | fmt, |
... | |||
) |
Formats a string using a printf style format descriptor.
Existing string contents will be overwritten. See also the static version TString::Format
Note: this is not to be confused with Format and Form (in the global namespace) which returns a const char* and relies on a thread-local static character buffer.
Definition at line 2264 of file TString.cxx.
|
static |
Static method which formats a string using a printf style format descriptor and return a TString.
Similar to TString::Form() but it is not needed to first create a TString.
Note: this is not to be confused with Format and Form (in the global namespace) which returns a const char* and relies on a thread-local static character buffer.
Definition at line 2286 of file TString.cxx.
|
private |
Formats a string using a printf style format descriptor.
Existing string contents will be overwritten.
Definition at line 2218 of file TString.cxx.
|
static |
Definition at line 1476 of file TString.cxx.
|
inlineprivate |
|
static |
Definition at line 1492 of file TString.cxx.
|
static |
Definition at line 1484 of file TString.cxx.
Read one line from the stream, including the
, or until EOF.
Remove the trailing [\r]
if chop is true. Returns kTRUE if data was read.
Definition at line 198 of file Stringio.cxx.
|
inlineprivate |
Calculates hash index from any char string.
(static function)
This employs two different hash functions, depending on ntxt:
Definition at line 799 of file TString.cxx.
UInt_t TString::Hash | ( | ECaseCompare | cmp = kExact | ) | const |
Return hash value.
Definition at line 626 of file TString.cxx.
|
private |
Return a case-sensitive hash value (endian independent).
Definition at line 582 of file TString.cxx.
|
private |
Return a case-insensitive hash value (endian independent).
Definition at line 611 of file TString.cxx.
|
inline |
Ssiz_t TString::Index | ( | const char * | pattern, |
Ssiz_t | plen, | ||
Ssiz_t | startIndex, | ||
ECaseCompare | cmp | ||
) | const |
Search for a string in the TString.
Plen is the length of pattern, startIndex is the index from which to start and cmp selects the type of case-comparison.
Definition at line 850 of file TString.cxx.
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match.
Extent is length of the matched string and start is the offset at which the matching should start.
Definition at line 261 of file TRegexp.cxx.
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match.
Start is the offset at which the search should start.
Definition at line 250 of file TRegexp.cxx.
|
inline |
|
inline |
Find the first occurrence of the regexp in string and return the position.
Extent is length of the matched string and start is the offset at which the matching should start.
Definition at line 539 of file TPRegexp.cxx.
Find the first occurrence of the regexp in string and return the position.
Start is the offset at which the search should start.
Definition at line 524 of file TPRegexp.cxx.
Private member function returning an empty string representation of size capacity and containing nchar characters.
Definition at line 227 of file TString.cxx.
|
protected |
Initialize a string with a single character.
Definition at line 135 of file TString.cxx.
Set default initial capacity for all TStrings. Default is 15.
Definition at line 1501 of file TString.cxx.
Bool_t TString::IsAlnum | ( | ) | const |
Returns true if all characters in string are alphanumeric.
Returns false in case string length is 0.
Definition at line 1721 of file TString.cxx.
Bool_t TString::IsAlpha | ( | ) | const |
Returns true if all characters in string are alphabetic.
Returns false in case string length is 0.
Definition at line 1706 of file TString.cxx.
Bool_t TString::IsAscii | ( | ) | const |
Returns true if all characters in string are ascii.
Definition at line 1693 of file TString.cxx.
Bool_t TString::IsBin | ( | ) | const |
Returns true if all characters in string are binary digits (0,1).
Returns false in case string length is 0 or string contains other characters.
Definition at line 1816 of file TString.cxx.
Bool_t TString::IsDec | ( | ) | const |
Returns true if all characters in string are decimal digits (0-9).
Returns false in case string length is 0 or string contains other characters.
Definition at line 1848 of file TString.cxx.
Bool_t TString::IsDigit | ( | ) | const |
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
"123456" and "123 456" are both valid integer strings. Returns false in case string length is 0 or string contains other characters or only whitespace.
Definition at line 1738 of file TString.cxx.
Bool_t TString::IsFloat | ( | ) | const |
Returns kTRUE if string contains a floating point or integer number.
Examples of valid formats are:
Definition at line 1766 of file TString.cxx.
Bool_t TString::IsHex | ( | ) | const |
Returns true if all characters in string are hexadecimal digits (0-9,a-f,A-F).
Returns false in case string length is 0 or string contains other characters.
Definition at line 1800 of file TString.cxx.
Returns true if all characters in string are expressed in the base specified (range=2-36), i.e.
{0,1} for base 2, {0-9,a-f,A-F} for base 16, {0-9,a-z,A-Z} for base 36. Returns false in case string length is 0 or string contains other characters.
Definition at line 1865 of file TString.cxx.
Bool_t TString::IsOct | ( | ) | const |
Returns true if all characters in string are octal digits (0-7).
Returns false in case string length is 0 or string contains other characters.
Definition at line 1832 of file TString.cxx.
Converts an Int_t to a TString with respect to the base specified (2-36).
Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). Usage: the following statement produce the same output, namely "1111"
In case of error returns the "!" string.
Definition at line 2000 of file TString.cxx.
Ssiz_t TString::Last | ( | char | c | ) | const |
Find last occurrence of a character c.
Definition at line 876 of file TString.cxx.
Converts a Long64_t to a TString with respect to the base specified (2-36).
Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). In case of error returns the "!" string.
Definition at line 2052 of file TString.cxx.
Set maximum space that may be wasted in a string before doing a resize.
Default is 15.
Definition at line 1520 of file TString.cxx.
Bool_t TString::MaybeRegexp | ( | ) | const |
Returns true if string contains one of the regexp characters "^$.[]*+?".
Definition at line 897 of file TString.cxx.
Bool_t TString::MaybeWildcard | ( | ) | const |
Returns true if string contains one of the wildcard characters "[]*?".
Definition at line 909 of file TString.cxx.
TString TString::MD5 | ( | ) | const |
Return the MD5 digest for this string, in a string representation.
Definition at line 885 of file TString.cxx.
|
inline |
TSubString TString::operator() | ( | const TRegexp & | re | ) | const |
Return the substring found by applying the regexp.
Definition at line 279 of file TRegexp.cxx.
TSubString TString::operator() | ( | const TRegexp & | re, |
Ssiz_t | start | ||
) | const |
Return the substring found by applying the regexp starting at start.
Definition at line 269 of file TRegexp.cxx.
TSubString TString::operator() | ( | Ssiz_t | start, |
Ssiz_t | len | ||
) | const |
Return sub-string of string starting at start with length len.
Definition at line 1547 of file TString.cxx.
TSubString TString::operator() | ( | TPRegexp & | re | ) | const |
Return the substring found by applying the regexp.
Definition at line 565 of file TPRegexp.cxx.
TSubString TString::operator() | ( | TPRegexp & | re, |
Ssiz_t | start | ||
) | const |
Return the substring found by applying the regexp starting at start.
Definition at line 555 of file TPRegexp.cxx.
std::enable_if< ROOT::TypeTraits::IsFloatNumeral< T >::value, TString >::type & TString::operator+= | ( | T | f | ) |
|
inline |
std::enable_if< ROOT::TypeTraits::IsUnsignedNumeral< T >::value, TString >::type & TString::operator+= | ( | T | u | ) |
TString & TString::operator= | ( | char | s | ) |
Assign character c to TString.
Definition at line 255 of file TString.cxx.
TString & TString::operator= | ( | const char * | s | ) |
Assign string cs to TString.
Definition at line 268 of file TString.cxx.
TString & TString::operator= | ( | const std::string & | s | ) |
Assign std::string s to TString.
Definition at line 281 of file TString.cxx.
TString & TString::operator= | ( | const std::string_view & | s | ) |
Assign std::string s to TString.
Definition at line 294 of file TString.cxx.
Assignment operator.
Definition at line 307 of file TString.cxx.
TString & TString::operator= | ( | const TSubString & | s | ) |
Assign a TSubString substr to TString.
Definition at line 336 of file TString.cxx.
Move-Assignment operator.
Definition at line 325 of file TString.cxx.
Prepend character c rep times to string.
Definition at line 921 of file TString.cxx.
void TString::Puts | ( | FILE * | fp | ) |
Write string to the stream.
Definition at line 223 of file Stringio.cxx.
|
virtual |
Read string from I/O buffer.
Reimplemented in TStringLong.
Definition at line 1239 of file TString.cxx.
std::istream & TString::ReadFile | ( | std::istream & | str | ) |
Replace string with the contents of strm, stopping at an EOF.
Definition at line 28 of file Stringio.cxx.
Read a line from stream upto newline skipping any whitespace.
Definition at line 65 of file Stringio.cxx.
std::istream & TString::ReadString | ( | std::istream & | str | ) |
Read a line from stream upto \0, including any newline.
Definition at line 76 of file Stringio.cxx.
Read TString object from buffer.
Simplified version of TBuffer::ReadObject (does not keep track of multiple references to same string). We need to have it here because TBuffer::ReadObject can only handle descendant of TObject.
Definition at line 1270 of file TString.cxx.
std::istream & TString::ReadToDelim | ( | std::istream & | strm, |
char | delim = '\n' |
||
) |
Read up to an EOF, or a delimiting character, whichever comes first.
The delimiter is not stored in the string, but is removed from the input stream. Because we don't know how big a string to expect, we first read as much as we can and then, if the EOF or null hasn't been encountered, do a resize and keep reading.
Definition at line 89 of file Stringio.cxx.
std::istream & TString::ReadToken | ( | std::istream & | str | ) |
Read a token, delimited by whitespace, from the input stream.
Definition at line 127 of file Stringio.cxx.
TString & TString::Remove | ( | EStripType | s, |
char | c | ||
) |
Remove char c at begin and/or end of string (like Strip()) but modifies directly the string.
Definition at line 1042 of file TString.cxx.
Remove at most n1 characters from self beginning at pos, and replace them with the first n2 characters of cs.
Definition at line 962 of file TString.cxx.
|
inline |
Find & Replace ls1 symbols of s1 with ls2 symbols of s2 if any.
Definition at line 1025 of file TString.cxx.
Resize the string. Truncate or add blanks as necessary.
Definition at line 1070 of file TString.cxx.
Set default resize increment for all TStrings. Default is 16.
Definition at line 1510 of file TString.cxx.
|
virtual |
Returns size string will occupy on I/O buffer.
Reimplemented in TStringLong.
Definition at line 1309 of file TString.cxx.
TSubString TString::Strip | ( | EStripType | s = kTrailing , |
char | c = ' ' |
||
) | const |
Return a substring of self stripped at beginning and/or end.
Definition at line 1081 of file TString.cxx.
TSubString TString::SubString | ( | const char * | pattern, |
Ssiz_t | startIndex = 0 , |
||
ECaseCompare | cmp = kExact |
||
) | const |
Returns a substring matching "pattern", or the null substring if there is no such match.
It would be nice if this could be yet another overloaded version of operator(), but this would result in a type conversion ambiguity with operator(Ssiz_t, Ssiz_t).
Definition at line 1565 of file TString.cxx.
This function is used to isolate sequential tokens in a TString.
These tokens are separated in the string by at least one of the characters in delim. The returned array contains the tokens as TObjString's. The returned array is the owner of the objects, and must be deleted by the user.
Definition at line 2172 of file TString.cxx.
Search for tokens delimited by regular expression 'delim' (default " ") in this string; search starts at 'from' and the token is returned in 'tok'.
Returns in 'from' the next position after the delimiter. Returns kTRUE if a token is found, kFALSE if not or if some inconsistency occurred. This method allows to loop over tokens in this way:
more convenient of the other Tokenize method when saving the tokens is not needed.
Definition at line 303 of file TRegexp.cxx.
void TString::ToLower | ( | ) |
Change string to lower-case.
Definition at line 1100 of file TString.cxx.
void TString::ToUpper | ( | ) |
Change string to upper case.
Definition at line 1113 of file TString.cxx.
Converts a UInt_t (twice the range of an Int_t) to a TString with respect to the base specified (2-36).
Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). In case of error returns the "!" string.
Definition at line 2027 of file TString.cxx.
Converts a ULong64_t (twice the range of an Long64_t) to a TString with respect to the base specified (2-36).
Thus it is an enhanced version of sprintf (adapted from versions 0.4 of http://www.jb.man.ac.uk/~slowe/cpp/itoa.html). In case of error returns the "!" string.
Definition at line 2079 of file TString.cxx.
|
inline |
Write TString object to buffer.
Simplified version of TBuffer::WriteObject (does not keep track of multiple references to the same string). We need to have it here because TBuffer::ReadObject can only handle descendant of TObject
Definition at line 1336 of file TString.cxx.
Add string to char.
Definition at line 1465 of file TString.cxx.
Use the special concatenation constructor.
Definition at line 1441 of file TString.cxx.
Add char to string.
Definition at line 1457 of file TString.cxx.
Use the special concatenation constructor.
Definition at line 1433 of file TString.cxx.
Use the special concatenation constructor.
Definition at line 1449 of file TString.cxx.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
Write TString or derived to TBuffer.
Definition at line 1378 of file TString.cxx.
Compare TString with a char *.
Definition at line 1390 of file TString.cxx.
|
friend |
|
friend |
|
friend |