AGX Dynamics 2.41.3.0
Loading...
Searching...
No Matches
agx::AgXString< T > Class Template Reference

#include <String.h>

+ Inheritance diagram for agx::AgXString< T >:

Public Types

typedef std::string::const_iterator const_iterator
 
typedef std::string::iterator iterator
 
typedef std::string::size_type size_type
 

Public Member Functions

 AgXString ()
 Default constructor.
 
 AgXString (const AgXString &str)
 Copy constructors.
 
 AgXString (const char *str)
 Element type pointer constructor.
 
 AgXString (const char *str, size_type index, size_type length)
 Construct sub-string of str from index and length characters forward.
 
 AgXString (const char *str, size_type length)
 Construct given str, final length of this string will be length.
 
 AgXString (const std::string &str)
 Create a AgXString from stl string.
 
 AgXString (const_iterator begin, const_iterator end)
 Construct sub-string given iterators.
 
 AgXString (size_type length, char ch)
 Construct length number of ch.
 
AgXString capitalize () const
 
AgXString center (int width) const
 
bool contains (const AgXString &sub, size_t start=0) const
 
AgXString copy () const
 Copy method, if implementation of this class is changed.
 
int count (const AgXString &substr, int start=0, int end=MAX_32BIT_INT) const
 
bool endswith (const AgXString &suffix, int start=0, int end=MAX_32BIT_INT) const
 
bool endswithCI (const AgXString &suffix, int start=0, int end=MAX_32BIT_INT) const
 
AgXString expandtabs (int tabsize=8) const
 
size_t find (const AgXString &sub, int start=0, int end=MAX_32BIT_INT) const
 
int index (const AgXString &sub, int start=0, int end=MAX_32BIT_INT) const
 Synonym of find right now.
 
bool isalnum () const
 
bool isalpha () const
 
bool isdigit () const
 
bool islower () const
 
bool isspace () const
 
bool istitle () const
 
bool isupper () const
 
AgXString ljust (int width) const
 
AgXString lower () const
 
AgXString lstrip (const AgXString &chars="") const
 
bool operator!= (const char *other) const
 
bool operator!= (const std::string &other) const
 
AgXString operator+ (const AgXString &other) const
 Operator +, AgXString b = thisAgXString + other.
 
AgXString operator+ (const char *other) const
 Operator +, AgXString b = thisAgXString + "other".
 
AgXString operator+ (const char elem) const
 Operator +, AgXString b = thisAgXString + 'o'.
 
bool operator== (const AgXString &other) const
 
bool operator== (const char *other) const
 
bool operator== (const std::string &other) const
 
void partition (const AgXString &sep, StringVector &result) const
 Split the string around first occurrence of sep.
 
AgXString replace (const AgXString &oldstr, const AgXString &newstr, int count=-1) const
 
size_t rfind (const AgXString &sub, int start=0, int end=MAX_32BIT_INT) const
 
AgXString rjust (int width) const
 
void rpartition (const AgXString &sep, StringVector &result) const
 Split the string around last occurrence of sep.
 
void rsplit (StringVector &result, const AgXString &sep="", int maxsplit=-1) const
 Fills the "result" list with the words in the string, using sep as the delimiter string.
 
AgXString rstrip (const AgXString &chars="") const
 
AgXString slice (int start=0, int end=MAX_32BIT_INT) const
 function matching python's slice functionality.
 
void split (StringVector &result, const AgXString &sep="", int maxsplit=-1) const
 Fills the "result" list with the words in the string, using sep as the delimiter string.
 
void splitlines (StringVector &result, bool keepends=false) const
 
bool startswith (const AgXString &prefix, int start=0, int end=MAX_32BIT_INT) const
 
bool startswithCI (const AgXString &prefix, int start=0, int end=MAX_32BIT_INT) const
 
AgXString strip (const AgXString &chars="") const
 
AgXString stripLeadingString (const AgXString &toBeRemoved) const
 If this string begins with toBeRemoved, it will be removed and returned.
 
AgXString substr (size_type index) const
 
AgXString substr (size_type index, size_type length) const
 
AgXString swapcase () const
 
