Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

template<typename>
class Geo::GeoString

STL string replacement.

Standard length doubling strategy allows for continued concatenation. Contains few of the algorithm functions (find_if, etc) but does have conversion from one string format to another. Also contains a Printf() function that creates a string from a standard C style format specifier, without the user having to know the maximum string length beforehand. There is no such thing as a NULL string representation; default constructor and construction from a NULL pointer both result in an empty string. If you must distinguish between empty and unset, use the Geo::Optional class.

Typedefs

NameDescription
T CharType

The character type of this string.

Functions

NameDescription
~GeoString()

Destructor.

Clear()

Clear the string.

CopyTo(T *, s32)

Copies the content of this string to the given raw character buffer.

Crop(s32)

Terminates the string at the given position.

CropAfterLastChar(T)

This will remove the string beyond and including the last character specified if there is one.

CropBeforeLastChar(T)

This will remove the string up to and including the last character specified if there is one.

ForceLength(s32)

Directly sets the length of the string to the given value.

FromUtf8(const char *)

Creates a new string of this format from a narrow string.

GeoString()

Default constructor.

GeoString(const T *)

Explicit constructor from a null-terminated array.

GeoString(const T *, s32)

Explicit constructor from an array of size n.

GeoString(s32)

Explicit constructor for an initial buffer length.

GeoString(const GeoString &)

Copy constructor.

GeoString(GeoString &&)

Move constructor.

GetCapacity()

Returns the string capacity.

GetCString()

Returns a const raw pointer to the string.

GetLength()

Returns the length of the string.

GetString()

Returns a non-const raw pointer to the string.

IsEmpty()

Returns true if the string is empty.

operator GeoStringView< T >()

Implicit conversion to string view.

operator[](s32)

Element access operator. Do not use this to assign a terminator, or the string will very likely be corrupted.

operator<(const GeoString &)

Comparison (required to use strings as keys in a map).

Printf(const T *, ...)

Creates a string from a standard C style format specifier, without the user having to know the maximum string length beforehand.

SetCapacity(s32)

Set the string capacity (increase only).

Substring(Geo::s32, Geo::s32)

Returns a subsection of the string.

Swap(GeoString &)

Swap places with other.

ToUtf8()

Returns a new narrow string from this one.


Anchor
aae39dc8d3d876dc786a660e27cdc595d
aae39dc8d3d876dc786a660e27cdc595d

Geo::GeoString< T >::~GeoString

...

public: ~GeoString()

...

Destructor.


Anchor
aceddc19e7bb75103a30daf7fd43b87d4
aceddc19e7bb75103a30daf7fd43b87d4

void Geo::GeoString< T >::Clear

...

public: void Clear()

...

Clear the string.


Anchor
a1e12a2279a06d14c95c7ee59f7b4c7c1
a1e12a2279a06d14c95c7ee59f7b4c7c1

s32 Geo::GeoString< T >::CopyTo

...

public: s32 CopyTo
(
    T * buffer,
    s32 maxCharsToCopy
) const

...

Copies the content of this string to the given raw character buffer.

Note this does not

...

Parameters
[in]buffer

The destination buffer.

[in]maxCharsToCopy

If this is less than the length of the string then only this many characters will be copied.

Returns

The number of characters copied.


Anchor
a4f0716fe546cd13850eb79a0f9a07ee8
a4f0716fe546cd13850eb79a0f9a07ee8

bool Geo::GeoString< T >::Crop

...

public: bool Crop
(
    s32 position
)

...

Terminates the string at the given position.

If position is less than the current length of the string it returns true, otherwise this is a no-op and returns false.


Anchor
a8a819951dd814135eb4d96fdd0af40dc
a8a819951dd814135eb4d96fdd0af40dc

bool Geo::GeoString< T >::CropAfterLastChar

...

public: bool CropAfterLastChar
(
    T c
)

...

This will remove the string beyond and including the last character specified if there is one.

If there isn't one it won't do anything.

Returns

True if the string was cropped.


Anchor
a6c93472c2d0c576b5635e474ccfb7d77
a6c93472c2d0c576b5635e474ccfb7d77

bool Geo::GeoString< T >::CropBeforeLastChar

...

public: bool CropBeforeLastChar
(
    T c
)

...

This will remove the string up to and including the last character specified if there is one.

If there isn't one it won't do anything.

Returns

True if the string was cropped.


Anchor
ae57398f48f6187ff12b2ea9bcf7cafe1
ae57398f48f6187ff12b2ea9bcf7cafe1

void Geo::GeoString< T >::ForceLength

...

public: void ForceLength
(
    s32 position
)

...

Directly sets the length of the string to the given value.

Useful for when the internal buffer is directly manipulated (after calling GetString()) and the stored length of the string needs to be kept in-sync.


Anchor
abe8e9192f21185b638ebedc294f8682e
abe8e9192f21185b638ebedc294f8682e

static GeoString Geo::GeoString< T >::FromUtf8

...

public: GeoString FromUtf8
(
    const char * utf8
)

...

Creates a new string of this format from a narrow string.


Anchor
adbab55911fa867af826f2cfbd51139a3
adbab55911fa867af826f2cfbd51139a3

