NDEVR
API Documentation

The core String class for the NDEVR API. More...

Inheritance diagram for String:
[legend]
Collaboration diagram for String:
[legend]

Public Member Functions

constexpr String () noexcept
 Constructor used to create an empty String*.
constexpr String (const char *const string, uint04 size)
 String Constructor char arrays when the size is known.
 String (const char *string)
 String Constructor for null terminated array of chars.
template<std::size_t N>
constexpr String (const char(&string)[N])
 String Constructor for static char arrays.
constexpr String (const String &string)
 Copy Constructor.
constexpr String (const StringView &string)
 Constructor for string view.
template<class t_type>
 String (const t_type &value)
 String Constructor that creates a string based off an object.
template<std::size_t N>
 String (const wchar(&string)[N])
 String Constructor for static wchar arrays of UTF16 data.
constexpr String (String &&string) noexcept
 Move contructor (No new memory allocation).
constexpr String (uint04 size, const char &value)
 String Constructor creates a string of a size and fills it with a character.
void addUTF16AsUTF8 (const wchar *unicode)
 Converts a unicode null terminated string of UTF16 wchars into UTF8 and appends it to the end of the String.
bool addUTF16CharAsUTF8 (const wchar *unicode, uint04 &advance)
 Converts a single unicode character at advance into UTF8 and appends it to the end of the String.
void addWChar (const wchar &object)
 Converts a single unicode character UTF16 character into one or more UTF8 characters and appends them to the end of this String.
StringaddWhiteSpace (uint04 desired_string_size, uint04 desired_right_alignment_location=0, char whitespace=' ')
 Used for formatting, will, if necessary, add white space so that the string becomes a certain length.
Stringappend (char value)
 Appends an object to the back of this string.
Stringappend (const char *value)
 Appends a string to the back of this string.
template<size_t t_size>
Stringappend (const char(&value)[t_size])
 Appends a string to the back of this string.
Stringappend (const StringView &string)
 Appends a string to the back of this string.
template<class t_type>
Stringappend (const t_type &value)
 Appends a string to the back of this string.
Stringappend (const wchar *value)
 Appends a string to the back of this string.
Stringappend (const wchar value)
 Appends a wchar utf16 to the back of this string as utf8.
template<size_t t_size>
Stringappend (const wchar(&value)[t_size])
 Appends a string to the back of this string.
bool beginsWith (const StringView &s, bool ignore_case=false) const
 Tests if this String starts with the specified prefix.
constexpr const char * c_str () const
 Used to access the raw memory of this string.
bool endsWith (const StringView &s, bool ignore_case=false) const
 Tests if this String ends with the specified suffix.
StringformatNumberString (bool add_comma, uint04 decimals)
 For a string representing a number, makes the decimals equal to the the provided value and adds comma seperators if number is large enough.
StringformatNumberString (bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, char decimal='.', char comma=',')
 Modifies the contents of this string, that represents a given number using the provided rules.
StringformatNumberString (uint04 decimals)
 For a string representing a number, makes the decimals equal to the the provided value Example: String("1000000").formatNumberString(2); will make "1000000.00".
uint04 fromHex () const
 Converts a hex value into an unsigned 4 byte number.