AgXString title () const
 
AgXString translate (const AgXString &table, const AgXString &deletechars="") const
 
AgXString upper () const
 
AgXString zfill (int width) const
 

Static Public Member Functions

static AgXString format (const char *format,...)
 C printf formatting of a string.
 
static AgXString formatVA (const char *format, va_list ap)
 

Detailed Description

template<typename T>
class agx::AgXString< T >

Definition at line 40 of file String.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef std::string::const_iterator agx::AgXString< T >::const_iterator

Definition at line 45 of file String.h.

◆ iterator

template<typename T >
typedef std::string::iterator agx::AgXString< T >::iterator

Definition at line 44 of file String.h.

◆ size_type

template<typename T >
typedef std::string::size_type agx::AgXString< T >::size_type

Definition at line 43 of file String.h.

Constructor & Destructor Documentation

◆ AgXString() [1/8]

template<typename T >
agx::AgXString< T >::AgXString
inline

Default constructor.

Definition at line 509 of file String.h.

◆ AgXString() [2/8]

template<typename T >
agx::AgXString< T >::AgXString ( const AgXString< T > &  str)
inline

Copy constructors.

Definition at line 515 of file String.h.

◆ AgXString() [3/8]

template<typename T >
agx::AgXString< T >::AgXString ( const std::string &  str)
inline

Create a AgXString from stl string.

Definition at line 522 of file String.h.

◆ AgXString() [4/8]

template<typename T >
agx::AgXString< T >::AgXString ( const char *  str)
inline

Element type pointer constructor.

Definition at line 528 of file String.h.

◆ AgXString() [5/8]

template<typename T >
agx::AgXString< T >::AgXString ( size_type  length,
char  ch 
)
inline

Construct length number of ch.

Parameters
length- final length of this string
ch- filling

Definition at line 534 of file String.h.

◆ AgXString() [6/8]

template<typename T >
agx::AgXString< T >::AgXString ( const char *  str,
size_type  length 
)
inline

Construct given str, final length of this string will be length.

Parameters
str- string
length- final length of this string
Note
If length > strlen( str ) it's not defined which characters this string is extended with.

Definition at line 540 of file String.h.

◆ AgXString() [7/8]

template<typename T >
agx::AgXString< T >::AgXString ( const char *  str,
size_type  index,
size_type  length 
)
inline

Construct sub-string of str from index and length characters forward.

Parameters
str- a string
index- index from where this sub-string should start
length- length from index

Definition at line 547 of file String.h.

◆ AgXString() [8/8]

template<typename T >
agx::AgXString< T >::AgXString ( const_iterator  begin,
const_iterator  end 
)
inline

Construct sub-string given iterators.

Parameters
begin- start iterator
end- end iterator

Definition at line 554 of file String.h.

Member Function Documentation

◆ capitalize()

template<typename T >
AgXString< T > agx::AgXString< T >::capitalize
Returns
a copy of the string with only its first character capitalized.

Definition at line 653 of file String.h.

◆ center()

template<typename T >
AgXString< T > agx::AgXString< T >::center ( int  width) const
Returns
centered in a string of length width. Padding is done using spaces.

Definition at line 659 of file String.h.

◆ contains()

template<typename T >
bool agx::AgXString< T >::contains ( const AgXString< T > &  sub,
size_t  start = 0 
) const
inline
Returns
the lowest index in the string where substring sub is found, such that sub is contained in the range [start, end). Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found.

Definition at line 646 of file String.h.

◆ copy()

template<typename T >
AgXString< T > agx::AgXString< T >::copy
inline

Copy method, if implementation of this class is changed.

Definition at line 584 of file String.h.

◆ count()

template<typename T >
int agx::AgXString< T >::count ( const AgXString< T > &  substr,
int  start = 0,
int  end = MAX_32BIT_INT 
) const
Returns
the number of occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Definition at line 665 of file String.h.

References agx::end().

◆ endswith()

template<typename T >
bool agx::AgXString< T >::endswith ( const AgXString< T > &  suffix,
int  start = 0,
int  end = MAX_32BIT_INT 
) const
Returns
True if the string ends with the specified suffix, otherwise return False. With optional start, test beginning at that position. With optional end, stop comparing at that position.

