summaryrefslogtreecommitdiffstats
path: root/source/core/slang-string.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-04-25 12:25:52 -0400
committerGitHub <noreply@github.com>2023-04-25 09:25:52 -0700
commit5abee6a0a30c7c965138ec7286b7f1b21b201731 (patch)
tree0469f6f85bac0fcf502a95f2a60c49179349dd17 /source/core/slang-string.cpp
parente5d5e3c215f3300bf447e6ab46cdf8d5c12f58a6 (diff)
StringBuilder to lowerCamel (#2840)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP lowerCamel Dictionary. * WIP more lowerCamel fixes for Dictionary. * Add/Remove/Clear * GetValue/Contains * Fix tabs in dictionary. Count -> getCount * Fix fields with caps. * Key -> key Value -> value Use m_ for members where appropriate. Use lowerCamel in linked list. * Some small fixes/improvements to Dictionary. * Kick CI. * Small tidy on String. * Append -> append * ToString -> toString ProduceString -> produceString * Small fixes. * StringToXXX -> stringToXXX * Fix typo introduced by Append -> append. * Made intToAscii do reversal at the end. --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/core/slang-string.cpp')
-rw-r--r--source/core/slang-string.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/source/core/slang-string.cpp b/source/core/slang-string.cpp
index dc3c3ed46..0cb034604 100644
--- a/source/core/slang-string.cpp
+++ b/source/core/slang-string.cpp
@@ -261,25 +261,25 @@ namespace Slang
return result;
}
- int StringToInt(const String & str, int radix)
+ int stringToInt(const String& str, int radix)
{
if (str.startsWith("0x"))
return (int)strtoll(str.getBuffer(), NULL, 16);
else
return (int)strtoll(str.getBuffer(), NULL, radix);
}
- unsigned int StringToUInt(const String & str, int radix)
+ unsigned int stringToUInt(const String& str, int radix)
{
if (str.startsWith("0x"))
return (unsigned int)strtoull(str.getBuffer(), NULL, 16);
else
return (unsigned int)strtoull(str.getBuffer(), NULL, radix);
}
- double StringToDouble(const String & str)
+ double stringToDouble(const String& str)
{
return (double)strtod(str.getBuffer(), NULL);
}
- float StringToFloat(const String & str)
+ float stringToFloat(const String& str)
{
return strtof(str.getBuffer(), NULL);
}
@@ -300,7 +300,7 @@ namespace Slang
}
#endif
- String String::fromWString(const wchar_t * wstr)
+ String String::fromWString(const wchar_t* wstr)
{
List<char> buf;
#ifdef _WIN32
@@ -311,7 +311,7 @@ namespace Slang
return String(buf.begin(), buf.end());
}
- String String::fromWString(const wchar_t * wstr, const wchar_t * wend)
+ String String::fromWString(const wchar_t* wstr, const wchar_t* wend)
{
List<char> buf;
#ifdef _WIN32
@@ -481,6 +481,11 @@ namespace Slang
}
}
+ void String::append(char const* str, size_t len)
+ {
+ append(str, str + len);
+ }
+
void String::append(const char* textBegin, char const* textEnd)
{
auto oldLength = getLength();
@@ -563,8 +568,7 @@ namespace Slang
{
enum { kCount = 33 };
char* data = prepareForAppend(kCount);
- auto count = IntToAscii(data, value, radix);
- ReverseInternalAscii(data, count);
+ const auto count = intToAscii(data, value, radix);
m_buffer->length += count;
}
@@ -572,8 +576,7 @@ namespace Slang
{
enum { kCount = 33 };
char* data = prepareForAppend(kCount);
- auto count = IntToAscii(data, value, radix);
- ReverseInternalAscii(data, count);
+ const auto count = intToAscii(data, value, radix);
m_buffer->length += count;
}
@@ -581,8 +584,7 @@ namespace Slang
{
enum { kCount = 65 };
char* data = prepareForAppend(kCount);
- auto count = IntToAscii(data, value, radix);
- ReverseInternalAscii(data, count);
+ auto count = intToAscii(data, value, radix);
m_buffer->length += count;
}
@@ -590,12 +592,11 @@ namespace Slang
{
enum { kCount = 65 };
char* data = prepareForAppend(kCount);
- auto count = IntToAscii(data, value, radix);
- ReverseInternalAscii(data, count);
+ auto count = intToAscii(data, value, radix);
m_buffer->length += count;
}
- void String::append(float val, const char * format)
+ void String::append(float val, const char* format)
{
enum { kCount = 128 };
char* data = prepareForAppend(kCount);
@@ -603,7 +604,7 @@ namespace Slang
m_buffer->length += strnlen_s(data, kCount);
}
- void String::append(double val, const char * format)
+ void String::append(double val, const char* format)
{
enum { kCount = 128 };
char* data = prepareForAppend(kCount);