31 template<
typename T = std::
string>
class AgXString;
190 #define MAX_32BIT_INT 2147483647
437 template <
typename T>
440 template <
typename T>
461 #include <external/pystring/pystring.h>
470 va_start(ap, format);
482 int len = _vscprintf( format, ap ) + 1;
483 buf = (
char*) malloc( len *
sizeof(
char) );
485 vsprintf_s( buf, len, format, ap );
487 int ret = vasprintf(&buf, format, ap);
488 agxVerifyN(ret >= 0,
"Could not allocate memory for formatted string: \'%s\'", format);
504 template <
typename T>
510 template <
typename T>
517 template <
typename T>
523 template <
typename T>
529 template <
typename T>
535 template <
typename T>
542 template <
typename T>
544 : T( str, index, length )
549 template <
typename T>
555 template <
typename T>
563 template <
typename T>
571 template <
typename T>
579 template <
typename T>
585 template <
typename T>
588 return AgXString( this->c_str(), index, this->size() );
591 template <
typename T>
594 return AgXString( this->c_str(), index, length );
597 template <
typename T>
600 return *(std::string*)
this == other;
603 template <
typename T>
606 return *(std::string*)
this == other;
609 template <
typename T>
612 return *(std::string*)
this != other;
615 template <
typename T>
618 return *(std::string*)
this != other;
645 return pystring::capitalize(*
this);
651 return pystring::center(*
this, width);
657 return pystring::count(*
this, substr, start,
end);
663 return pystring::endswith(*
this, suffix, start,
end);
669 return pystring::endswithCI(*
this, suffix, start,
end);
675 return pystring::expandtabs(*
this, tabsize);
688 return pystring::index(*
this, sub, start,
end);
694 return pystring::isalnum(*
this);
700 return pystring::isalpha(*
this);
706 return pystring::isdigit(*
this);
712 return pystring::islower(*
this);
718 return pystring::isspace(*
this);
724 return pystring::istitle(*
this);
730 return pystring::isupper(*
this);
737 return pystring::ljust(*
this, width);
743 return pystring::lower(*
this);
750 std::size_t start = this->find(toBeRemoved);
752 if (T::length() > toBeRemoved.size()) {
753 return this->substr(toBeRemoved.size(), T::length() );
764 return pystring::lstrip(*
this, chars);
770 return pystring::partition(*
this, sep, result);
776 return pystring::replace(*
this, oldstr, newstr, count);
782 int index = pystring::find(*
this, sub, start,
end);
783 return index < 0 ? AgXString<T>::npos : (size_t)index;
789 int index = pystring::rfind(*
this, sub, start,
end);
790 return index < 0 ? AgXString<T>::npos : (size_t)index;
797 return pystring::rjust(*
this, width);
803 return pystring::rpartition(*
this, sep, result);
809 return pystring::rstrip(*
this, chars);
815 return pystring::split(*
this, result, sep, maxsplit);
821 return pystring::rsplit(*
this, result, sep, maxsplit);
827 return pystring::splitlines(*
this, result, keepends);
833 return pystring::startswith(*
this, prefix, start,
end);
839 return pystring::startswithCI(*
this, prefix, start,
end);
845 if (this->size() == 0)
848 return pystring::strip(*
this, chars);
854 return pystring::swapcase(*
this);
860 return pystring::title(*
this);
866 return pystring::translate(*
this, table, deletechars);
872 return pystring::upper(*
this);
878 return pystring::zfill(*
this, width);
884 return pystring::slice(*
this, start,
end);
888 template <
typename T>
894 template <
typename T>
906 std::swap(
static_cast<std::string&
>(lhs),
static_cast<std::string&
>(rhs));
void swap(agx::Name &lhs, agx::Name &rhs)
AgXString center(int width) const
AgXString swapcase() const
AgXString(const_iterator begin, const_iterator end)
Construct sub-string given iterators.
void splitlines(StringVector &result, bool keepends=false) const
AgXString zfill(int width) const
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(const std::string &str)
Create a AgXString from stl string.
AgXString(const AgXString &str)
Copy constructors.
bool operator!=(const std::string &other) const
bool contains(const AgXString &sub, size_t start=0) const
AgXString strip(const AgXString &chars="") const
AgXString rstrip(const AgXString &chars="") const
AgXString copy() const
Copy method, if implementation of this class is changed.
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.
int index(const AgXString &sub, int start=0, int end=MAX_32BIT_INT) const
Synonym of find right now.
AgXString replace(const AgXString &oldstr, const AgXString &newstr, int count=-1) const
AgXString substr(size_type index) const
AgXString stripLeadingString(const AgXString &toBeRemoved) const
If this string begins with toBeRemoved, it will be removed and returned.
AgXString(const char *str, size_type index, size_type length)
Construct sub-string of str from index and length characters forward.
static AgXString formatVA(const char *format, va_list ap)
bool endswith(const AgXString &suffix, int start=0, int end=MAX_32BIT_INT) const
AgXString(const char *str)
Element type pointer constructor.
AgXString translate(const AgXString &table, const AgXString &deletechars="") const
bool startswithCI(const AgXString &prefix, int start=0, int end=MAX_32BIT_INT) const
AgXString rjust(int width) const
std::string::size_type size_type
std::string::iterator iterator
bool operator==(const std::string &other) const
AgXString capitalize() const
bool endswithCI(const AgXString &suffix, int start=0, int end=MAX_32BIT_INT) const
AgXString slice(int start=0, int end=MAX_32BIT_INT) const
function matching python's slice functionality.
AgXString lstrip(const AgXString &chars="") const
AgXString substr(size_type index, size_type length) const
size_t find(const AgXString &sub, int start=0, int end=MAX_32BIT_INT) const
AgXString expandtabs(int tabsize=8) const
std::string::const_iterator const_iterator
AgXString()
Default constructor.
bool startswith(const AgXString &prefix, int start=0, int end=MAX_32BIT_INT) const
void rpartition(const AgXString &sep, StringVector &result) const
Split the string around last occurrence of sep.
int count(const AgXString &substr, int start=0, int end=MAX_32BIT_INT) const
AgXString operator+(const AgXString &other) const
Operator +, AgXString b = thisAgXString + other.
size_t rfind(const AgXString &sub, int start=0, int end=MAX_32BIT_INT) const
static AgXString format(const char *format,...)
C printf formatting of a string.
AgXString ljust(int width) const
AgXString(const char *str, size_type length)
Construct given str, final length of this string will be length.
void partition(const AgXString &sep, StringVector &result) const
Split the string around first occurrence of sep.
AgXString(size_type length, char ch)
Construct length number of ch.
#define agxVerifyN(expr, format,...)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AgXString< T > operator+(const Indentation &indentation, const AgXString< T > &str)
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
Vector< AgXString< std::string > > StringVector
AgXString< std::string > String
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
agx::String printHex(const T &val)
AGXCORE_EXPORT const agx::String & getEmptyString()
Return a reference to an empty string that is owned by an AGX Dynamics shared library.
agx::String printBin(const T &val)