Definition at line 671 of file String.h.

References agx::end().

◆ endswithCI()

template<typename T >
bool agx::AgXString< T >::endswithCI ( const AgXString< T > &  suffix,
int  start = 0,
int  end = MAX_32BIT_INT 
) const

Definition at line 677 of file String.h.

References agx::end().

◆ expandtabs()

template<typename T >
AgXString< T > agx::AgXString< T >::expandtabs ( int  tabsize = 8) const
Returns
a copy of the string where all tab characters are expanded using spaces. If tabsize is not given, a tab size of 8 characters is assumed.

Definition at line 683 of file String.h.

◆ find()

template<typename T >
size_t agx::AgXString< T >::find ( const AgXString< T > &  sub,
int  start = 0,
int  end = MAX_32BIT_INT 
) const
Returns
the lowest index in the string where substring sub is found, such that sub is contained in the range [start, end). Optional arguments start and end are interpreted as in slice notation. Return npos if sub is not found.

Definition at line 790 of file String.h.

References agx::end().

◆ format()

template<typename T >
AgXString< T > agx::AgXString< T >::format ( const char *  format,
  ... 
)
inlinestatic

C printf formatting of a string.

E.g., agx::AgXString s = agx::AgXString::format( "%s%d", "a number: ", 10 );.

Returns
string of given format

Definition at line 471 of file String.h.

References agx::AgXString< T >::formatVA().

◆ formatVA()

template<typename T >
AgXString< T > agx::AgXString< T >::formatVA ( const char *  format,
va_list  ap 
)
inlinestatic

Definition at line 481 of file String.h.

References agxAssert, and agxVerifyN.

Referenced by agx::AgXString< T >::format().

◆ index()

template<typename T >
int agx::AgXString< T >::index ( const AgXString< T > &  sub,
int  start = 0,
int  end = MAX_32BIT_INT 
) const

Synonym of find right now.

Python version throws exceptions. This one currently doesn't

Definition at line 696 of file String.h.

References agx::end().

◆ isalnum()

template<typename T >
bool agx::AgXString< T >::isalnum
Returns
true if all characters in the string are alphanumeric and there is at least one character, false otherwise.

Definition at line 702 of file String.h.

◆ isalpha()

template<typename T >
bool agx::AgXString< T >::isalpha
Returns
true if all characters in the string are alphabetic and there is at least one character, false otherwise

Definition at line 708 of file String.h.

◆ isdigit()

template<typename T >
bool agx::AgXString< T >::isdigit
Returns
true if all characters in the string are digits and there is at least one character, false otherwise.

Definition at line 714 of file String.h.

◆ islower()

template<typename T >
bool agx::AgXString< T >::islower
Returns
true if all cased characters in the string are lowercase and there is at least one cased character, false otherwise.

Definition at line 720 of file String.h.

◆ isspace()

template<typename T >
bool agx::AgXString< T >::isspace
Returns
true if there are only whitespace characters in the string and there is at least one character, false otherwise.

Definition at line 726 of file String.h.

◆ istitle()

template<typename T >
bool agx::AgXString< T >::istitle
Returns
true if the string is a titlecased string and there is at least one character, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return false otherwise.

Definition at line 732 of file String.h.

◆ isupper()

template<typename T >
bool agx::AgXString< T >::isupper
Returns
true if all cased characters in the string are uppercase and there is at least one cased character, false otherwise.

Definition at line 738 of file String.h.

◆ ljust()

template<typename T >
AgXString< T > agx::AgXString< T >::ljust ( int  width) const
Returns
the string left justified in a string of length width. Padding is done using spaces. The original string is returned if width is less than str.size().

Definition at line 745 of file String.h.

◆ lower()

template<typename T >
AgXString< T > agx::AgXString< T >::lower
Returns
a copy of the string converted to lowercase.

Definition at line 751 of file String.h.

Referenced by agx::GenericJsonParameter< T >::isDefault(), and agx::GenericJsonParameter< T >::parseBool().

◆ lstrip()

