34#include <NDEVR/Buffer.h>
35#include <NDEVR/StringStream.h>
46 class String :
public Buffer<char, uint04, ObjectAllocator<true>, BufferAllocator<char, uint04, true>>
53 template<std::
size_t N>
57 template<std::
size_t N>
71 template<
class t_type>
127 template<
class t_type>
132 const char* n_value = value;
133 for (; *n_value; ++n_value)
140 const wchar* n_value = value;
141 for (; *n_value; ++n_value)
147 else if (*n_value < 0x800)
153 uint04 cp = (*n_value << 16);
165#pragma warning( disable : 4307)
169 uint08 hash_value = 5381U;
170 for (
const char* n_value = value; *n_value; n_value++)
172 hash_value = ((hash_value << 5) + hash_value) + cast<uint08>(*n_value);
222 template<
class t_
object>
223 static typename std::enable_if<ObjectInfo<t_object>::Integer,
String>::type
toHex(t_object value)
228 for (
uint04 i = 0; i < byte_size; i++)
231 hex[2 * (byte_size - i - 1) + 0] = local_hex[0];
232 hex[2 * (byte_size - i - 1) + 1] = local_hex[1];
237 template<
class t_
object,
class t_allocator,
class t_buff>
244 hex +=
toHex(values[i]);
254 hex +=
toHex(values[i]);
258 template<u
int01 t_size,
class t_type>
263 for (
uint01 i = 0; i < t_size; i++)
265 hex +=
toHex(values[i]);
287 if(value[i] != (*
this)[i])
296 if(value[i] != (*
this)[i])
299 return value[
size()] ==
'\0';
301 template<std::
size_t t_size>
306 if(
string[
size()] !=
'\0')
308 return memcmp(
string,
begin(),
sizeof(
char) *
size()) == 0;
315 if(value[i] != (*
this)[i])
318 return value[
size()] !=
'\0';
320 template<std::
size_t t_size>
325 if(
string[
size()] !=
'\0')
327 return memcmp(
string,
begin(),
sizeof(
char) *
size()) != 0;
335 if(value[i] != (*
this)[i])
340 template <
class t_type>
351 static void BadCharHeuristic(
const char* str,
uint04 size,
sint04 badchar[256],
bool ignore_case);
352 static uint04 Search(
const char* txt,
const char* pat,
uint04 size_m,
uint04 size_n,
bool ignore_case);
374 return std::move(v1);
379 return std::move(v1);
385 return std::move(v1);
391 return std::move(v1);
411 template<
size_t t_size>
415 return std::move(v1);
417 template<
size_t t_size>
430 template<
size_t t_size>
437 template<
size_t t_size>
447 template<
size_t t_size>
456 template<
size_t t_size>
462 s.
addAll((
char*)v1, size);
469 return static_cast<t_to
>(value.
getAs<t_to>());
472 struct ObjectInfo<String, false, true>
474 static const uint01 Dimensions = 0;
475 static const bool Vector =
false;
476 static const bool Buffer =
true;
477 static const bool Primitive =
false;
478 static const bool Pointer =
false;
479 static const bool Unsigned =
false;
480 static const bool Float =
false;
481 static const bool Integer =
false;
482 static const bool Number =
false;
483 static const bool Enum =
false;
484 static const bool String =
true;
485 static const bool Color =
false;
486 static const bool Boolean =
false;
487 static constexpr ObjectInfo<char, false, false> VectorSub() {
return ObjectInfo<char, false, false>(); }
494 return value.
size() == 0;
502 struct hash<
NDEVR::String>
504 std::size_t operator()(
const NDEVR::String& s)
const noexcept
506 return static_cast<size_t>(s.hash());
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
Buffer & operator=(const Buffer &buffer)
Definition Buffer.hpp:1653
void add(t_type &&object)
Definition Buffer.hpp:211
constexpr uint04 size() const
Definition Buffer.hpp:1374
void addAll(const Buffer< t_type, t_other_index_type, t_other_memory_allocator, t_other_memory_manager > &buffer)
Definition Buffer.hpp:276
decltype(auto) end()
Definition Buffer.hpp:719
void setSize(t_index_type new_size)
Definition Buffer.hpp:1330
t_index_type indexOf(const t_type &element) const
Definition Buffer.hpp:864
void ensureCapacity(t_index_type new_capacity, bool ensure_not_greater=false, bool ensure_not_less=true)
Definition Buffer.hpp:770
decltype(auto) begin()
Definition Buffer.hpp:497
uint04 count(const char &element) const
Definition Buffer.hpp:703
Definition MemoryManager.h:261
The core String class for the software.
Definition String.h:47
String(uint04 size, const char &value)
Definition String.h:67
NDEVR_BASE_API String toLower() const
NDEVR_BASE_API bool hasSubString(const char *sub_string, bool ignore_case=false) const
NDEVR_BASE_API String & trimWhiteSpace()
NDEVR_BASE_API void splitString(const Buffer< char > &delimiter, Buffer< String, uint04, ObjectAllocator< false > > &strings, bool preserve_empty=true) const
NDEVR_BASE_API String & formatNumberString(bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, char decimal='.', char comma=',')
NDEVR_BASE_API uint04 lastIndexOf(const char *sub_string, bool ignore_case=false) const
static NDEVR_BASE_API String toHex(char value)
NDEVR_BASE_API uint04 indexOf(const char *sub_string, bool ignore_case=false, uint04 start_index=0) const
static NDEVR_BASE_API bool IsWhiteSpace(char s)
NDEVR_BASE_API Buffer< String, uint04, ObjectAllocator< false > > splitStringLength(uint04 max_chars_per_line) const
static NDEVR_BASE_API String UnicodetoUTF8(const wchar *unicode, uint04 &advance)
NDEVR_BASE_API String formatTitleString() const
NDEVR_BASE_API String shortenString(uint04 size) const
NDEVR_BASE_API uint04 indexOf(const String &sub_string, bool ignore_case=false, uint04 start_index=0) const
NDEVR_BASE_API String & append(const String &string)
NDEVR_BASE_API void splitString(char delimiter, Buffer< String, uint04, ObjectAllocator< false > > &strings, bool preserve_empty=true) const
NDEVR_BASE_API String substr(uint04 start) const
NDEVR_BASE_API String toUpper() const
static constexpr uint08 hash(const char *value)
Definition String.h:167
bool operator==(const char *const value) const
Definition String.h:292
NDEVR_BASE_API bool matchesWildcard(const String &pattern) const
static constexpr uint04 str_len(const char *value)
Definition String.h:130
String(const t_type &value)
Definition String.h:72
NDEVR_BASE_API String & removeNonNumeric()
size_t operator()() const
Definition String.h:184
NDEVR_BASE_API bool operator<(const String &value) const
NDEVR_BASE_API bool beginsWith(const String &s, bool ignore_case=false) const
NDEVR_BASE_API uint04 lastIndexOf(const char value, bool ignore_case=false) const
NDEVR_BASE_API uint08 hashUpper() const
NDEVR_BASE_API uint04 indexOf(const char &sub_string, uint04 start_pos, uint04 size) const
Definition String.h:96
String & operator=(String &&value) noexcept
Definition String.h:276
NDEVR_BASE_API String & replace(const String &sub_string, const String &replace_sub_string, bool ignore_case=false)
static String toHex(const String &values)
Definition String.h:248
NDEVR_BASE_API bool hasSubString(const String &sub_string, bool ignore_case=false) const
NDEVR_BASE_API uint04 indexOf(const char *sub_string, bool ignore_case, uint04 start_index, uint04 size) const
bool operator==(const String &value) const
Definition String.h:281
static String toHex(const Buffer< t_object, t_allocator, t_buff > &values)
Definition String.h:238
bool operator!=(const String &value) const
Definition String.h:329
NDEVR_BASE_API uint08 hashLower() const
NDEVR_BASE_API Buffer< String, uint04, ObjectAllocator< false > > splitString(char delimiter, bool preserve_empty=true) const
void addWChar(const wchar &object)
NDEVR_BASE_API String & formatNumberString(bool add_comma, uint04 decimals)
static std::enable_if< ObjectInfo< t_object >::Integer, String >::type toHex(t_object value)
Definition String.h:223
bool operator==(const char(&string)[t_size])
Definition String.h:302
NDEVR_BASE_API uint04 indexOf(const char &sub_string, uint04 start_pos) const
Definition String.h:95
static NDEVR_BASE_API bool AlphaNumericCompare(const String &left, const String &right)
NDEVR_BASE_API String(String &&string) noexcept
NDEVR_BASE_API String & formatNumberString(uint04 decimals)
NDEVR_BASE_API String & replace(const Buffer< String, uint04, ObjectAllocator< false > > &sub_string, const Buffer< String, uint04, ObjectAllocator< false > > &replace_sub_string, bool ignore_case=false)
String(const char *string)
Definition String.h:62
static constexpr uint04 str_len(const wchar *value)
Definition String.h:137
static NDEVR_BASE_API wchar UTF8toUnicode(const char *utf8, uint04 &advance)
t_type getAs() const
Definition String.h:341
static String toHex(const Vector< t_size, t_type > &values)
Definition String.h:259
String(const char(&string)[N])
Definition String.h:54
NDEVR_BASE_API bool isNumeric() const
static NDEVR_BASE_API String ConvertToCharString(uint04 number)
NDEVR_BASE_API bool isSameNoCase(const String &s) const
static NDEVR_BASE_API String NumberString(fltp08 value, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, char decimal='.', char comma=',')
NDEVR_BASE_API void addUnicodeAsUTF8(const wchar *unicode)
String(const wchar(&string)[N])
Definition String.h:58
NDEVR_BASE_API String substr(uint04 start, uint04 end) const
String & operator=(const String &value)
Definition String.h:270
static NDEVR_BASE_API String toHex(uint01 value)
NDEVR_BASE_API uint04 fromHex() const
bool operator!=(const char *const value) const
Definition String.h:311
NDEVR_BASE_API bool addUnicodeCharAsUTF8(const wchar *unicode, uint04 &advance)
NDEVR_BASE_API const char * c_str() const
NDEVR_BASE_API Buffer< String, uint04, ObjectAllocator< false > > splitStringLength(fltp04 length, fltp04(&font_width)[256]) const
static TranslatedString DisplayString(const t_type &value)
Definition TranslatedString.h:54
NDEVR_BASE_API String insertNewLines(uint04 max_line_size) const
NDEVR_BASE_API String predictNextStringIncrement() const
NDEVR_BASE_API bool operator>(const String &value) const
bool operator!=(const char(&string)[t_size])
Definition String.h:321
NDEVR_BASE_API bool endsWith(const String &s, bool ignore_case=false) const
NDEVR_BASE_API uint04 indexOf(const char &sub_string) const
Definition String.h:94
NDEVR_BASE_API Buffer< String, uint04, ObjectAllocator< false > > splitString(const Buffer< char > &delimiter, bool preserve_empty=true) const
NDEVR_BASE_API String & addWhiteSpace(uint04 desired_string_size, uint04 desired_right_alignment_location=0, char whitespace=' ')
NDEVR_BASE_API uint08 hash() const
NDEVR_BASE_API uint04 indexOf(const char *sub_string, char escape_char, bool ignore_case=false, uint04 start_index=0) const
NDEVR_BASE_API String(const String &string)
NDEVR_BASE_API String(const char *const string, uint04 size)
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)
static void toString(const t_type &value, String &string)
static void fromString(const String &string, t_type &value)
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:62
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:177
bool operator==(const char(&v1)[t_size], const String &v2)
Definition String.h:448
wchar_t wchar
Allias for wchar_t, a value that represents a character of two bytes in size.
Definition BaseValues.hpp:151
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:125
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:78
constexpr t_to rcast(t_from value)
Casts the given value. Is equivalent to reinterpret_cast except allows for the option of special case...
Definition BaseValues.hpp:400
String operator+(const String &string_a, const String &string_b)
Definition String.h:363
String & operator+=(String &string, const String &value)
Definition String.h:425
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:104
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:94
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:379
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146
NDEVR_BASE_API ostream & operator<<(ostream &in, const NDEVR::String &string)
NDEVR_BASE_API istream & operator>>(istream &in, NDEVR::String &string)
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved.
Definition BaseValues.hpp:230
UTF8Iterator(const String &string)
const String & string
Definition String.h:359
uint04 m_position
Definition String.h:360