template<class t_type>
decltype(autogetAs () const
 Converts a string into an object.
constexpr uint08 hash () const
 Creates a simple, quick hash of the object.
uint08 hashLower () const
 Creates a simple, quick hash of the object.
uint08 hashUpper () const
 Creates a simple, quick hash of the object.
bool hasSubString (const StringView &sub_string, bool ignore_case=false, uint04 start_idx=0) const
 Tests if this String contains the specified substring.
uint04 indexOf (const char &sub_string) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
uint04 indexOf (const char &sub_string, uint04 start_pos) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
uint04 indexOf (const char &sub_string, uint04 start_pos, uint04 size) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
uint04 indexOf (const char *sub_string, bool ignore_case, uint04 start_index, uint04 size) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
uint04 indexOf (const char *sub_string, bool ignore_case=false, uint04 start_index=0) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
uint04 indexOf (const char *sub_string, char escape_char, bool ignore_case=false, uint04 start_index=0) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
uint04 indexOf (const String &sub_string, bool ignore_case=false, uint04 start_index=0) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
uint04 indexOf (const StringView &sub_string, bool ignore_case=false, uint04 start_index=0) const
 Given a substring specified by the input, returns the first index of that string, if it exists.
String insertNewLines (uint04 max_line_size) const
 Finds key areas to insert new lines such that the rows are at most, the length provided.
bool isNumeric () const
 Checks to see if the string is a numeric string.
bool isSameNoCase (const StringView &s) const
 Checks whether two strings match in a case-insensitive way.
uint04 lastIndexOf (const char *sub_string, bool ignore_case=false) const
 Given a substring specified by the input, returns the last index of that string, if it exists.
uint04 lastIndexOf (const char value, bool ignore_case=false) const
 Given a value specified by the input, returns the last index of that char, if it exists.
uint04 lastIndexOf (const StringView &sub_string, bool ignore_case=false) const
 Given a substring specified by the input, returns the last index of that string, if it exists.
bool matchesWildcard (const StringView &pattern) const
 Checks whether two strings match allowing '' to be used as a wildcard pattern.
String predictNextStringIncrement () const
 Looks in the string for key markers that might be an index, and attempts to increment the index.
StringremoveNonAlphaNumeric (bool remove_tab=true, bool remove_space=true, bool remove_new_line=true, bool remove_r=true, bool remove_numbers=false)
 Removes any characters that aren't numbers or letters with other options available.
StringremoveNonNumeric ()
 Removes anything that is not a number or decimal ('0'-'9' or .).
Stringreplace (const StringView &sub_string, const StringView &replace_sub_string, bool ignore_case=false, uint04 start_index=0)
 Replaces ALL instances of a given substring with the provided replacement.
Stringreplace (const StringViewBuffer &sub_string, const StringBuffer &replace_sub_string, bool ignore_case=false, uint04 start_index=0)
 Replaces ALL instances of the given substrings with the provided replacements.
Stringreplace (const StringViewBuffer &sub_string, const StringViewBuffer &replace_sub_string, bool ignore_case=false, uint04 start_index=0)
 Replaces ALL instances of the given substrings with the provided replacements.
StringAllocatingView shortenString (uint04 size) const
 Shortens the string to the max size provided.
StringViewBuffer split (char delimiter, bool preserve_empty=true) const
 Given a delimiter, breaks the string into subsections, returning an array of each subsection.
StringViewBuffer split (const Buffer< char > &delimiter, bool preserve_empty=true) const
 Given multiple delimiter, breaks the string into subsections, returning an array of each subsection.
void splitString (char delimiter, StringViewBuffer &strings, bool preserve_empty=true) const
 Given multiple delimiter, breaks the string into subsections, and APPENDS each substring to the given Buffer.
void splitString (const Buffer< char > &delimiter, StringViewBuffer &strings, bool preserve_empty=true) const
 Given multiple delimiter, breaks the string into subsections, and APPENDS each substring to the given Buffer.
StringView substr (uint04 start) const
 Creates a substring from a given start position, to the end of the string.
StringView substr (uint04 start, uint04 end) const
 Creates a substring from a given start position, to the given end position, non-inclusive of the end index.
StringAllocatingView toLower () const
 changes all upper case characters into lower case characters.
String toTitleString () const
 Formats the string to be a title, capitalizing important characters and replacing underscores with spaces.
StringAllocatingView toUpper () const
 changes all lower case characters into upper case characters.
StringtrimWhiteSpace ()
 Trims any white space (tabs, spaces, etc) from the beginning and end of the string.
Public Member Functions inherited from Buffer< char, BufferAllocator< char, 0, true, uint04, true > >
constexpr Buffer () noexcept
 Creates an empty buffer.
 ~Buffer ()
void add (char &&object)
 Adds object to the end of the buffer.
void addSpace (t_index_type space_to_add)
 Adds a space to the end of the buffer.
operator decltype auto () const
 Gets the first location of type* in the array.
sint04 compare (const Buffer &value) const
 Compares this Buffer to another to determine their relative ordering.
Buffer< t_other_type, t_other_memory_manager > getAs () const
 Gets a copy of this buffer, with filled objects t_other_type, where all objects are created using the contents of this buffer.
void insert (t_index_type location, const char &object)
 Adds an object to a specific location.
void removeAllOrdered (const char &object)
 Removes all instances of the object.
void removeAllOrderedFn (const t_functor &functor)
 Removes all items based on the functor.
void removeAllUnordered (const char &object)
 Removes all unordered described by object.

Static Public Member Functions

static bool AlphaNumericCompare (const StringView &left, const StringView &right)
 Compares two strings given their alpha-numeric determined value.
template<class t_type>
static TranslatedString DisplayString (const t_type &value)
 Converts an object into a TranslatedString.
static constexpr uint08 hash (const char *value)
 constexpr method to hash a value.
static bool IsNumeric (char value)
 Checks to see if the char is a numeric string.
static bool IsWhiteSpace (char s)
 Checks whether a given character is a whitespace character or not.
static String NumberString (fltp08 value, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, char decimal='.', char comma=',')
 Creates a string from a given number using the provided rules.
static constexpr uint04 str_len (const char *value)
 constexpr method to get the length of a null-terminated string at compile time
static constexpr uint04 str_len (const wchar *value)
 constexpr method to get the UTF8 length of a null-terminated string at compile time
static String ToAlphaString (uint04 number)
 Converts a number into a char string.
static String ToHex (char value)
 Converts the memory of the given object into a hexidecimal string.
template<class t_object, class t_allocator>
static String ToHex (const Buffer< t_object, t_allocator > &values)
 Converts a buffer of objects into a hexidecimal string.
static String ToHex (const StringView &values)
 Converts a string of any type of data (assumed to be binary) into a hex representation.
template<uint01 t_size, class t_type>
static String ToHex (const Vector< t_size, t_type > &values)
 Converts a vector into a hex representation.
template<class t_object>
static std::enable_if< ObjectInfo< t_object >::Integer, String >::type ToHex (t_object value)
 Converts the memory of the given object into a hexidecimal string.
static String ToHex (uint01 value)
 Converts the memory of the given object into a hexidecimal string.
static constexpr Vector< 2, char > ToHexVec (char value)
 Converts the memory of the given object into a hexidecimal string.
static constexpr Vector< 2, char > ToHexVec (uint01 value)
 Converts the memory of the given object into a hexidecimal string.
static String UTF16toUTF8 (const wchar *unicode, uint04 &advance)
 Converts a single unicode character at advance into UTF8 and and returns it as a String.
static wchar UTF8toUTF16 (const char *utf8, uint04 &advance)
 Converts a unicode null terminated string of chars into a UTF16 wchar and increments advance by the ammount of characters consumed to make the UTF16 character.

Detailed Description

The core String class for the NDEVR API.


This String class:

  • Explicitly uses Unicode (UTF8)
  • Easy functions for converting to anything (getAs<class>())
  • Inherits faster Buffer class
  • Provides a quick way to easily convert classes to and from a string in a modular way.

See StringStream for details on providing a definition that will allow any object to be used as a constructor for String, or convert a String into any object using getAs<...>()

The string container is guaranteed to be null-terminated meaning that c_str() and begin() will both point directly into the data structure.

TranslatedString should be used, when possible, for any data that will be displayed to the user.

Strings can be used in case statements using string.hash[upper/lower]()

switch (string.hashUpper())
{
case String::hash("DEFAULT"): value = CompressionMode::e_default; break;
case String::hash("BEST"): value = CompressionMode::e_best; break;
case String::hash("NONE"): value = CompressionMode::e_none; break;
}
constexpr uint08 hash() const
Creates a simple, quick hash of the object.
Definition String.h:524
uint08 hashUpper() const
Creates a simple, quick hash of the object.
@ e_none
No defined value type.
CompressionMode
Forward declaration of the Module struct for module metadata.
Definition Compressor.h:17

Since the String is null terminated, declaring a String using String(256) will allocate 257 bytes on the heap. Thus for memory management, block sizes should be one smaller.

See also
StringView, TranslatedString, PasswordString

Definition at line 94 of file String.h.

Constructor & Destructor Documentation

◆ String() [1/7]

String::String ( const StringView & string)
inlineexplicitconstexpr

Constructor for string view.

Limit use to reduce string memory consumption

Definition at line 114 of file String.h.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer().

◆ String() [2/7]

template<std::size_t N>
String::String ( const char(&) string[N])
inlineexplicitconstexpr

String Constructor for static char arrays.

Parameters
[in]stringThe array of characters making up the string. Should be in Unicode (UTF8)

Definition at line 132 of file String.h.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer(), and str_len().

◆ String() [3/7]

template<std::size_t N>
String::String ( const wchar(&) string[N])
inlineexplicit

String Constructor for static wchar arrays of UTF16 data.

Parameters
[in]stringUTF16 array of characters making up the string, will be converted to UTF8.

Definition at line 140 of file String.h.

References addUTF16AsUTF8().

◆ String() [4/7]

String::String ( const char * string)
inlineexplicit

String Constructor for null terminated array of chars.

Parameters
[in]stringThe array of characters making up the string. Should be in Unicode (UTF8) and null terminated.

Definition at line 149 of file String.h.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer(), and str_len().

◆ String() [5/7]

String::String ( const char *const string,
uint04 size )
inlineconstexpr

String Constructor char arrays when the size is known.

Slightly faster than iterating over a null-terminated array.

Parameters
[in]stringThe array of characters making up the string. Should be in Unicode (UTF8)
[in]sizeThe size of the string

Definition at line 158 of file String.h.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer().

◆ String() [6/7]

String::String ( uint04 size,
const char & value )
inlineconstexpr

String Constructor creates a string of a size and fills it with a character.

Parameters
[in]sizeThe size of the string
[in]valueThe value to set all characters in the string to.

Definition at line 169 of file String.h.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer().

◆ String() [7/7]

template<class t_type>
String::String ( const t_type & value)
explicit

String Constructor that creates a string based off an object.

To use this function an object must have overwritten StringStream<t_type>::toString.

Parameters
[in]valueThe value to use as a reference to generate a string representation.

Definition at line 1579 of file String.h.

References StringView::begin(), StringView::size(), and StringStream< t_type >::toString().

Member Function Documentation

◆ addUTF16AsUTF8()

void String::addUTF16AsUTF8 ( const wchar * unicode)

Converts a unicode null terminated string of UTF16 wchars into UTF8 and appends it to the end of the String.

Parameters
[in]unicodeThe UTF16 null-terminated string of chars to append to this string

Referenced by String(), append(), and append().

◆ addUTF16CharAsUTF8()

bool String::addUTF16CharAsUTF8 ( const wchar * unicode,
uint04 & advance )

Converts a single unicode character at advance into UTF8 and appends it to the end of the String.

Parameters
[in]unicodeThe UTF16 string of chars to append to this string
[in,out]advancethe location in unicode to append, will be incremented based on number of UT16 characters consumed (1 or 2).

◆ addWChar()

void String::addWChar ( const wchar & object)

Converts a single unicode character UTF16 character into one or more UTF8 characters and appends them to the end of this String.

Parameters
[in]objectThe UTF16 encoded object to append.

References String().

Referenced by append().

◆ addWhiteSpace()

String & String::addWhiteSpace ( uint04 desired_string_size,
uint04 desired_right_alignment_location = 0,
char whitespace = ' ' )

Used for formatting, will, if necessary, add white space so that the string becomes a certain length.

desired_right_alignment_location Will try and align the string to a location by prepending whitspace. desired_string_size will append space to try and make the string a given size.

Parameters
[in]desired_string_sizeThe size the string should be once whitespace is added to the end.
[in]desired_right_alignment_locationIf the string is smaller than desired_right_alignment_location will add whitespace until the rightmost terminating index is equal to desired_right_alignment_location.
[in]whitespacethe character to use for whitespace.
Returns
A reference to this String.

References String().

◆ AlphaNumericCompare()

bool String::AlphaNumericCompare ( const StringView & left,
const StringView & right )
static

Compares two strings given their alpha-numeric determined value.

Returns
True if left is LESS than right.

◆ append() [1/8]

String & String::append ( char value)
inline

Appends an object to the back of this string.

Parameters
[in]valueThe value to append.
Returns
A reference to this string.

Definition at line 454 of file String.h.

References String(), and Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::add().

◆ append() [2/8]

String & String::append ( const char * value)
inline

Appends a string to the back of this string.

Parameters
[in]valueThe value to append.
Returns
A reference to this string.

Definition at line 482 of file String.h.

References String().

◆ append() [3/8]

template<size_t t_size>
String & String::append ( const char(&) value[t_size])
inline

Appends a string to the back of this string.

Parameters
[in]valueThe value to append.
Returns
A reference to this string.

Definition at line 472 of file String.h.

References String().

◆ append() [4/8]

String & String::append ( const StringView & string)

Appends a string to the back of this string.

Parameters
[in]stringThe string to append.
Returns
A reference to this string.

References String().

Referenced by IMUNoiseSimulator::addVector(), and IMUNoiseSimulator::setVector().

◆ append() [5/8]

template<class t_type>
String & String::append ( const t_type & value)

Appends a string to the back of this string.

Parameters
[in]valueThe value to append.
Returns
A reference to this string.

Definition at line 1645 of file String.h.

References String(), StringView::begin(), StringView::m_size, StringView::m_start, StringView::size(), and StringStream< t_type >::toString().

◆ append() [6/8]

String & String::append ( const wchar * value)
inline

Appends a string to the back of this string.

Parameters
[in]valueThe value to append.
Returns
A reference to this string.

Definition at line 503 of file String.h.

References String(), and addUTF16AsUTF8().

◆ append() [7/8]

String & String::append ( const wchar value)
inline

Appends a wchar utf16 to the back of this string as utf8.

Parameters
[in]valueThe value to append.
Returns
A reference to this string.

Definition at line 513 of file String.h.

References String(), and addWChar().

◆ append() [8/8]

template<size_t t_size>
String & String::append ( const wchar(&) value[t_size])
inline

Appends a string to the back of this string.

Parameters
[in]valueThe value to append.
Returns
A reference to this string.

Definition at line 493 of file String.h.

References String(), and addUTF16AsUTF8().

◆ beginsWith()

bool String::beginsWith ( const StringView & s,
bool ignore_case = false ) const

Tests if this String starts with the specified prefix.

Parameters
[in]sthe value to test against the start of this string.
[in]ignore_casewhether or not to check using case sensitivity.
Returns
true if the String begins with this value

Referenced by TableColumnBuffer< t_type >::beginsWith(), ShaderTools::compileShader(), and TranslationTools::processString().

◆ c_str()

const char * String::c_str ( ) const
inlineconstexpr

Used to access the raw memory of this string.

Returns
A pointer to the internal memory of the string which is guaranteed to be null terminated.

Definition at line 423 of file String.h.

Referenced by TAR::Extract(), and hash().

◆ DisplayString()

template<class t_type>
TranslatedString String::DisplayString ( const t_type & value)
static

Converts an object into a TranslatedString.

Converts a value to a user-facing TranslatedString using the appropriate StringStream formatter.

To use this function an object must have overwritten StringStream<t_type>::toDisplayString.

Returns
The user-friendly string representation of this object.
Parameters
[in]valueThe value to convert to a display string.
Returns
A TranslatedString representing the display form of the value.

Definition at line 194 of file TranslatedString.h.

References StringStream< t_type >::toDisplayString().

Referenced by HardwareCommandQueue< t_type >::getCommandCSVInfo(), HardwareCommandQueue< t_type >::getCommandJSONInfo(), DevActionTree::init(), HardwareCommandQueue< t_type >::setFromJSONInfo(), DesignObjectStringWidget::setNDPO(), DesignObjectToggleWidget::setNDPO(), DesignObjectStringWidget::setTitle(), QCustomComboBox::setup(), QCustomComboBox::setup(), and QCustomComboBox::setup().

◆ endsWith()

bool String::endsWith ( const StringView & s,
bool ignore_case = false ) const

Tests if this String ends with the specified suffix.

Parameters
[in]sthe value to test against the start of this string.
[in]ignore_casewhether or not to check using case sensitivity.
Returns
true if the String begins with this value

◆ formatNumberString() [1/3]

String & String::formatNumberString ( bool add_comma,
uint04 decimals )

For a string representing a number, makes the decimals equal to the the provided value and adds comma seperators if number is large enough.

Warning
Undefined behavior if this string does not represent a single number. Example: String("1000000").formatNumberString(true, 2); will make "1,000,000.00"
Parameters
[in]add_commaAdds comma seperators if number is large enough
[in]decimalsthe set number of decimals the string should have.
Returns
A reference to this String.

References String().

◆ formatNumberString() [2/3]

String & String::formatNumberString ( bool add_comma,
uint04 min_decimals,
uint04 max_decimals,
uint04 min_digits,
char decimal = '.',
char comma = ',' )

Modifies the contents of this string, that represents a given number using the provided rules.

Warning
Undefined behavior if this string does not represent a single number.
Parameters
[in]add_commaAdds comma seperators if number is large enough
[in]min_decimalsThe minimum number of decimals the formatted number should have (will add 0's to end)
[in]max_decimalsThe maximum number of decimals the formatted number should have (will remove more decimals)
[in]min_digitsThe minimum number of digits the formatted number should have (will add 0's to the begining)
[in]decimalThe character to use as the decimal ('.')
[in]commaThe character to use as the comma (',')
Returns
A reference to this String.

References String().

◆ formatNumberString() [3/3]

String & String::formatNumberString ( uint04 decimals)

For a string representing a number, makes the decimals equal to the the provided value Example: String("1000000").formatNumberString(2); will make "1000000.00".

Warning
Undefined behavior if this string does not represent a single number.
Parameters
[in]decimalsthe set number of decimals the string should have.
Returns
A reference to this String.

References String().

◆ fromHex()

uint04 String::fromHex ( ) const

Converts a hex value into an unsigned 4 byte number.

Returns
the hex value of this string or Constant<uint04>::Invalid if this is not a hex string.

◆ getAs()

◆ hash() [1/2]

uint08 String::hash ( ) const
inlineconstexpr

Creates a simple, quick hash of the object.

See hash(const char* value) for details of the implementation.

Returns
A hash value for this string.

Definition at line 524 of file String.h.

References c_str(), and StringView::hash().

Referenced by File::operator()(), and GLESShader::uniformLocation().

◆ hash() [2/2]

constexpr uint08 String::hash ( const char * value)
inlinestaticconstexpr

constexpr method to hash a value.

Also provides the hashing method used throughout the API to hash strings.

Returns
A hash value.
Warning
This is not designed to get the length of the wchar* array, but rather the length of a char* array that represents this array.

Definition at line 1041 of file String.h.

References StringView::hash().

◆ hashLower()

uint08 String::hashLower ( ) const

Creates a simple, quick hash of the object.

See hash(const char* value) for details of the implementation.

Returns
A hash value for this string as if where all lowercase.

◆ hashUpper()

uint08 String::hashUpper ( ) const

Creates a simple, quick hash of the object.

See hash(const char* value) for details of the implementation.

Returns
A hash value for this string as if it were all uppercase.

◆ hasSubString()

bool String::hasSubString ( const StringView & sub_string,
bool ignore_case = false,
uint04 start_idx = 0 ) const

Tests if this String contains the specified substring.

Parameters
[in]sub_stringthe value to test for containment.
[in]ignore_casewhether or not to check using case sensitivity.
Returns
true if the String contains this value

Referenced by RealSenseServer::checkRecieve(), and TableColumnBuffer< t_type >::contains().

◆ indexOf() [1/8]

uint04 String::indexOf ( const char & sub_string) const
inline

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

Definition at line 255 of file String.h.

◆ indexOf() [2/8]

uint04 String::indexOf ( const char & sub_string,
uint04 start_pos ) const
inline

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]start_posThe index of where to begin searching for the sub_string.
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

Definition at line 264 of file String.h.

◆ indexOf() [3/8]

uint04 String::indexOf ( const char & sub_string,
uint04 start_pos,
uint04 size ) const
inline

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]start_posThe index of where to begin searching for the sub_string.
[in]sizeThe max span to continue searching for the sub_string. The sub_string must entirely reside within the span from start_pos to sie to be valid.
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

Definition at line 275 of file String.h.

◆ indexOf() [4/8]

uint04 String::indexOf ( const char * sub_string,
bool ignore_case,
uint04 start_index,
uint04 size ) const

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]ignore_casewhether or not to check using case sensitivity.
[in]start_indexThe index of where to begin searching for the sub_string.
[in]sizeThe max span to continue searching for the sub_string. The sub_string must entirely reside within the span from start_pos to sie to be valid.
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