template<typename T >
AgXString< T > agx::AgXString< T >::lstrip ( const AgXString< T > &  chars = "") const
Returns
a copy of the string with leading characters removed. If chars is omitted or None, whitespace characters are removed. If given and not "", chars must be a string; the characters in the string will be stripped from the beginning of the string this method is called on (argument "str" ).

Definition at line 772 of file String.h.

◆ operator!=() [1/2]

template<typename T >
bool agx::AgXString< T >::operator!= ( const char *  other) const
Returns
true if this string is NOT equal to other

Definition at line 626 of file String.h.

◆ operator!=() [2/2]

template<typename T >
bool agx::AgXString< T >::operator!= ( const std::string &  other) const
Returns
true if this string is NOT equal to other

Definition at line 620 of file String.h.

◆ operator+() [1/3]

template<typename T >
AgXString< T > agx::AgXString< T >::operator+ ( const AgXString< T > &  other) const
inline

Operator +, AgXString b = thisAgXString + other.

Definition at line 560 of file String.h.

◆ operator+() [2/3]

template<typename T >
AgXString< T > agx::AgXString< T >::operator+ ( const char *  other) const
inline

Operator +, AgXString b = thisAgXString + "other".

Definition at line 568 of file String.h.

◆ operator+() [3/3]

template<typename T >
AgXString< T > agx::AgXString< T >::operator+ ( const char  elem) const
inline

Operator +, AgXString b = thisAgXString + 'o'.

Definition at line 576 of file String.h.

◆ operator==() [1/3]

template<typename T >
bool agx::AgXString< T >::operator== ( const AgXString< T > &  other) const
Returns
true if this string is equal to other

Definition at line 602 of file String.h.

◆ operator==() [2/3]

template<typename T >
bool agx::AgXString< T >::operator== ( const char *  other) const
Returns
true if this string is equal to other

Definition at line 614 of file String.h.

◆ operator==() [3/3]

template<typename T >
bool agx::AgXString< T >::operator== ( const std::string &  other) const
Returns
true if this string is equal to other

Definition at line 608 of file String.h.

◆ partition()

template<typename T >
void agx::AgXString< T >::partition ( const AgXString< T > &  sep,
StringVector result 
) const

Split the string around first occurrence of sep.

Three strings will always placed into result. If sep is found, the strings will be the text before sep, sep itself, and the remaining text. If sep is not found, the original string will be returned with two empty strings.

Definition at line 778 of file String.h.

◆ replace()

template<typename T >
AgXString< T > agx::AgXString< T >::replace ( const AgXString< T > &  oldstr,
const AgXString< T > &  newstr,
int  count = -1 
) const
Returns
a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.

Definition at line 784 of file String.h.

◆ rfind()

template<typename T >
size_t agx::AgXString< T >::rfind ( const AgXString< T > &  sub,
int  start = 0,
int  end = MAX_32BIT_INT 
) const
Returns
the highest index in the string where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return npos if sub is not found.

Definition at line 797 of file String.h.

References agx::end().

◆ rjust()

template<typename T >
AgXString< T > agx::AgXString< T >::rjust ( int  width) const
Returns
the string right justified in a string of length width. Padding is done using spaces. The original string is returned if width is less than str.size().

Definition at line 805 of file String.h.

◆ rpartition()

template<typename T >
void agx::AgXString< T >::rpartition ( const AgXString< T > &  sep,
StringVector result 
) const

Split the string around last occurrence of sep.

Three strings will always placed into result. If sep is found, the strings will be the text before sep, sep itself, and the remaining text. If sep is not found, the original string will be returned with two empty strings.

Definition at line 811 of file String.h.

◆ rsplit()

template<typename T >
void agx::AgXString< T >::rsplit ( StringVector result,
const AgXString< T > &  sep = "",
int  maxsplit = -1 
) const

Fills the "result" list with the words in the string, using sep as the delimiter string.

Does a number of splits starting at the end of the string, the result still has the split strings in their original order. If maxsplit is > -1, at most maxsplit splits are done. If sep is "", any whitespace string is a separator.

Definition at line 829 of file String.h.

◆ rstrip()

