31 template<
typename T = std::
string>
class AgXString;
194#define MAX_32BIT_INT 2147483647
441 template <
typename T>
444 template <
typename T>
465#include <pystring/pystring.h>
474 va_start(ap, format);
486 int len = _vscprintf( format, ap ) + 1;
487 buf = (
char*) malloc( len *
sizeof(
char) );
489 vsprintf_s( buf, len, format, ap );
491 int ret = vasprintf(&buf, format, ap);
492 agxVerifyN(ret >= 0,
"Could not allocate memory for formatted string: \'%s\'", format);
508 template <
typename T>
514 template <
typename T>
521 template <
typename T>
527 template <
typename T>
533 template <
typename T>
539 template <
typename T>
546 template <
typename T>
548 : T( str, index, length )
553 template <
typename T>
559 template <
typename T>
567 template <
typename T>
575 template <
typename T>
583 template <
typename T>
589 template <
typename T>
592 return AgXString( this->c_str(), index, this->size() );
595 template <
typename T>
598 return AgXString( this->c_str(), index, length );
601 template <
typename T>
604 return static_cast<const std::string&
>(*this) ==
static_cast<const std::string&
>(other);
607 template <
typename T>
610 return *(std::string*)
this == other;
613 template <
typename T>
616 return *(std::string*)
this == other;
619 template <
typename T>
622 return *(std::string*)
this != other;
625 template <
typename T>
628 return *(std::string*)
this != other;
655 return pystring::capitalize(*
this);
661 return pystring::center(*
this, width);
667 return pystring::count(*
this, substr, start,
end);
673 return pystring::endswith(*
this, suffix, start,
end);
679 return pystring::endswithCI(*
this, suffix, start,
end);
685 return pystring::expandtabs(*
this, tabsize);
698 return pystring::index(*
this, sub, start,
end);
704 return pystring::isalnum(*
this);
710 return pystring::isalpha(*
this);
716 return pystring::isdigit(*
this);
722 return pystring::islower(*
this);
728 return pystring::isspace(*
this);
734 return pystring::istitle(*
this);
740 return pystring::isupper(*
this);
747 return pystring::ljust(*
this, width);
753 return pystring::lower(*
this);
760 std::size_t start = this->find(toBeRemoved);
762 if (T::length() > toBeRemoved.size()) {
763 return this->substr(toBeRemoved.size(), T::length() );
774 return pystring::lstrip(*
this, chars);
780 return pystring::partition(*
this, sep, result);
786 return pystring::replace(*
this, oldstr, newstr, count);
792 int index = pystring::find(*
this, sub, start,
end);
793 return index < 0 ? AgXString<T>::npos : (size_t)index;
799 int index = pystring::rfind(*
this, sub, start,
end);
800 return index < 0 ? AgXString<T>::npos : (size_t)index;
807 return pystring::rjust(*
this, width);
813 return pystring::rpartition(*
this, sep, result);
819 return pystring::rstrip(*
this, chars);
825 return pystring::split(*
this, result, sep, maxsplit);
831 return pystring::rsplit(*
this, result, sep, maxsplit);
837 return pystring::splitlines(*
this, result, keepends);
843 return pystring::startswith(*
this, prefix, start,
end);
849 return pystring::startswithCI(*
this, prefix, start,
end);
855 if (this->size() == 0)
858 return pystring::strip(*
this, chars);
864 return pystring::swapcase(*
this);
870 return pystring::title(*
this);
876 return pystring::translate(*
this, table, deletechars);
882 return pystring::upper(*
this);
888 return pystring::zfill(*
this, width);
894 return pystring::slice(*
this, start,
end);
898 template <
typename T>
904 template <
typename T>
916 std::swap(
static_cast<std::string&
>(lhs),
static_cast<std::string&
>(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
Fills "result" with a list of the lines in the string, breaking at line boundaries.
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
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 operator==(const AgXString &other) const
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.
Vector< AgXString< std::string > > StringVector
LinearProbingHashSetImplementation< KeyT, HashT >::iterator end(LinearProbingHashSetImplementation< KeyT, HashT > &set)
AgXString< std::string > String
AGXCORE_EXPORT const agx::String & getEmptyString()
Return a reference to an empty string that is owned by an AGX Dynamics shared library.
LinearProbingHashSetImplementation< KeyT, HashT >::iterator begin(LinearProbingHashSetImplementation< KeyT, HashT > &set)
AgXString< T > operator+(const Indentation &indentation, const AgXString< T > &str)
agx::String printHex(const T &val)
agx::String printBin(const T &val)
void swap(agx::Name &lhs, agx::Name &rhs)