NDEVR
API Documentation
StringView

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

Inheritance diagram for StringView:
[legend]

Public Member Functions

constexpr StringView ()
 Constructor used to create an empty StringView.
constexpr StringView (const char *const string, uint04 size)
 String Constructor char arrays when the size is known.
constexpr StringView (const char *string)
 String Constructor for null terminated array of chars.
template<std::size_t N>
constexpr StringView (const char(&string)[N])
 String Constructor for static char arrays.
constexpr StringView (const String &s)
 Constructs a StringView from an existing String object.
constexpr StringView (const StringView &other) noexcept
 Copy constructor for StringView.
 StringView (String &&s)=delete
 Deleted move constructor from String to prevent dangling views.
constexpr StringView (StringView &&other) noexcept
 Move constructor for StringView.
void addToSize (uint04 size)
 Increases the reported size of the string view by the given amount.
constexpr const char * begin () const
 Returns a pointer to the beginning of the string data.
constexpr const char * begin (uint04 idx_offset) const
 Returns a pointer offset from the beginning of the string data.
bool beginsWith (const StringView &s, bool ignore_case=false) const
 Tests if this String starts with the specified prefix.
constexpr bool contains (char c) const
 Checks whether the string view contains the given character.
uint04 count (char c) const
 Counts the number of occurrences of the given character.
constexpr const char * end () const
 Returns a pointer to one past the last character of the string data.
bool endsWith (const StringView &s, bool ignore_case=false) const
 Tests if this String ends with the specified suffix.
void ensureNullTerminated (String &s)
 This makes the string null terminated, if needed, using the provided string as the new buffer.
uint04 fromHex () const
 Converts a hex value into an unsigned 4 byte number.
template<class t_type>
t_type getAs () const
 Converts a string into an object.
constexpr uint08 hash () const
 Creates a simple, quick hash of the object.
constexpr uint08 hashLower () const
 Creates a simple, quick hash of the object.
constexpr uint08 hashUpper () const
 Creates a simple, quick hash of the object.