template<typename T >
AgXString< T > agx::AgXString< T >::rstrip ( const AgXString< T > &  chars = "") const
Returns
a copy of the string with trailing characters removed. If chars is "", whitespace characters are removed. If not "", the characters in the string will be stripped from the end of the string this method is called on.

Definition at line 817 of file String.h.

◆ slice()

template<typename T >
AgXString< T > agx::AgXString< T >::slice ( int  start = 0,
int  end = MAX_32BIT_INT 
) const

function matching python's slice functionality.

Definition at line 892 of file String.h.

References agx::end().

◆ split()

template<typename T >
void agx::AgXString< T >::split ( StringVector result,
const AgXString< T > &  sep = "",
int  maxsplit = -1 
) const

Fills the "result" list with the words in the string, using sep as the delimiter string.

If maxsplit is > -1, at most maxsplit splits are done. If sep is "", any whitespace string is a separator.

Definition at line 823 of file String.h.

◆ splitlines()

template<typename T >
void agx::AgXString< T >::splitlines ( StringVector result,
bool  keepends = false 
) const
Returns
a list of the lines in the string, breaking at line boundaries. Line breaks are not included in the resulting list unless keepends is given and true.

Definition at line 835 of file String.h.

◆ startswith()

template<typename T >
bool agx::AgXString< T >::startswith ( const AgXString< T > &  prefix,
int  start = 0,
int  end = MAX_32BIT_INT 
) const
Returns
True if string starts with the prefix, otherwise return False. With optional start, test string beginning at that position. With optional end, stop comparing string at that position

Definition at line 841 of file String.h.

References agx::end().

◆ startswithCI()

template<typename T >
bool agx::AgXString< T >::startswithCI ( const AgXString< T > &  prefix,
int  start = 0,
int  end = MAX_32BIT_INT 
) const

Definition at line 847 of file String.h.

References agx::end().

◆ strip()

template<typename T >
AgXString< T > agx::AgXString< T >::strip ( const AgXString< T > &  chars = "") const
Returns
a copy of the string with leading and trailing characters removed. If chars is "", whitespace characters are removed. If given not "", the characters in the string will be stripped from the both ends of the string this method is called on.

Definition at line 853 of file String.h.

◆ stripLeadingString()

template<typename T >
AgXString< T > agx::AgXString< T >::stripLeadingString ( const AgXString< T > &  toBeRemoved) const

If this string begins with toBeRemoved, it will be removed and returned.

Returns
this string with the leading string toBeRemoved removed. Otherwise the string is returned unmodified.

Definition at line 758 of file String.h.

◆ substr() [1/2]

template<typename T >
AgXString< T > agx::AgXString< T >::substr ( size_type  index) const
inline
Returns
sub-string of this from index to end

Definition at line 590 of file String.h.

◆ substr() [2/2]

template<typename T >
AgXString< T > agx::AgXString< T >::substr ( size_type  index,
size_type  length 
) const
inline
Returns
sub-string of this given index and length

Definition at line 596 of file String.h.

◆ swapcase()

template<typename T >
AgXString< T > agx::AgXString< T >::swapcase
Returns
a copy of the string with uppercase characters converted to lowercase and vice versa.

Definition at line 862 of file String.h.

◆ title()

template<typename T >
AgXString< T > agx::AgXString< T >::title
Returns
a titlecased version of the string: words start with uppercase characters, all remaining cased characters are lowercase.

Definition at line 868 of file String.h.

◆ translate()

template<typename T >
AgXString< T > agx::AgXString< T >::translate ( const AgXString< T > &  table,
const AgXString< T > &  deletechars = "" 
) const
Returns
a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256.

Definition at line 874 of file String.h.

◆ upper()

template<typename T >
AgXString< T > agx::AgXString< T >::upper
Returns
a copy of the string converted to uppercase.

Definition at line 880 of file String.h.

◆ zfill()

template<typename T >
AgXString< T > agx::AgXString< T >::zfill ( int  width) const
Returns
the numeric string left filled with zeros in a string of length width. The original string is returned if width is less than str.size().

Definition at line 886 of file String.h.


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