|
@ -155,175 +155,11 @@ template<typename T> void Jupiter::String_Type<T>::remove(size_t index, size_t l |
|
|
|
|
|
|
|
|
// erase
|
|
|
// erase
|
|
|
|
|
|
|
|
|
template<typename T> void Jupiter::String_Type<T>::erase() |
|
|
template<typename T> void Jupiter::String_Type<T>::clear() |
|
|
{ |
|
|
{ |
|
|
Jupiter::String_Type<T>::length = 0; |
|
|
Jupiter::String_Type<T>::length = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// processEscapeSequences
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> void Jupiter::String_Type<T>::processEscapeSequences() |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<> inline void Jupiter::String_Type<char>::processEscapeSequences() |
|
|
|
|
|
{ |
|
|
|
|
|
if (Jupiter::String_Type<char>::length == 0) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
size_t index = 0; |
|
|
|
|
|
while (index + 1 != Jupiter::String_Type<char>::length) |
|
|
|
|
|
{ |
|
|
|
|
|
if (operator[](index) == '\\') |
|
|
|
|
|
{ |
|
|
|
|
|
switch (operator[](++index)) |
|
|
|
|
|
{ |
|
|
|
|
|
case '0': |
|
|
|
|
|
case '1': |
|
|
|
|
|
case '2': |
|
|
|
|
|
case '3': |
|
|
|
|
|
if (index + 1 != Jupiter::String_Type<char>::length && Jupiter_isOctal(operator[](index + 1))) |
|
|
|
|
|
{ |
|
|
|
|
|
if (index + 2 != Jupiter::String_Type<char>::length && Jupiter_isOctal(operator[](index + 2))) |
|
|
|
|
|
this->replace(index - 1, 4, static_cast<uint8_t>(Jupiter_getOctal(operator[](index))) << 6 | static_cast<uint8_t>(Jupiter_getOctal(operator[](index + 1))) << 3 | static_cast<uint8_t>(Jupiter_getOctal(operator[](index + 2)))); |
|
|
|
|
|
else |
|
|
|
|
|
this->replace(index - 1, 3, static_cast<uint8_t>(Jupiter_getOctal(operator[](index))) << 3 | static_cast<uint8_t>(Jupiter_getOctal(operator[](index + 1)))); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
this->replace(index - 1, 2, static_cast<uint8_t>(Jupiter_getOctal(operator[](index)))); |
|
|
|
|
|
break; |
|
|
|
|
|
case '4': |
|
|
|
|
|
case '5': |
|
|
|
|
|
case '6': |
|
|
|
|
|
case '7': |
|
|
|
|
|
if (index + 1 != Jupiter::String_Type<char>::length && Jupiter_isOctal(operator[](index + 1))) |
|
|
|
|
|
this->replace(index - 1, 3, static_cast<uint8_t>(Jupiter_getOctal(operator[](index))) << 3 | static_cast<uint8_t>(Jupiter_getOctal(operator[](index + 1)))); |
|
|
|
|
|
else |
|
|
|
|
|
this->replace(index - 1, 2, static_cast<uint8_t>(Jupiter_getOctal(operator[](index)))); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'a': |
|
|
|
|
|
this->replace(index - 1, 2, '\a'); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'b': |
|
|
|
|
|
this->replace(index - 1, 2, '\b'); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'f': |
|
|
|
|
|
this->replace(index - 1, 2, '\f'); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'n': |
|
|
|
|
|
this->replace(index - 1, 2, '\n'); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'r': |
|
|
|
|
|
this->replace(index - 1, 2, '\r'); |
|
|
|
|
|
break; |
|
|
|
|
|
case 't': |
|
|
|
|
|
this->replace(index - 1, 2, '\t'); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'v': |
|
|
|
|
|
this->replace(index - 1, 2, '\v'); |
|
|
|
|
|
break; |
|
|
|
|
|
case '?': |
|
|
|
|
|
this->replace(index - 1, 2, '\?'); |
|
|
|
|
|
break; |
|
|
|
|
|
case '\'': |
|
|
|
|
|
this->replace(index - 1, 2, '\''); |
|
|
|
|
|
break; |
|
|
|
|
|
case '\"': |
|
|
|
|
|
this->replace(index - 1, 2, '\"'); |
|
|
|
|
|
break; |
|
|
|
|
|
case '\\': |
|
|
|
|
|
this->replace(index - 1, 2, '\\'); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'x': |
|
|
|
|
|
if (Jupiter::String_Type<char>::length >= index + 2 |
|
|
|
|
|
&& Jupiter_isHex(operator[](index + 1)) && Jupiter_isHex(operator[](index + 2))) |
|
|
|
|
|
this->replace(index - 1, 4, static_cast<uint8_t>(Jupiter_getHex(operator[](index + 1))) << 4 | static_cast<uint8_t>(Jupiter_getHex(operator[](index + 2)))); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'U': |
|
|
|
|
|
if (Jupiter::String_Type<char>::length >= index + 8 |
|
|
|
|
|
&& Jupiter_isHex(operator[](index + 1)) && Jupiter_isHex(operator[](index + 2)) && Jupiter_isHex(operator[](index + 3)) && Jupiter_isHex(operator[](index + 4)) && Jupiter_isHex(operator[](index + 5)) && Jupiter_isHex(operator[](index + 6)) && Jupiter_isHex(operator[](index + 7)) && Jupiter_isHex(operator[](index + 8))) |
|
|
|
|
|
{ |
|
|
|
|
|
uint32_t codepoint = static_cast<uint8_t>(Jupiter_getHex(operator[](index + 1))) << 4 | static_cast<uint8_t>(Jupiter_getHex(operator[](index + 2))); |
|
|
|
|
|
codepoint <<= 8; |
|
|
|
|
|
codepoint |= static_cast<uint8_t>(Jupiter_getHex(operator[](index + 3))) << 4 | static_cast<uint8_t>(Jupiter_getHex(operator[](index + 4))); |
|
|
|
|
|
codepoint <<= 8; |
|
|
|
|
|
codepoint |= static_cast<uint8_t>(Jupiter_getHex(operator[](index + 5))) << 4 | static_cast<uint8_t>(Jupiter_getHex(operator[](index + 6))); |
|
|
|
|
|
codepoint <<= 8; |
|
|
|
|
|
codepoint |= static_cast<uint8_t>(Jupiter_getHex(operator[](index + 7))) << 4 | static_cast<uint8_t>(Jupiter_getHex(operator[](index + 8))); |
|
|
|
|
|
if (codepoint <= 0x007F) |
|
|
|
|
|
this->replace(index - 1, 10, static_cast<uint8_t>(codepoint)); |
|
|
|
|
|
else if (codepoint <= 0x07FF) |
|
|
|
|
|
{ |
|
|
|
|
|
char bytes[2]; |
|
|
|
|
|
bytes[0] = 0xC0 | ((codepoint >> 6) & 0x1F); |
|
|
|
|
|
bytes[1] = 0x80 | (codepoint & 0x3F); |
|
|
|
|
|
this->replace(index - 1, 10, bytes, sizeof(bytes)); |
|
|
|
|
|
++index; |
|
|
|
|
|
} |
|
|
|
|
|
else if (codepoint <= 0xFFFF) |
|
|
|
|
|
{ |
|
|
|
|
|
char bytes[3]; |
|
|
|
|
|
bytes[0] = 0xE0 | ((codepoint >> 12) & 0x0F); |
|
|
|
|
|
bytes[1] = 0x80 | ((codepoint >> 6) & 0x3F); |
|
|
|
|
|
bytes[2] = 0x80 | (codepoint & 0x3F); |
|
|
|
|
|
this->replace(index - 1, 10, bytes, sizeof(bytes)); |
|
|
|
|
|
index += 2; |
|
|
|
|
|
} |
|
|
|
|
|
else if (codepoint <= 0x10FFFF) |
|
|
|
|
|
{ |
|
|
|
|
|
char bytes[4]; |
|
|
|
|
|
bytes[0] = 0xE0 | ((codepoint >> 18) & 0x0F); |
|
|
|
|
|
bytes[1] = 0x80 | ((codepoint >> 12) & 0x3F); |
|
|
|
|
|
bytes[2] = 0x80 | ((codepoint >> 6) & 0x3F); |
|
|
|
|
|
bytes[3] = 0x80 | (codepoint & 0x3F); |
|
|
|
|
|
this->replace(index - 1, 10, bytes, sizeof(bytes)); |
|
|
|
|
|
index += 3; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 'u': |
|
|
|
|
|
if (Jupiter::String_Type<char>::length >= index + 4 |
|
|
|
|
|
&& Jupiter_isHex(operator[](index + 1)) && Jupiter_isHex(operator[](index + 2)) && Jupiter_isHex(operator[](index + 3)) && Jupiter_isHex(operator[](index + 4))) |
|
|
|
|
|
{ |
|
|
|
|
|
uint16_t codepoint = static_cast<uint8_t>(Jupiter_getHex(operator[](index + 1))) << 4 | static_cast<uint8_t>(Jupiter_getHex(operator[](index + 2))); |
|
|
|
|
|
codepoint <<= 8; |
|
|
|
|
|
codepoint |= static_cast<uint8_t>(Jupiter_getHex(operator[](index + 3))) << 4 | static_cast<uint8_t>(Jupiter_getHex(operator[](index + 4))); |
|
|
|
|
|
if (codepoint <= 0x007F) |
|
|
|
|
|
this->replace(index - 1, 6, static_cast<uint8_t>(codepoint)); |
|
|
|
|
|
else if (codepoint <= 0x07FF) |
|
|
|
|
|
{ |
|
|
|
|
|
char bytes[2]; |
|
|
|
|
|
bytes[0] = 0xC0 | ((codepoint >> 6) & 0x1F); |
|
|
|
|
|
bytes[1] = 0x80 | (codepoint & 0x3F); |
|
|
|
|
|
this->replace(index - 1, 6, bytes, sizeof(bytes)); |
|
|
|
|
|
++index; |
|
|
|
|
|
} |
|
|
|
|
|
else if (codepoint <= 0xFFFF) |
|
|
|
|
|
{ |
|
|
|
|
|
char bytes[3]; |
|
|
|
|
|
bytes[0] = 0xE0 | ((codepoint >> 12) & 0x0F); |
|
|
|
|
|
bytes[1] = 0x80 | ((codepoint >> 6) & 0x3F); |
|
|
|
|
|
bytes[2] = 0x80 | (codepoint & 0x3F); |
|
|
|
|
|
this->replace(index - 1, 6, bytes, sizeof(bytes)); |
|
|
|
|
|
index += 2; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (index == Jupiter::String_Type<char>::length) |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
++index; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template<> inline void Jupiter::String_Type<wchar_t>::processEscapeSequences() |
|
|
|
|
|
{ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// set
|
|
|
// set
|
|
|
|
|
|
|
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(size_t index, const T &in) |
|
|
template<typename T> size_t Jupiter::String_Type<T>::set(size_t index, const T &in) |
|
|