◆ indexOf() [5/8]

uint04 String::indexOf ( const char * sub_string,
bool ignore_case = false,
uint04 start_index = 0 ) const

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]ignore_casewhether or not to check using case sensitivity.
[in]start_indexThe index of where to begin searching for the sub_string.
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

◆ indexOf() [6/8]

uint04 String::indexOf ( const char * sub_string,
char escape_char,
bool ignore_case = false,
uint04 start_index = 0 ) const

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]escape_charThe char that when encountered, ends the search.
[in]ignore_casewhether or not to check using case sensitivity.
[in]start_indexThe index of where to begin searching for the sub_string.
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

◆ indexOf() [7/8]

uint04 String::indexOf ( const String & sub_string,
bool ignore_case = false,
uint04 start_index = 0 ) const

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]ignore_casewhether or not to check using case sensitivity.
[in]start_indexThe index of where to begin searching for the sub_string.
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

References String().

◆ indexOf() [8/8]

uint04 String::indexOf ( const StringView & sub_string,
bool ignore_case = false,
uint04 start_index = 0 ) const

Given a substring specified by the input, returns the first index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]ignore_casewhether or not to check using case sensitivity.
[in]start_indexThe index of where to begin searching for the sub_string.
Returns
The first index pointing to the beginning of the substring, if it exists. If it is not found, Constant<uint04>::Invalid is returned.

