summaryrefslogtreecommitdiffstats
path: root/source/core/slang-string-util.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-04-29 09:24:26 -0400
committerGitHub <noreply@github.com>2023-04-29 09:24:26 -0400
commit19c0866b050a022406867aa650302f4efbf8e010 (patch)
treef5ed4e1f5d27865518daf81c7e861b4908186b23 /source/core/slang-string-util.cpp
parentc571bcb025009f9c662e8d631fa49dbfed560287 (diff)
CommandOptions (#2856)
* WIP CommandOptions * Fix some output issues. * Simplify word wrapping. * Add file extensions. * Change how lookup takes place. Add appendSplit functions to StringUtil. Make Categories hold the index range of their options. * Small improvement. * Lookup with partial option names. * Associate user values. * Encoding flags in the name. * Refactor setting up of command options. * Use CommandOptions in slang-options. * Remove old help text. * Cache the CommandOptions on the Session. * Range checking. Fix bug in the Options handling. * Extra checks for validity. * Get categories directly. * Slight improvements over output. * Added NameValue types. * Fix typo. Remove some now unused diagnostics. Fix diagnostic in testing, as output has changed. * Add minimal usage message. * Remove platform executable extension from diagnostics output. * Some improvements around getting names from NameValue types. * Improve some option descriptions. * Small fixes.
Diffstat (limited to 'source/core/slang-string-util.cpp')
-rw-r--r--source/core/slang-string-util.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp
index 29e0dad5d..7de6846d5 100644
--- a/source/core/slang-string-util.cpp
+++ b/source/core/slang-string-util.cpp
@@ -35,10 +35,8 @@ namespace Slang {
return areAllEqual(slicesA, slicesB, equalFn);
}
-/* static */void StringUtil::split(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& outSlices)
+/* static */void StringUtil::appendSplit(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& outSlices)
{
- outSlices.clear();
-
const char* start = in.begin();
const char* end = in.end();
@@ -59,17 +57,15 @@ namespace Slang {
}
}
-/* static */void StringUtil::split(const UnownedStringSlice& in, const UnownedStringSlice& splitSlice, List<UnownedStringSlice>& outSlices)
+/* static */void StringUtil::appendSplit(const UnownedStringSlice& in, const UnownedStringSlice& splitSlice, List<UnownedStringSlice>& outSlices)
{
const Index splitLen = splitSlice.getLength();
if (splitLen == 1)
{
- return split(in, splitSlice[0], outSlices);
+ return appendSplit(in, splitSlice[0], outSlices);
}
- outSlices.clear();
-
SLANG_ASSERT(splitLen > 0);
if (splitLen <= 0)
{
@@ -96,7 +92,7 @@ namespace Slang {
cur++;
}
-
+
// Add to output
outSlices.add(UnownedStringSlice(start, cur));
@@ -105,6 +101,18 @@ namespace Slang {
}
}
+/* static */void StringUtil::split(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& outSlices)
+{
+ outSlices.clear();
+ appendSplit(in, splitChar, outSlices);
+}
+
+/* static */void StringUtil::split(const UnownedStringSlice& in, const UnownedStringSlice& splitSlice, List<UnownedStringSlice>& outSlices)
+{
+ outSlices.clear();
+ appendSplit(in, splitSlice, outSlices);
+}
+
/* static */Index StringUtil::split(const UnownedStringSlice& in, char splitChar, Index maxSlices, UnownedStringSlice* outSlices)
{
Index index = 0;