bool hasSubString (const StringView &sub_string, bool ignore_case=false, uint04 initial_index=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, 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.
template<size_t t_size>
uint04 indexOf (const char(&value)[t_size], bool ignore_case, uint04 start_index=0) const
 Template overload of indexOf for static char arrays.
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.
StringAllocatingView insertNewLines (uint04 max_line_size) const
 Finds key areas to insert new lines such that the rows are at most, the length provided.
bool isGreaterNoCase (const StringView &other) const
 Case-insensitive greater-than comparison.
bool isLessNoCase (const StringView &other) const
 Case-insensitive less-than comparison.
bool isNullTerminated () const
 Checks whether the underlying string data is null terminated.
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.
char last () const
 Returns the last character in the string view.
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.
bool matchesWildcard (const StringView &pattern) const
 Checks whether two strings match allowing '' to be used as a wildcard pattern.
constexpr bool operator!= (const char *const value) const
 Checks inequality with a null-terminated C string.
template<std::size_t t_size>
constexpr bool operator!= (const char(&string)[t_size])
 Checks inequality with a static char array.
bool operator!= (const String &value) const
 Checks inequality with a String object.
constexpr bool operator!= (const StringView &value) const
 Checks inequality with another StringView.
bool operator< (const StringView &value) const
 Less-than comparison operator using lexicographic ordering.
constexpr StringViewoperator= (const char *value)
 Assignment operator from a null-terminated C string.
template<std::size_t t_size>
constexpr StringViewoperator= (const char(&string)[t_size])
 Assignment operator from a static char array.
StringViewoperator= (const String &value)
 Assignment operator from a String object.
constexpr StringViewoperator= (const StringView &value)
 Copy assignment operator from another StringView.
StringViewoperator= (String &&value)=delete
 Deleted move assignment from String to prevent dangling views.
constexpr bool operator== (const char *const value) const
 Checks equality with a null-terminated C string.
template<std::size_t t_size>
constexpr bool operator== (const char(&string)[t_size])
 Checks equality with a static char array.
bool operator== (const String &value) const
 Checks equality with a String object.
constexpr bool operator== (const StringView &value) const
 Checks equality with another StringView.
bool operator> (const StringView &value) const
 Greater-than comparison operator using lexicographic ordering.
constexpr const char & operator[] (const uint04 idx) const
 Accesses the character at the given index.
String predictNextStringIncrement () const
 Looks in the string for key markers that might be an index, and attempts to increment the index.
void removeFirst (uint04 count=1)
 Removes the specified number of characters from the beginning of the view.
void removeLast (uint04 count=1)
 Removes the specified number of characters from the end of the view.
StringAllocatingView shortenString (uint04 size) const
 Shortans the string to the max size provided.
constexpr uint04 size () const
 Returns the byte size of this string view.
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 view into subsections, returning an array of each subsection.
StringView splitPart (char delimiter, uint04 index) const
 Returns a single part from splitting the string by the given delimiter.
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.
StringViewtrimWhiteSpace ()
 Trims leading and trailing whitespace from the string view.

Static Public Member Functions

static bool AlphaNumericCompare (const StringView &left, const StringView &right)
 Compares two strings given their alpha-numeric determined value.
static StringViewBuffer Convert (const StringBuffer &strings)
 Converts a StringBuffer into a StringViewBuffer.
static StringBuffer Convert (const StringViewBuffer &views)
 Converts a StringViewBuffer into a StringBuffer by copying each view into a String.
static void Convert (StringBuffer &&strings)=delete
 Deleted overload to prevent converting from rvalue StringBuffer which would create dangling views.
static constexpr uint08 hash (const char *value)
 constexpr method to hash a value.
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

Protected Attributes

uint04 m_size = 0
 The byte length of the string view.
const char * m_start = nullptr
 Pointer to the beginning of the string data.

Detailed Description

The core String View class for the NDEVR API.


This String View class:

  • Explicitly uses Unicode (UTF8)
  • Easy functions for converting to anything (getAs<class>())
  • Is faster than Buffer as allocates memory
  • 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<...>()

See also
String, TranslatedString

Definition at line 57 of file StringView.h.

Constructor & Destructor Documentation

◆ StringView() [1/6]

StringView::StringView ( StringView && other)
inlineconstexprnoexcept

Move constructor for StringView.

Parameters
[in]otherThe other view to be converted

Definition at line 70 of file StringView.h.

References StringView().

◆ StringView() [2/6]

StringView::StringView ( const StringView & other)
inlineconstexprnoexcept

Copy constructor for StringView.

Parameters
[in]otherThe other view to be copied

Definition at line 78 of file StringView.h.

References StringView().

◆ StringView() [3/6]

template<std::size_t N>
StringView::StringView ( const char(&) string[N])
inlineconstexpr

String Constructor for static char arrays.

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

Definition at line 87 of file StringView.h.

References StringView(), and str_len().

◆ StringView() [4/6]

StringView::StringView ( const char * string)
inlineconstexpr

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 95 of file StringView.h.

References StringView(), and str_len().

◆ StringView() [5/6]

StringView::StringView ( 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 105 of file StringView.h.

References m_size, m_start, and size().

◆ StringView() [6/6]

StringView::StringView ( const String & s)
explicitconstexpr

Constructs a StringView from an existing String object.

Parameters
[in]sThe String to create a view of.

Definition at line 1054 of file String.h.

References m_size, m_start, and size().

Member Function Documentation

◆ addToSize()

void StringView::addToSize ( uint04 size)
inline

Increases the reported size of the string view by the given amount.

Parameters
[in]sizeThe number of bytes to add to the current size.

Definition at line 769 of file StringView.h.

References m_size, and size().

◆ AlphaNumericCompare()

bool StringView::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.

References StringView().

◆ begin() [1/2]

const char * StringView::begin ( ) const
inlinenodiscardconstexpr

Returns a pointer to the beginning of the string data.

Returns
A const pointer to the first character.

Definition at line 640 of file StringView.h.

References m_start.

Referenced by String::String(), String::append(), HashMaker::hash(), operator!=(), BinaryFile::write(), and BinaryFile::writeRawData().

◆ begin() [2/2]

const char * StringView::begin ( uint04 idx_offset) const
inlinenodiscardconstexpr

Returns a pointer offset from the beginning of the string data.

Parameters
[in]idx_offsetThe number of characters to offset from the start.
Returns
A const pointer to the character at the given offset.

Definition at line 649 of file StringView.h.

References m_start.

◆ beginsWith()

bool StringView::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

References StringView().

◆ contains()

bool StringView::contains ( char c) const
inlinenodiscardconstexpr

Checks whether the string view contains the given character.

Parameters
[in]cThe character to search for.
Returns
True if the character is found in the string view.

Definition at line 666 of file StringView.h.

◆ Convert() [1/2]

StringViewBuffer StringView::Convert ( const StringBuffer & strings)
static

Converts a StringBuffer into a StringViewBuffer.

Parameters
[in]stringsThe StringBuffer to convert.
Returns
A StringViewBuffer containing views into the source strings.

Referenced by ManagedDesignCommand::setParams(), and TranslationTools::setupFile().

◆ Convert() [2/2]

StringBuffer StringView::Convert ( const StringViewBuffer & views)
static

Converts a StringViewBuffer into a StringBuffer by copying each view into a String.

Parameters
[in]viewsThe StringViewBuffer to convert.
Returns
A StringBuffer containing copies of the source views.

◆ count()

uint04 StringView::count ( char c) const
nodiscard

Counts the number of occurrences of the given character.

Parameters
[in]cThe character to count.
Returns
The number of times the character appears in the string view.

Referenced by removeFirst(), removeLast(), and str_len().

◆ end()

const char * StringView::end ( ) const
inlinenodiscardconstexpr

Returns a pointer to one past the last character of the string data.

Returns
A const pointer to the end of the string.

Definition at line 657 of file StringView.h.

References m_size, and m_start.

Referenced by substr().

◆ endsWith()

bool StringView::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

References StringView().

◆ ensureNullTerminated()

void StringView::ensureNullTerminated ( String & s)

This makes the string null terminated, if needed, using the provided string as the new buffer.

If this is already null terminated, this function does not allocate memory

◆ fromHex()

uint04 StringView::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 StringView::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 330 of file StringView.h.

References cast(), hash(), and size().

Referenced by TranslationTools::convertBrackets(), TranslationTools::convertFromBrackets(), String::hash(), String::hash(), hash(), hashLower(), and hashUpper().

◆ hash() [2/2]

constexpr uint08 StringView::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.

Definition at line 342 of file StringView.h.

◆ hashLower()

uint08 StringView::hashLower ( ) 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 as if where all lowercase.

Definition at line 372 of file StringView.h.

References cast(), hash(), and size().

◆ hashUpper()

uint08 StringView::hashUpper ( ) 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 as if it were all uppercase.

Definition at line 356 of file StringView.h.

References cast(), hash(), and size().

◆ hasSubString()

bool StringView::hasSubString ( const StringView & sub_string,
bool ignore_case = false,
uint04 initial_index = 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

References StringView().

◆ indexOf() [1/7]

uint04 StringView::indexOf ( const char & sub_string) 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
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() [2/7]

uint04 StringView::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.

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.

◆ indexOf() [3/7]

uint04 StringView::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.

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.

References size().

◆ indexOf() [4/7]

uint04 StringView::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.

References size().

◆ indexOf() [5/7]

uint04 StringView::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() [6/7]

template<size_t t_size>
uint04 StringView::indexOf ( const char(&) value[t_size],
bool ignore_case,
uint04 start_index = 0 ) const
inline

Template overload of indexOf for static char arrays.

Parameters
[in]valueThe static char array to find in the String.
[in]ignore_caseWhether or not to check using case sensitivity.
[in]start_indexThe index of where to begin searching.
Returns
The first index pointing to the beginning of the match, or Constant<uint04>::Invalid if not found.

Definition at line 173 of file StringView.h.

References StringView(), indexOf(), and str_len().

◆ indexOf() [7/7]

uint04 StringView::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.

References StringView().

Referenced by TranslationTools::convertBrackets(), and indexOf().

◆ insertNewLines()

StringAllocatingView StringView::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

◆ isGreaterNoCase()

bool StringView::isGreaterNoCase ( const StringView & other) const

Case-insensitive greater-than comparison.

Parameters
[in]otherThe StringView to compare against.
Returns
True if this string is lexicographically greater than other, ignoring case.

References StringView().

◆ isLessNoCase()

bool StringView::isLessNoCase ( const StringView & other) const

Case-insensitive less-than comparison.

Parameters
[in]otherThe StringView to compare against.
Returns
True if this string is lexicographically less than other, ignoring case.

References StringView().

◆ isNullTerminated()

bool StringView::isNullTerminated ( ) const

Checks whether the underlying string data is null terminated.

Returns
True if the character after the view's range is a null terminator.

◆ isNumeric()

bool StringView::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 StringView::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.

References StringView().

◆ last()

char StringView::last ( ) const
nodiscard

Returns the last character in the string view.

Returns
The last character.

◆ lastIndexOf() [1/2]

uint04 StringView::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/2]

uint04 StringView::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.

◆ matchesWildcard()

bool StringView::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.

References StringView().

◆ operator!=() [1/4]

bool StringView::operator!= ( const char *const value) const
inlineconstexpr

Checks inequality with a null-terminated C string.

Parameters
[in]valueThe C string to compare against.
Returns
True if the contents differ.

Definition at line 531 of file StringView.h.

References size().

◆ operator!=() [2/4]

template<std::size_t t_size>
bool StringView::operator!= ( const char(&) string[t_size])
inlineconstexpr

Checks inequality with a static char array.

Parameters
[in]stringThe static char array to compare against.
Returns
True if the contents differ.

Definition at line 546 of file StringView.h.

References begin(), and size().

◆ operator!=() [3/4]

bool StringView::operator!= ( const String & value) const

Checks inequality with a String object.

Parameters
[in]valueThe String to compare against.
Returns
True if the contents differ.

◆ operator!=() [4/4]

bool StringView::operator!= ( const StringView & value) const
inlineconstexpr

Checks inequality with another StringView.

Parameters
[in]valueThe StringView to compare against.
Returns
True if the contents differ.

Definition at line 559 of file StringView.h.

References StringView(), and size().

◆ operator<()

bool StringView::operator< ( const StringView & value) const

Less-than comparison operator using lexicographic ordering.

Parameters
[in]valueThe StringView to compare against.
Returns
True if this string is lexicographically less than value.

References StringView().

◆ operator=() [1/4]

StringView & StringView::operator= ( const char * value)
inlineconstexpr

Assignment operator from a null-terminated C string.

Parameters
[in]valueThe C string to assign from.
Returns
A reference to this StringView.

Definition at line 606 of file StringView.h.

References StringView(), m_size, m_start, and str_len().

◆ operator=() [2/4]

template<std::size_t t_size>
StringView & StringView::operator= ( const char(&) string[t_size])
inlineconstexpr

Assignment operator from a static char array.

Parameters
[in]stringThe static char array to assign from.
Returns
A reference to this StringView.

Definition at line 595 of file StringView.h.

References StringView(), m_size, m_start, and str_len().

◆ operator=() [3/4]

StringView & StringView::operator= ( const String & value)

Assignment operator from a String object.

Parameters
[in]valueThe String to assign from.
Returns
A reference to this StringView.

References StringView().

◆ operator=() [4/4]

StringView & StringView::operator= ( const StringView & value)
inlineconstexpr

Copy assignment operator from another StringView.

Parameters
[in]valueThe StringView to assign from.
Returns
A reference to this StringView.

Definition at line 575 of file StringView.h.

References StringView(), m_size, m_start, and size().

◆ operator==() [1/4]

bool StringView::operator== ( const char *const value) const
inlineconstexpr

Checks equality with a null-terminated C string.

Parameters
[in]valueThe C string to compare against.
Returns
True if the contents are identical.

Definition at line 499 of file StringView.h.

References size().

◆ operator==() [2/4]

template<std::size_t t_size>
bool StringView::operator== ( const char(&) string[t_size])
inlineconstexpr

Checks equality with a static char array.

Parameters
[in]stringThe static char array to compare against.
Returns
True if the contents are identical.

Definition at line 514 of file StringView.h.

References size().

◆ operator==() [3/4]

bool StringView::operator== ( const String & value) const

Checks equality with a String object.

Parameters
[in]valueThe String to compare against.
Returns
True if the contents are identical.

◆ operator==() [4/4]

bool StringView::operator== ( const StringView & value) const
inlineconstexpr

Checks equality with another StringView.

Parameters
[in]valueThe StringView to compare against.
Returns
True if the contents are identical.

Definition at line 483 of file StringView.h.

References StringView(), and size().

◆ operator>()

bool StringView::operator> ( const StringView & value) const

Greater-than comparison operator using lexicographic ordering.

Parameters
[in]valueThe StringView to compare against.
Returns
True if this string is lexicographically greater than value.

References StringView().

◆ operator[]()

const char & StringView::operator[] ( const uint04 idx) const
inlinenodiscardconstexpr

Accesses the character at the given index.

Parameters
[in]idxThe zero-based index of the character.
Returns
A const reference to the character at the specified index.

Definition at line 320 of file StringView.h.

References m_start.

◆ predictNextStringIncrement()

String StringView::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

◆ removeFirst()

void StringView::removeFirst ( uint04 count = 1)

Removes the specified number of characters from the beginning of the view.

Parameters
[in]countThe number of characters to remove from the beginning.

References count().

◆ removeLast()

void StringView::removeLast ( uint04 count = 1)

Removes the specified number of characters from the end of the view.

Parameters
[in]countThe number of characters to remove from the end.

References count().

◆ shortenString()

StringAllocatingView StringView::shortenString ( uint04 size) const

Shortans the string to the max size provided.

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

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

References size().

◆ size()

◆ split() [1/2]

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

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, StringView("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 TranslationTools::setupFile().

◆ split() [2/2]

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

Given multiple delimiter, breaks the string view 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, StringView("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.

◆ splitPart()

StringView StringView::splitPart ( char delimiter,
uint04 index ) const

Returns a single part from splitting the string by the given delimiter.

Parameters
[in]delimiterThe character to split the string on.
[in]indexThe zero-based index of the part to return.
Returns
The substring at the specified index after splitting.

References StringView().

◆ splitString() [1/2]

void StringView::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 StringView::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.

◆ str_len() [1/2]

constexpr uint04 StringView::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 723 of file StringView.h.

References cast().

Referenced by StringView(), StringView(), indexOf(), operator=(), and operator=().

◆ str_len() [2/2]

constexpr uint04 StringView::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 738 of file StringView.h.

References count().

◆ substr() [1/2]

StringView StringView::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.

References StringView().

Referenced by TranslationTools::convertBrackets().

◆ substr() [2/2]

StringView 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.

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.

References StringView(), and end().

◆ toLower()

StringAllocatingView StringView::toLower ( ) const

changes all upper case characters into lower case characters.

Returns
A string in all lower case

◆ toTitleString()

String StringView::toTitleString ( ) const

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

Returns
A reference to this String.

◆ toUpper()

StringAllocatingView StringView::toUpper ( ) const

changes all lower case characters into upper case characters.

Returns
A string in all upper case

◆ trimWhiteSpace()

StringView & StringView::trimWhiteSpace ( )

Trims leading and trailing whitespace from the string view.

Returns
A reference to this StringView after trimming.

References StringView().


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