Referenced by JSONToStringHelper< Time >::Convert(), TranslationTools::convertFromBrackets(), TranslationTools::processString(), RealSenseServer::ReadNetworkPacket(), and TranslationTools::setupFile().

◆ insertNewLines()

String String::insertNewLines ( uint04 max_line_size) const

Finds key areas to insert new lines such that the rows are at most, the length provided.

Parameters
[in]max_line_sizeThe max size of any row of the resulting string
Returns
A string with the new lines inserted appropriately

References String().

◆ IsNumeric()

bool String::IsNumeric ( char value)
static

Checks to see if the char is a numeric string.

(-, +, ., 0-9 considered numeric).

Parameters
valuethe char to check to see if it is numeric.
Returns
true if the char could be representing a number, false if some non-numeric data is present.

◆ isNumeric()

bool String::isNumeric ( ) const

Checks to see if the string is a numeric string.

Returns
true if the string could be representing a number, false if some non-numeric data is present.

◆ isSameNoCase()

bool String::isSameNoCase ( const StringView & s) const

Checks whether two strings match in a case-insensitive way.

Parameters
[in]sThe string to compare against
Returns
True if the strings match in a case insensitive way.

◆ IsWhiteSpace()

bool String::IsWhiteSpace ( char s)
static

Checks whether a given character is a whitespace character or not.