Geo::GeoString< T >::GeoString

...

public: GeoString()

...

Default constructor.


Anchor
a6d199b2658213da30ef1d817c15c020b
a6d199b2658213da30ef1d817c15c020b

Geo::GeoString< T >::GeoString

...

public: GeoString
(
    const T * str
)

...

Explicit constructor from a null-terminated array.


Anchor
a54cbc062306a4272ba56cab443016d72
a54cbc062306a4272ba56cab443016d72

Geo::GeoString< T >::GeoString

...

public: GeoString
(
    const T * str,
    s32 n
)

...

Explicit constructor from an array of size n.


Anchor
a31772f87d3e0c6f868929f9eae678b06
a31772f87d3e0c6f868929f9eae678b06

Geo::GeoString< T >::GeoString

...

public: GeoString
(
    s32 capacity
)

...

Explicit constructor for an initial buffer length.


Anchor
adca48682366ed2753cd35dcb46a444c4
adca48682366ed2753cd35dcb46a444c4

Geo::GeoString< T >::GeoString

...

public: GeoString
(
    const GeoString & rhs
)

...

Copy constructor.


Anchor
a1f96b946696fcc71491f32b19bc035f4
a1f96b946696fcc71491f32b19bc035f4

Geo::GeoString< T >::GeoString

...

public: GeoString
(
    GeoString && rhs
)

...

Move constructor.


Anchor
af499910a1828b44dc0e24540e371e6e6
af499910a1828b44dc0e24540e371e6e6

s32 Geo::GeoString< T >::GetCapacity

...

public: s32 GetCapacity() const

...

Returns the string capacity.


Anchor
aadeb78eaf27a2579774f10691c6f9e98
aadeb78eaf27a2579774f10691c6f9e98

const T* Geo::GeoString< T >::GetCString

...

public: const T * GetCString() const

...

Returns a const raw pointer to the string.


Anchor
a1dc76f92f334ba819c53b0caa771c475
a1dc76f92f334ba819c53b0caa771c475

s32 Geo::GeoString< T >::GetLength

...

public: s32 GetLength() const

...

Returns the length of the string.


Anchor
ae543c3b6f55be85186dc5478b62c0ead
ae543c3b6f55be85186dc5478b62c0ead

T* Geo::GeoString< T >::GetString

...

public: T * GetString()

...

Returns a non-const raw pointer to the string.


Anchor
a6b1313ce34ee4479956b73055d220836
a6b1313ce34ee4479956b73055d220836

bool Geo::GeoString< T >::IsEmpty

...

public: bool IsEmpty() const

...

Returns true if the string is empty.


Anchor
a7d20571b49d7e6da38e982dfe3648089
a7d20571b49d7e6da38e982dfe3648089

Geo::GeoString< T >::operator GeoStringView< T >

...

public: operator GeoStringView< T >() const

...

Implicit conversion to string view.


Anchor
af480f26a86324d9f41249d4afe8caaa0
af480f26a86324d9f41249d4afe8caaa0

T Geo::GeoString< T >::operator[]

...

public: T operator[]
(
    s32 idx
) const

...

Element access operator. Do not use this to assign a terminator, or the string will very likely be corrupted.


Anchor
a8db9e96400a50c2287c98d37f16d8e44
a8db9e96400a50c2287c98d37f16d8e44

bool Geo::GeoString< T >::operator<

...

public: bool operator<
(
    const GeoString & rhs
) const

...

Comparison (required to use strings as keys in a map).


Anchor
a96d0156cdb065c2f293dbbd7e617c75e
a96d0156cdb065c2f293dbbd7e617c75e

static GeoString Geo::GeoString< T >::Printf

...

public: GeoString Printf
(
    const T * ,
    ...
)

...

Creates a string from a standard C style format specifier, without the user having to know the maximum string length beforehand.


Anchor
a0f01ea0d646074c59c328420c99f2f17
a0f01ea0d646074c59c328420c99f2f17

bool Geo::GeoString< T >::SetCapacity

...

public: bool SetCapacity
(
    s32 minLength
)

...

Set the string capacity (increase only).


Anchor
a484d61e198523eded0b8eefd3263f2c0
a484d61e198523eded0b8eefd3263f2c0

GeoString Geo::GeoString< T >::Substring

...

public: GeoString Substring
(
    Geo::s32 idxBegin,
    Geo::s32 idxEnd
) const

...

Returns a subsection of the string.

Parameters
[in]idxBegin

Index of first character of substring.

[in]idxEnd

Index of 'one past end' of substring. May specify -1 to mean 'end of string'.


Anchor
a9539f4eea6ef4e9d26f08e2f18ee9d5f
a9539f4eea6ef4e9d26f08e2f18ee9d5f

void Geo::GeoString< T >::Swap

...

public: void Swap
(
    GeoString & other
)

...

Swap places with other.


Anchor
ae1140b5c556010662da6266d28360f58
ae1140b5c556010662da6266d28360f58

GeoString<char> Geo::GeoString< T >::ToUtf8

...

public: GeoString< char > ToUtf8() const

...

Returns a new narrow string from this one.