34#include <NDEVR/Buffer.h>
35#include <NDEVR/StringStream.h>
36#include <NDEVR/StringView.h>
42 template<
class t_type>
43 struct FromStringItemReturn
45 t_type get(
const String& s)
53 struct FromStringItemReturn<
String>
55 const String& get(
const String& s) {
return s; }
60 StringView get(
const String& s) {
return StringView(s); }
94 class String :
public Buffer<char, BufferAllocator<char, 0, true, uint04, true>>
97 friend class StringView;
114 constexpr explicit String(
const StringView&
string)
115 :
Buffer(string.begin(), string.size())
122 :
Buffer(std::move(
string))
131 template<std::
size_t N>
132 constexpr explicit String(
const char (&
string)[N])
139 template<std::
size_t N>
178 template<
class t_type>
179 explicit String(
const t_type& value);
187 template<
class t_type>
188 [[nodiscard]]
decltype(
auto)
getAs()
const
190 return FromStringItemReturn<t_type>().get(*
this);
192 template<
class t_type>
193 void setFrom(
const t_type& value)
203 template<
class t_type>
211 NDEVR_BASE_API
bool beginsWith(
const StringView& s,
bool ignore_case =
false)
const;
219 NDEVR_BASE_API
bool endsWith(
const StringView& s,
bool ignore_case =
false)
const;
227 NDEVR_BASE_API
bool hasSubString(
const StringView& sub_string,
bool ignore_case =
false,
uint04 start_idx = 0)
const;
237 NDEVR_BASE_API
uint04 indexOf(
const StringView& sub_string,
bool ignore_case =
false,
uint04 start_index = 0)
const;
255 NDEVR_BASE_API
uint04 indexOf(
const char& sub_string)
const {
return Buffer::indexOf(sub_string); }
264 NDEVR_BASE_API
uint04 indexOf(
const char& sub_string,
uint04 start_pos)
const {
return Buffer::indexOf(sub_string, start_pos); }
275 NDEVR_BASE_API
uint04 indexOf(
const char& sub_string,
uint04 start_pos,
uint04 size)
const {
return Buffer::indexOf(sub_string, start_pos, size); }
285 NDEVR_BASE_API
uint04 indexOf(
const char* sub_string,
bool ignore_case =
false,
uint04 start_index = 0)
const;
308 NDEVR_BASE_API
uint04 indexOf(
const char* sub_string,
char escape_char,
bool ignore_case =
false,
uint04 start_index = 0)
const;
326 NDEVR_BASE_API
uint04 lastIndexOf(
const StringView& sub_string,
bool ignore_case =
false)
const;
345 NDEVR_BASE_API
String&
replace(
const StringView& sub_string,
const StringView& replace_sub_string,
bool ignore_case =
false,
uint04 start_index = 0);
357 NDEVR_BASE_API
String&
replace(
const StringViewBuffer& sub_string,
const StringViewBuffer& replace_sub_string,
bool ignore_case =
false,
uint04 start_index = 0);
383 NDEVR_BASE_API [[nodiscard]] StringViewBuffer
split(
char delimiter,
bool preserve_empty =
true)
const;
386 NDEVR_BASE_API [[nodiscard]] StringView splitPart(
char delimiter,
uint04 index)
const;
397 NDEVR_BASE_API [[nodiscard]] StringViewBuffer
split(
const Buffer<char>& delimiter,
bool preserve_empty =
true)
const;
407 NDEVR_BASE_API
void splitString(
char delimiter, StringViewBuffer& strings,
bool preserve_empty =
true)
const;
425 return Buffer::begin();
464 template<
class t_type>
471 template<
size_t t_size>
492 template<
size_t t_size>
615 NDEVR_BASE_API
String&
removeNonAlphaNumeric(
bool remove_tab =
true,
bool remove_space =
true,
bool remove_new_line =
true,
bool remove_r =
true,
bool remove_numbers =
false);
693 Buffer::operator=(value);
699 Buffer::operator=(std::move(value));
702 String& operator=(
const StringView& value)
704 if (value.begin() == begin())
706 setSize(value.size());
709 if (value.size() > size())
710 setSize(value.size());
711 memmove(begin(), value.begin(),
sizeof(
char) * value.size());
712 if (value.size() < size())
713 setSize(value.size());
716 String& operator=(
const char* value)
719 memmove(begin(), value,
sizeof(
char) * size());
722 template<std::
size_t N>
723 String& operator=(
const char (&value)[N])
726 memmove(begin(), value,
sizeof(
char) * size());
729 template<std::
size_t N>
736 bool operator==(
const String& value)
const
738 if (value.size() != size())
740 for (
uint04 i = 0; i < size(); i++)
742 if (value[i] != (*
this)[i])
747 bool operator==(
const StringView& value)
const
749 if (value.size() != size())
751 for (
uint04 i = 0; i < size(); i++)
753 if (value[i] != (*
this)[i])
758 bool operator==(
const char*
const value)
const
760 for (
uint04 i = 0; i < size(); i++)
762 if (value[i] != (*
this)[i])
765 return value[size()] ==
'\0';
767 template<
size_t t_size>
768 bool operator==(
const char(&
string)[t_size])
770 if (t_size <= size())
772 if (
string[size()] !=
'\0')
774 return memcmp(
string, begin(),
sizeof(
char) * size()) == 0;
777 bool operator!=(
const char*
const value)
const
779 for (
uint04 i = 0; i < size(); i++)
781 if (value[i] != (*
this)[i])
784 return value[size()] !=
'\0';
786 template<std::
size_t t_size>
787 bool operator!=(
const char(&
string)[t_size])
789 if (t_size <= size())
791 if (
string[size()] !=
'\0')
793 return memcmp(
string, begin(),
sizeof(
char) * size()) != 0;
795 bool operator!=(
const String& value)
const
797 if (value.size() != size())
799 for (
uint04 i = 0; i < size(); i++)
801 if (value[i] != (*
this)[i])
806 bool operator!=(
const StringView& value)
const
808 if (value.size() != size())
810 for (
uint04 i = 0; i < size(); i++)
812 if (value[i] != (*
this)[i])
818 NDEVR_BASE_API
bool operator<(
const String& value)
const;
819 NDEVR_BASE_API
bool operator>(
const String& value)
const;
820 NDEVR_BASE_API
bool isLessNoCase(
const StringView& other)
const;
821 NDEVR_BASE_API
bool isGreaterNoCase(
const StringView& other)
const;
822 operator StringView()
const
824 return StringView(*
this);
875 return Vector<2, char>(BinaryToHexChar(value >> 4), BinaryToHexChar(value & 0x0F));
897 return String({ vec[0], vec[1],
'\0'});
907 return String({ vec[0], vec[1],
'\0' });
914 template<
class t_
object>
915 static typename std::enable_if<ObjectInfo<t_object>::Integer,
String>
::type ToHex(t_object value)
919 hex.setSize(2 * byte_size);
920 for (
uint04 i = 0; i < byte_size; i++)
923 hex[2 * (byte_size - i - 1) + 0] = local_hex[0];
924 hex[2 * (byte_size - i - 1) + 1] = local_hex[1];
934 template<
class t_
object,
class t_allocator>
938 hex.ensureCapacity(values.size() * 2 *
sizeof(t_object));
939 for (
uint04 i = 0; i < values.size(); i++)
941 hex +=
ToHex(values[i]);
953 hex.setSize(values.
size() * 2);
957 hex[2 * i + 0] = hex_vec[0];
958 hex[2 * i + 1] = hex_vec[1];
967 template<u
int01 t_size,
class t_type>
971 hex.ensureCapacity(
cast<uint04>(t_size) * 2 *
sizeof(t_type));
972 for (
uint01 i = 0; i < t_size; i++)
974 hex +=
ToHex(values[i]);
991 const char* n_value = value;
992 for (; *n_value; ++n_value)
1007 const wchar* n_value = value;
1008 for (; *n_value; ++n_value)
1010 if (*n_value < 0x80)
1014 else if (*n_value < 0x800)
1020 uint04 cp = (*n_value << 16);
1032#pragma warning( disable : 4307)
1046 static constexpr char BinaryToHexChar(
uint01 value)
1048 return "0123456789ABCDEF"[value];
1051 static void BadCharHeuristic(
const char* str,
uint04 size,
sint04 badchar[256],
bool ignore_case);
1052 static uint04 Search(
const char* txt,
const char* pat,
uint04 size_m,
uint04 size_n,
bool ignore_case);
1061 s.ensureCapacity(string_a.size() + string_b.size());
1066 inline String
operator+(
const StringView& string_a,
const StringView& string_b)
1069 s.ensureCapacity(string_a.size() + string_b.size());
1077 s.ensureCapacity(string_a.size() + string_b.size());
1085 s.ensureCapacity(string_a.size() + string_b.size());
1093 return std::move(v1);
1098 return std::move(v1);
1104 return std::move(v1);
1110 s.ensureCapacity(v2.size() + size);
1119 s.ensureCapacity(v2.size() + size);
1124 template<
size_t t_size>
1128 return std::move(v1);
1131 template<
size_t t_size>
1136 combined.ensureCapacity(v1.size() + length);
1137 combined.append(v1);
1138 combined.addAll(v2, length);
1141 template<
size_t t_size>
1146 combined.ensureCapacity(v1.size() + length);
1147 combined.append(v1);
1148 combined.addAll(v2, length);
1151 template<
size_t t_size>
1156 combined.ensureCapacity(v2.size() + length);
1157 combined.addAll(v1, length);
1158 combined.append(v2);
1164 s.ensureCapacity(v1.size() + 1);
1172 s.ensureCapacity(v2.size() + 1);
1179 string.addUTF16AsUTF8(value);
1184 string.addAll(value);
1189 string.append(value);
1192 template<
size_t t_size>
1208 template<
size_t t_size>
1213 s.ensureCapacity(v2.size() + size);
1218 template<
size_t t_size>
1219 inline bool operator==(
const char(&v1)[t_size],
const String& v2)
1223 inline bool operator==(
const char*& v1,
const String& v2)
1227 template<
size_t t_size>
1232 s.ensureCapacity(v2.size() + size);
1233 s.addAll((
char*)v1, size);
1237 template<
class t_to>
1240 return static_cast<t_to
>(value.getAs<t_to>());
1245 static const uint01 Dimensions = 0;
1246 static const bool Vector =
false;
1247 static const bool Buffer =
true;
1248 static const bool Primitive =
false;
1249 static const bool Pointer =
false;
1250 static const bool Unsigned =
false;
1251 static const bool Float =
false;
1252 static const bool Integer =
false;
1253 static const bool Number =
false;
1254 static const bool Enum =
false;
1255 static const bool String =
true;
1256 static const bool Color =
false;
1257 static const bool Boolean =
false;
1258 static constexpr ObjectInfo<char, false, false> VectorSub() {
return ObjectInfo<char, false, false>(); }
1261 template<>
inline const String Constant<String>::Invalid =
String();
1265 return value.size() == 0;
1270 return value.size() > 0;
1280 friend class String;
1281 friend class StringAllocation;
1282 constexpr StringAllocatingView()
1284 StringAllocatingView(
const StringAllocatingView& other)
noexcept
1286 if (other.m_allocated_string.size() > 0)
1292 constexpr StringAllocatingView(
const char(&
string)[N]) noexcept
1295 StringAllocatingView(StringAllocatingView&& other) noexcept
1298 std::swap(other.m_allocated_string, m_allocated_string);
1300 constexpr StringAllocatingView(String&& other) noexcept
1302 , m_allocated_string(std::move(other))
1304 template<
class t_type>
1305 StringAllocatingView(
const t_type& value)
1330 NDEVR_BASE_API StringAllocatingView& insert(
uint04 i,
char value);
1333 m_allocated_string.clear();
1337 constexpr void allocate(
const StringView& value)
1339 m_allocated_string.clear();
1340 m_allocated_string.addAll(value.
begin(), value.
size());
1341 m_start = m_allocated_string.begin();
1344 constexpr void allocate(
const String& value)
1346 allocate(
StringView(value.begin(), value.size()));
1348 constexpr void allocate(
const StringAllocatingView& value)
1350 allocate(
StringView(value.begin(), value.size()));
1353 constexpr void allocate(
const char(&
string)[N])
noexcept
1357 template<
class t_type>
1358 void allocate(
const t_type& value)
1364 inline void allocate()
1368 if (m_allocated_string.size() == 0)
1370 m_allocated_string = *
this;
1371 m_start = m_allocated_string.begin();
1376 m_allocated_string.setSize(
m_size - offset);
1382 if (m_allocated_string.size() == 0)
1386 m_start = m_allocated_string.begin();
1392 m_allocated_string.ensureCapacity(
extra_size + new_allocation_size);
1393 m_allocated_string.setSize(new_allocation_size);
1394 m_start = m_allocated_string.begin();
1397 void ensureNullTerminated()
1401 StringAllocatingView& operator=(StringAllocatingView&& other)
noexcept
1405 std::swap(other.m_allocated_string, m_allocated_string);
1408 StringAllocatingView& operator=(
const StringAllocatingView& other)
noexcept
1410 if (other.m_allocated_string.size() > 0)
1421 NDEVR_BASE_API
void removeElement(
char c,
uint04 start);
1423 constexpr void reference(
const char(&
string)[N])
noexcept
1425 m_allocated_string.clear();
1429 constexpr void reference(
const StringView& value)
1431 m_allocated_string.clear();
1435 template<
class t_type>
1436 void append(
const t_type& value)
1442 m_allocated_string.addSpace<
true>(
size);
1443 m_start = m_allocated_string.begin();
1448 m_allocated_string.ensureCapacity(
size);
1449 m_start = m_allocated_string.begin();
1451 NDEVR_BASE_API StringAllocatingView& makeLower(
uint04 offset = 0);
1452 NDEVR_BASE_API StringAllocatingView& makeUpper(
uint04 offset = 0);
1453 void append(
const char& value)
1455 if (m_allocated_string.size() == 0)
1456 allocateWithExtra(1);
1457 m_allocated_string.add(value);
1458 m_start = m_allocated_string.begin();
1462 constexpr void append(
const char(&
string)[N])
noexcept
1466 constexpr void append(
const StringView& value)
1468 if (value.size() == 0)
1471 if (
m_size > 0 && m_allocated_string.size() == 0)
1474 m_allocated_string.addAll(value.begin(), value.size());
1478 lib_assert(value.end() < m_allocated_string.begin() || value.begin() > m_allocated_string.end(),
"Cannot append to self" );
1479 m_allocated_string.addAll(value.begin(), value.size());
1481 m_start = m_allocated_string.begin();
1484 constexpr void append(
const String& value)
1488 constexpr void append(
const StringAllocatingView& value)
1492 void referencedAppend(
const char& value)
1504 constexpr void referencedAppend(
const StringView& value)
1506 if (value.size() == 0)
1513 constexpr void referencedAppend(
const String& value)
1515 if (value.size() == 0)
1522 void referencedAppend(
const String&& value) =
delete;
1523 void referencedAppend(
char&& value) =
delete;
1524 [[nodiscard]]
constexpr char* allocationPtr()
1526 lib_assert(m_allocated_string.size() > 0,
"Bad Allocation");
1527 return m_allocated_string.begin();
1529 [[nodiscard]]
constexpr char* allocationPtr(
uint04 idx_offset)
1531 lib_assert(m_allocated_string.size() > 0,
"Bad Allocation");
1532 return m_allocated_string.begin(idx_offset);
1534 void replaceIndexRange(
uint04 offset,
uint04 replace_size,
const char* buffer,
uint04 buffer_size)
1538 lib_assert(offset + replace_size <=
size(),
"invalid replace");
1539 m_allocated_string.replaceIndexRange(offset + reference_offset, replace_size, buffer, buffer_size);
1540 m_start = m_allocated_string.begin();
1541 m_size = m_allocated_string.size();
1543 template<
class t_
string_type>
1544 static StringAllocatingView Reference(
const t_string_type& value)
1546 StringAllocatingView view;
1550 template<
class t_type>
1551 static StringAllocatingView Allocate(
const t_type& value)
1553 StringAllocatingView view;
1554 view.allocate(value);
1558 String m_allocated_string;
1563 static const uint01 Dimensions = 0;
1564 static const bool Vector =
false;
1565 static const bool Buffer =
true;
1566 static const bool Primitive =
false;
1567 static const bool Pointer =
false;
1568 static const bool Unsigned =
false;
1569 static const bool Float =
false;
1570 static const bool Integer =
false;
1571 static const bool Number =
false;
1572 static const bool Enum =
false;
1573 static const bool String =
true;
1574 static const bool Color =
false;
1575 static const bool Boolean =
false;
1576 static constexpr ObjectInfo<char, false, false> VectorSub() {
return ObjectInfo<char, false, false>(); }
1578 template<
class t_type>
1583 if (view.m_allocated_string.size() > 0)
1584 *
this = std::move(view.m_allocated_string);
1585 else if (view.
size() > 0)
1588 class StringAllocation final
1594 if (s.m_allocated_string.size() > 0)
1596 m_start_offset =
cast<uint04>(s.m_start - s.m_allocated_string.begin());
1601 m_reference.allocate();
1607 ~StringAllocation() noexcept
1609 m_reference.m_start = m_start_offset + m_reference.m_allocated_string.begin();
1610 m_reference.m_size =
cast<uint04>(m_reference.m_allocated_string.size() - m_start_offset);
1613 operator String&()
noexcept {
return m_reference.m_allocated_string; }
1614 operator const String&()
const noexcept {
return m_reference.m_allocated_string; }
1615 String& operator*() noexcept {
return m_reference.m_allocated_string; }
1616 const String& operator*() const noexcept {
return m_reference.m_allocated_string; }
1617 StringAllocation(
const StringAllocation&) =
delete;
1618 StringAllocation& operator=(
const StringAllocation&) =
delete;
1619 StringAllocation(StringAllocation&&) =
delete;
1620 StringAllocation& operator=(StringAllocation&&) =
delete;
1621 String* operator->() noexcept {
return &m_reference.m_allocated_string; }
1622 const String* operator->() const noexcept {
return &m_reference.m_allocated_string; }
1624 StringAllocatingView& m_reference;
1625 uint04 m_start_offset = 0;
1630 StringWrappedAllocation(String& s)
1633 std::swap(m_allocated_string, reference);
1635 ~StringWrappedAllocation()
1637 if (m_allocated_string.size() > 0)
1638 reference = std::move(m_allocated_string);
1639 else if (
size() > 0)
1644 template<
class t_type>
1650 std::swap(view.m_allocated_string, *
this);
1651 view.
m_start = view.m_allocated_string.begin();
1652 view.
m_size = view.m_allocated_string.size();
1655 if (view.m_allocated_string.size() > 0)
1656 *
this = std::move(view.m_allocated_string);
1657 else if (view.
size() > 0)
1667 struct equal_to<
NDEVR::String>
1669 using is_transparent = std::true_type;
1670 bool operator()(
const String& a,
const StringView& b)
const {
return a == b; }
1671 bool operator()(
const StringView& a,
const String& b)
const {
return a == b; }
1672 bool operator()(
const String& a,
const String& b)
const {
return a == b; }
1673 bool operator()(
const String& a,
const char* b)
const {
return a == b; }
1674 bool operator()(
const char* a,
const String& b)
const {
return a == b; }
1675 template<std::
size_t N>
1676 bool operator()(
const String& a,
const char(&b)[N])
const {
return a == b; }
1677 template<std::
size_t N>
1678 bool operator()(
const char(&a)[N],
const String& b)
const {
return a == b; }
1681 struct equal_to<StringAllocatingView>
1683 using is_transparent = std::true_type;
1684 bool operator()(
const String& a,
const StringView& b)
const {
return a == b; }
1685 bool operator()(
const StringView& a,
const String& b)
const {
return a == b; }
1686 bool operator()(
const StringAllocatingView& a,
const String& b)
const {
return a == b; }
1687 bool operator()(
const String& a,
const StringAllocatingView& b)
const {
return a == b; }
1688 bool operator()(
const StringAllocatingView& a,
const StringView& b)
const {
return a == b; }
1689 bool operator()(
const StringView& a,
const StringAllocatingView& b)
const {
return a == b; }
1690 bool operator()(
const StringAllocatingView& a,
const StringAllocatingView& b)
const {
return a == b; }
1691 bool operator()(
const String& a,
const String& b)
const {
return a == b; }
1692 bool operator()(
const StringView& a,
const StringView& b)
const {
return a == b; }
1693 bool operator()(
const String& a,
const char* b)
const {
return a == b; }
1694 bool operator()(
const char* a,
const String& b)
const {
return a == b; }
1695 template<std::
size_t N>
1696 bool operator()(
const String& a,
const char(&b)[N])
const {
return a == b; }
1697 template<std::
size_t N>
1698 bool operator()(
const char(&a)[N],
const String& b)
const {
return a == b; }
1703 using is_transparent = std::true_type;
1704 size_t operator()(
const String& s)
const noexcept
1706 return static_cast<size_t>(s.hash());
1708 constexpr size_t operator()(
const StringView& s)
const noexcept
1710 return static_cast<size_t>(s.hash());
1712 constexpr size_t operator()(
const char* s)
const noexcept
1717 constexpr size_t operator()(
const char(&s)[N])
const noexcept
1723 struct hash<StringAllocatingView>
1725 using is_transparent = std::true_type;
1726 size_t operator()(
const String& s)
const noexcept
1728 return static_cast<size_t>(s.hash());
1730 constexpr size_t operator()(
const StringView& s)
const noexcept
1732 return static_cast<size_t>(s.hash());
1734 constexpr size_t operator()(
const StringAllocatingView& s)
const noexcept
1736 return static_cast<size_t>(s.hash());
1738 constexpr size_t operator()(
const char* s)
const noexcept
1743 constexpr size_t operator()(
const char(&s)[N])
const noexcept
1749 NDEVR_BASE_API ostream& operator<<(ostream& in,
const StringView&
string);
1750 NDEVR_BASE_API ostream& operator<<(ostream& in,
const String&
string);
The equivelent of std::vector but with a bit more control.
constexpr Buffer() noexcept
This class is like a string view, but may optionally store the data internally Useful if the return t...
StringAllocatingView & replace(const Buffer< StringView > &sub_string, const Buffer< String > &replace_sub_string, bool ignore_case=false, uint04 start_index=0)
Replaces ALL instances of the given substrings with the provided replacements.
StringAllocatingView & 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.
static void fromString(const StringView &string, t_type &value)
Logic for converting an object from an NDEVR API String allowing it to be used automatically with get...
static void toString(const t_type &value, StringAllocatingView &string)
Logic for converting an object to an NDEVR API String allowing it to be used automatically with the S...
The core String View class for the NDEVR API.
static constexpr uint04 str_len(const char *value)
constexpr method to get the length of a null-terminated string at compile time
constexpr const char * end() const
Returns a pointer to one past the last character of the string data.
const char * m_start
Pointer to the beginning of the string data.
constexpr StringView()
Constructor used to create an empty StringView.
constexpr const char * begin() const
Returns a pointer to the beginning of the string data.
uint04 m_size
The byte length of the string view.
constexpr uint08 hash() const
Creates a simple, quick hash of the object.
void ensureNullTerminated(String &s)
This makes the string null terminated, if needed, using the provided string as the new buffer.
constexpr uint04 size() const
Returns the byte size of this string view.
The core String class for the NDEVR API.
StringView substr(uint04 start) const
Creates a substring from a given start position, to the end of the string.
constexpr String(const String &string)
Copy Constructor.
String(const wchar(&string)[N])
String Constructor for static wchar arrays of UTF16 data.
StringAllocatingView shortenString(uint04 size) const
Shortens the string to the max size provided.
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.
String & append(const char(&value)[t_size])
Appends a string to the back of this string.
String & removeNonNumeric()
Removes anything that is not a number or decimal ('0'-'9' or .).
uint08 hashLower() const
Creates a simple, quick hash of the object.
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...
static constexpr uint08 hash(const char *value)
constexpr method to hash a value.
constexpr String(uint04 size, const char &value)
String Constructor creates a string of a size and fills it with a character.
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.
String & append(const StringView &string)
Appends a string to the back of this string.
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.
void addWChar(const wchar &object)
Converts a single unicode character UTF16 character into one or more UTF8 characters and appends them...
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.
static constexpr uint04 str_len(const wchar *value)
constexpr method to get the UTF8 length of a null-terminated string at compile time
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 wchar UTF8toUTF16(const char *utf8, uint04 &advance)
Converts a unicode null terminated string of chars into a UTF16 wchar and increments advance by the a...
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.
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 ...
uint04 fromHex() const
Converts a hex value into an unsigned 4 byte number.
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.
String insertNewLines(uint04 max_line_size) const
Finds key areas to insert new lines such that the rows are at most, the length provided.
String & append(const wchar(&value)[t_size])
Appends a string to the back of this string.
constexpr String(const char(&string)[N])
String Constructor for static char arrays.
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.
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.
String & formatNumberString(uint04 decimals)
For a string representing a number, makes the decimals equal to the the provided value Example: Strin...
static String ToHex(const Vector< t_size, t_type > &values)
Converts a vector into a hex representation.
decltype(auto) getAs() const
Converts a string into an object.
constexpr const char * c_str() const
Used to access the raw memory of this string.
constexpr uint08 hash() const
Creates a simple, quick hash of the object.
static String ToHex(const Buffer< t_object, t_allocator > &values)
Converts a buffer of objects into a hexidecimal string.
String & append(const wchar *value)
Appends a string to the back of this 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.
static bool IsNumeric(char value)
Checks to see if the char is a numeric 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...
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.
bool endsWith(const StringView &s, bool ignore_case=false) const
Tests if this String ends with the specified suffix.
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.
String & trimWhiteSpace()
Trims any white space (tabs, spaces, etc) from the beginning and end of the string.
static String ToAlphaString(uint04 number)
Converts a number into a char string.
uint08 hashUpper() const
Creates a simple, quick hash of the object.
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 String ToHex(const StringView &values)
Converts a string of any type of data (assumed to be binary) into a hex representation.
constexpr String(const char *const string, uint04 size)
String Constructor char arrays when the size is known.
bool isNumeric() const
Checks to see if the string is a numeric string.
bool hasSubString(const StringView &sub_string, bool ignore_case=false, uint04 start_idx=0) const
Tests if this String contains the specified substring.
bool beginsWith(const StringView &s, bool ignore_case=false) const
Tests if this String starts with the specified prefix.
String predictNextStringIncrement() const
Looks in the string for key markers that might be an index, and attempts to increment the index.
String & append(const char *value)
Appends a string to the back of this string.
bool matchesWildcard(const StringView &pattern) const
Checks whether two strings match allowing '' to be used as a wildcard pattern.
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.
static bool AlphaNumericCompare(const StringView &left, const StringView &right)
Compares two strings given their alpha-numeric determined value.
StringAllocatingView toUpper() const
changes all lower case characters into upper case characters.
constexpr String(String &&string) noexcept
Move contructor (No new memory allocation).
StringAllocatingView toLower() const
changes all upper case characters into lower case characters.
StringViewBuffer split(char delimiter, bool preserve_empty=true) const
Given a delimiter, breaks the string into subsections, returning an array of each subsection.
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.
static String ToHex(char value)
Converts the memory of the given object into a hexidecimal string.
static TranslatedString DisplayString(const t_type &value)
Converts an object into a TranslatedString.
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.
String(const char *string)
String Constructor for null terminated array of chars.
static bool IsWhiteSpace(char s)
Checks whether a given character is a whitespace character or not.
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.
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.
constexpr String() noexcept
Constructor used to create an empty String*.
uint04 indexOf(const char &sub_string) const
Given a substring specified by the input, returns the first index of that string, if it exists.
String toTitleString() const
Formats the string to be a title, capitalizing important characters and replacing underscores with sp...
void addUTF16AsUTF8(const wchar *unicode)
Converts a unicode null terminated string of UTF16 wchars into UTF8 and appends it to the end of the ...
constexpr String(const StringView &string)
Constructor for string view.
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...
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.
String & append(char value)
Appends an object to the back of this string.
String & append(const wchar value)
Appends a wchar utf16 to the back of this string as utf8.
bool isSameNoCase(const StringView &s) const
Checks whether two strings match in a case-insensitive way.
static constexpr uint04 str_len(const char *value)
constexpr method to get the length of a null-terminated string at compile time
static String ToHex(uint01 value)
Converts the memory of the given object into a hexidecimal 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.
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.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
@ type
The type identifier string for this model node.
@ Color
Per-vertex RGBA color.
static constexpr bool IsValid(const Angle< t_type > &value)
Checks whether the given Angle holds a valid value.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
int32_t sint04
-Defines an alias representing a 4 byte, signed integer.
constexpr t_to & rcast(t_from &value)
Casts the given value.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
static constexpr Angle< t_angle_type > & operator+=(Angle< t_angle_type > &angle, const Angle< t_angle_type > &add)
Addition assignment operator for Angles.
static constexpr bool IsInvalid(const Angle< t_type > &value)
Checks whether the given Angle holds an invalid value.
AlocatingAlignedBuffer< String, sizeof(char *)==4 ? 8 :16 > StringBuffer
A Buffer of String objects using aligned allocation optimized for pointer size.
static constexpr Angle< t_type > operator+(const Angle< t_type > &angle_a, const Angle< t_type > &angle_b)
Addition operator.
@ extra_size
An additional size parameter for the effect.
wchar_t wchar
Allias for wchar_t, a value that represents a character of two bytes in size.
constexpr t_to cast(const Angle< t_from > &value)
Casts an Angle from one backing type to another.
istream & operator>>(istream &in, StringView &string)
Stream extraction operator for reading into an StringView.
Information about the object.