Parameters
[in]sthe character to check against.
Returns
true if the character is considered by the software to be whitespace, false if not.

◆ lastIndexOf() [1/3]

uint04 String::lastIndexOf ( const char * sub_string,
bool ignore_case = false ) const

Given a substring specified by the input, returns the last index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]ignore_casewhether or not to check using case sensitivity.
Returns
The last index of pointing to the beginning of the substring, if it exists. If it does not exist, Constant<uint04>::Invalid is returned.

◆ lastIndexOf() [2/3]

uint04 String::lastIndexOf ( const char value,
bool ignore_case = false ) const

Given a value specified by the input, returns the last index of that char, if it exists.

Parameters
[in]valuethe value to find in the String
[in]ignore_casewhether or not to check using case sensitivity.
Returns
The last index of pointing to the beginning of the substring, if it exists. If it does not exist, Constant<uint04>::Invalid is returned.

◆ lastIndexOf() [3/3]

uint04 String::lastIndexOf ( const StringView & sub_string,
bool ignore_case = false ) const

Given a substring specified by the input, returns the last index of that string, if it exists.

Parameters
[in]sub_stringthe value to find in the String
[in]ignore_casewhether or not to check using case sensitivity.
Returns
The last index of pointing to the beginning of the substring, if it exists. If it does not exist, Constant<uint04>::Invalid is returned.

◆ matchesWildcard()

bool String::matchesWildcard ( const StringView & pattern) const

Checks whether two strings match allowing '' to be used as a wildcard pattern.

For example, String("Hello").matchesWildcard("*ll") would return true.

Parameters
[in]patternThe pattern used to check the string against.
Returns
true if the string matches a given wild card pattern.

◆ NumberString()

String String::NumberString ( fltp08 value,
bool add_comma,
uint04 min_decimals,
uint04 max_decimals,
uint04 min_digits,
char decimal = '.',
char comma = ',' )
static

Creates a string from a given number using the provided rules.

Warning
If the value is Invalid, the resulting string will be "NaN".
Parameters
[in]valueThe value to convert to a string.
[in]add_commaAdds comma seperators if number is large enough
[in]min_decimalsThe minimum number of decimals the formatted number should have (will add 0's to end)
[in]max_decimalsThe maximum number of decimals the formatted number should have (will remove more decimals)
[in]min_digitsThe minimum number of digits the formatted number should have (will add 0's to the begining)
[in]decimalThe character to use as the decimal ('.')
[in]commaThe character to use as the comma (',')
Returns
A reference to this String.

References String().

◆ predictNextStringIncrement()

String String::predictNextStringIncrement ( ) const

Looks in the string for key markers that might be an index, and attempts to increment the index.

If no index is found a "1" will be inserted to the end of the string.

Returns
A string that represents an incremented index

References String().

◆ removeNonAlphaNumeric()

String & String::removeNonAlphaNumeric ( bool remove_tab = true,
bool remove_space = true,
bool remove_new_line = true,
bool remove_r = true,
bool remove_numbers = false )

Removes any characters that aren't numbers or letters with other options available.

Parameters
[in]remove_tabWhether or not to remove tabs
[in]remove_spaceWhether or not to remove spaces
[in]remove_new_lineWhether or not to remove new lines '\n'
[in]remove_rWhether or not to remove carage return '\r'
[in]remove_numbersWhether or not to remove numbers.
Returns
A reference to this String.

References String().

◆ removeNonNumeric()

String & String::removeNonNumeric ( )

Removes anything that is not a number or decimal ('0'-'9' or .).

Returns
A reference to this String.

References String().

◆ replace() [1/3]

String & String::replace ( const StringView & sub_string,
const StringView & replace_sub_string,
bool ignore_case = false,
uint04 start_index = 0 )

Replaces ALL instances of a given substring with the provided replacement.

Parameters
[in]sub_stringThe subsring to replace
[in]replace_sub_stringThe string to replace ALL instances of the provided sub_string with.
[in]ignore_casewhether or not to check using case sensitivity checks. This will not affect the replacement value, only which parts to replace.
Returns
A reference to this String.

References String().

Referenced by BoilerMaker::boiler(), TranslationTools::convertFromBrackets(), and TranslationTools::replaceStringVars().

◆ replace() [2/3]

String & String::replace ( const StringViewBuffer & sub_string,
const StringBuffer & replace_sub_string,
bool ignore_case = false,
uint04 start_index = 0 )

Replaces ALL instances of the given substrings with the provided replacements.

This allows safe replacement when the replacement string might contain the same data being replaced.

Parameters
[in]sub_stringThe subsrings to replace
[in]replace_sub_stringThe strings to replace ALL instances of the provided sub_string with.
[in]ignore_casewhether or not to check using case sensitivity checks. This will not affect the replacement value, only which parts to replace.
Returns
A reference to this String.

References String().

◆ replace() [3/3]

String & String::replace ( const StringViewBuffer & sub_string,
const StringViewBuffer & replace_sub_string,
bool ignore_case = false,
uint04 start_index = 0 )

Replaces ALL instances of the given substrings with the provided replacements.

This allows safe replacement when the replacement string might contain the same data being replaced.

Parameters
[in]sub_stringThe subsrings to replace
[in]replace_sub_stringThe strings to replace ALL instances of the provided sub_string with.
[in]ignore_casewhether or not to check using case sensitivity checks. This will not affect the replacement value, only which parts to replace.
Returns
A reference to this String.

References String().

◆ shortenString()

StringAllocatingView String::shortenString ( uint04 size) const

Shortens the string to the max size provided.

If string is longer, searches for an ideal place to insert "..." (ellipsis)

Parameters
[in]sizeThe max size of the new string.
Returns
The shortened String

◆ split() [1/2]

StringViewBuffer String::split ( char delimiter,
bool preserve_empty = true ) const
nodiscard

Given a delimiter, breaks the string into subsections, returning an array of each subsection.

If the String is empty, an empty String will be appended to the output if preserve_empty is true.

For example, String("The quick, dog,,jumped").splitString(',', true) would return {"The quick", " dog", "", "jumped"}

Parameters
[in]delimiterThe delimiter to split the string
[in]preserve_emptyIf true, when two delimiters are encountered, an empty string is added to the return Buffer. If false, there will be no added empty strings.
Returns
A Buffer of substrings that were broken apart from this string using the delimiter.

Referenced by RealSenseServer::checkRecieve().

◆ split() [2/2]

StringViewBuffer String::split ( const Buffer< char > & delimiter,
bool preserve_empty = true ) const
nodiscard

Given multiple delimiter, breaks the string into subsections, returning an array of each subsection.

If the String is empty, an empty String will be appended to the output if preserve_empty is true. For example, String("The quick, dog,,jumped").splitString({',', ' '}, true) would return {"The", "quick", "dog", "", "jumped"}

Parameters
[in]delimiterThe delimiter to split the string
[in]preserve_emptyIf true, when two delimiters are encountered, an empty string is added to the return Buffer. If false, there will be no added empty strings.
Returns
A Buffer of substrings that were broken apart from this string using the delimiters.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer().

◆ splitString() [1/2]

void String::splitString ( char delimiter,
StringViewBuffer & strings,
bool preserve_empty = true ) const

Given multiple delimiter, breaks the string into subsections, and APPENDS each substring to the given Buffer.

If the String is empty, an empty Buffer will be appended if preserve_empty is true.

Parameters
[in]delimiterThe delimiter to split the string
[in]preserve_emptyIf true, when two delimiters are encountered, an empty string is added to the return Buffer. If false, there will be no added empty strings.
[out]stringswill be appended with substrings that were broken apart from this string using the delimiter.

◆ splitString() [2/2]

void String::splitString ( const Buffer< char > & delimiter,
StringViewBuffer & strings,
bool preserve_empty = true ) const

Given multiple delimiter, breaks the string into subsections, and APPENDS each substring to the given Buffer.

If the String is empty, an empty String will be appended if preserve_empty is true.

Parameters
[in]delimiterThe delimiter to split the string
[in]preserve_emptyIf true, when two delimiters are encountered, an empty string is added to the return Buffer. If false, there will be no added empty strings.
[out]stringswill be appended with substrings that were broken apart from this string using the delimiter.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer().

◆ str_len() [1/2]

constexpr uint04 String::str_len ( const char * value)
inlinestaticconstexpr

constexpr method to get the length of a null-terminated string at compile time

Parameters
[in]valueA null terminated string.
Returns
the length of the string.

Definition at line 989 of file String.h.

References cast().

Referenced by String(), String(), and HashMaker::hash().

◆ str_len() [2/2]

constexpr uint04 String::str_len ( const wchar * value)
inlinestaticconstexpr

constexpr method to get the UTF8 length of a null-terminated string at compile time

Warning
This is not designed to get the length of the wchar* array, but rather the length of a char* array that represents this array.
Parameters
[in]valueA null-terminated UTF16 wchar string.
Returns
the length of the String object that would be created from this object.

Definition at line 1004 of file String.h.

◆ substr() [1/2]

StringView String::substr ( uint04 start) const

Creates a substring from a given start position, to the end of the string.

Parameters
[in]startThe index where to start the substring.
Returns
the substring starting at start.

Referenced by JSONToStringHelper< Time >::Convert(), TranslationTools::convertFromBrackets(), TranslationTools::processString(), and TranslationTools::setupFile().

◆ substr() [2/2]

StringView String::substr ( uint04 start,
uint04 end ) const

Creates a substring from a given start position, to the given end position, non-inclusive of the end index.

If the end index is greater than the size of the string, all data past start is returned.

Parameters
[in]startthe index where to start the substring.
[in]endthe index where to end the substring (non-inclusive).
Returns
the substring starting at start, going until end index or the end of the string.

◆ ToAlphaString()

String String::ToAlphaString ( uint04 number)
static

Converts a number into a char string.

For example 0 will become 'A' and 27 will become 'AA'

Parameters
[in]numberThe number to convert to a character representation.

References String().

Referenced by RealSenseMotor::RealSenseMotor(), RealSenseMotor::getLocation(), and RealSenseMotor::setLocation().

◆ ToHex() [1/6]

String String::ToHex ( char value)
inlinestatic

Converts the memory of the given object into a hexidecimal string.

Parameters
[in]valueThe value to convert to a hex form.
Returns
A string filled with the hex values representing the given object

Definition at line 904 of file String.h.

References String(), and ToHexVec().

◆ ToHex() [2/6]

template<class t_object, class t_allocator>
String String::ToHex ( const Buffer< t_object, t_allocator > & values)
inlinestatic

Converts a buffer of objects into a hexidecimal string.

Parameters
[in]valuesThe values to convert to a hex form.
Returns
A string filled with the hex values representing the given object

Definition at line 935 of file String.h.

References Buffer< char, BufferAllocator< char, 0, true, uint04, true > >::Buffer(), String(), and ToHex().

◆ ToHex() [3/6]

String String::ToHex ( const StringView & values)
inlinestatic

Converts a string of any type of data (assumed to be binary) into a hex representation.

Parameters
[in]valuesRaw binary data in the form of a string.
Returns
A string filled with the hex values representing the given object

Definition at line 950 of file String.h.

References String(), StringView::size(), and ToHexVec().

◆ ToHex() [4/6]

template<uint01 t_size, class t_type>
String String::ToHex ( const Vector< t_size, t_type > & values)
inlinestatic

Converts a vector into a hex representation.

Parameters
[in]valuesRaw binary data in the form of a string.
Returns
A string filled with the hex values representing the given object

Definition at line 968 of file String.h.

References String(), cast(), and ToHex().

◆ ToHex() [5/6]

template<class t_object>
std::enable_if< ObjectInfo< t_object >::Integer, String >::type String::ToHex ( t_object value)
inlinestatic

Converts the memory of the given object into a hexidecimal string.

Parameters
[in]valueThe value to convert to a hex form.
Returns
A string filled with the hex values representing the given object

Definition at line 915 of file String.h.

References String(), cast(), rcast(), and ToHexVec().

◆ ToHex() [6/6]

String String::ToHex ( uint01 value)
inlinestatic

Converts the memory of the given object into a hexidecimal string.

Parameters
[in]valueThe value to convert to a hex form.
Returns
A string filled with the hex values representing the given object

Definition at line 894 of file String.h.

References String(), and ToHexVec().

Referenced by ToHex(), and ToHex().

◆ ToHexVec() [1/2]

constexpr Vector< 2, char > String::ToHexVec ( char value)
inlinestaticconstexpr

Converts the memory of the given object into a hexidecimal string.

Parameters
[in]valueThe value to convert to a hex form.
Returns
A string filled with the hex values representing the given object

Definition at line 882 of file String.h.

References rcast(), and ToHexVec().

◆ ToHexVec() [2/2]

constexpr Vector< 2, char > String::ToHexVec ( uint01 value)
inlinestaticconstexpr

Converts the memory of the given object into a hexidecimal string.

Parameters
[in]valueThe value to convert to a hex form.
Returns
A string filled with the hex values representing the given object

Definition at line 873 of file String.h.

Referenced by ToHex(), ToHex(), ToHex(), ToHex(), and ToHexVec().

◆ toLower()

StringAllocatingView String::toLower ( ) const

changes all upper case characters into lower case characters.

Returns
A string in all lower case

References String().

Referenced by IMUNoiseSimulator::addVector(), and IMUNoiseSimulator::setVector().

◆ toTitleString()

String String::toTitleString ( ) const

Formats the string to be a title, capitalizing important characters and replacing underscores with spaces.

Returns
A reference to this String.

References String().

Referenced by IMUNoiseSimulator::addVector().

◆ toUpper()

StringAllocatingView String::toUpper ( ) const

changes all lower case characters into upper case characters.

Returns
A string in all upper case

References String().

◆ trimWhiteSpace()

String & String::trimWhiteSpace ( )

Trims any white space (tabs, spaces, etc) from the beginning and end of the string.

Returns
A reference to this String.

References String().

Referenced by TranslationTools::processString(), and DBFParser::readColumn().

◆ UTF16toUTF8()

String String::UTF16toUTF8 ( const wchar * unicode,
uint04 & advance )
static

Converts a single unicode character at advance into UTF8 and and returns it as a String.

Parameters
[in]unicodeThe UTF16 string of chars to append to this string
[in,out]advancethe location in unicode to append, will be incremented based on number of UT16 characters consumed (1 or 2).

References String().

◆ UTF8toUTF16()

wchar String::UTF8toUTF16 ( const char * utf8,
uint04 & advance )
static

Converts a unicode null terminated string of chars into a UTF16 wchar and increments advance by the ammount of characters consumed to make the UTF16 character.

Parameters
[in]utf8the UTF8 value to convert to UTF16.
[in,out]advanceThe advance from the start of utf8 which will be incremented by this function.
Returns
A UTF16 unicode character.

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