diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-05-02 11:10:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-02 11:10:58 -0400 |
| commit | 29cb65585782f71a9c6fa1062eaa0b8de8359604 (patch) | |
| tree | cdd820f2c4a8b26933ba4f5057f92e84b8dc01eb /source/core/slang-string-util.cpp | |
| parent | 19c0866b050a022406867aa650302f4efbf8e010 (diff) | |
Markdown CommandOptions (#2860)
* 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.
* WIP improvements around CommandOptions.
* Split out CommandOptionsWriter.
* Add links to options.
* Add command line options reference.
* Link to the reference command line information.
* Add quick links.
* Improvements around lookup.
Add categories to linking.
* Small additional fixes.
* Add LinkFlags control.
* Small text fixes.
* Fix typo.
* Fix typo.
* Fix typo.
* Add support for -g and -O using CommandOptions.
* Improve generated doc output/descriptions.
Remove options listed directly in documentation.
Diffstat (limited to 'source/core/slang-string-util.cpp')
| -rw-r--r-- | source/core/slang-string-util.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp index 7de6846d5..ac8a176ad 100644 --- a/source/core/slang-string-util.cpp +++ b/source/core/slang-string-util.cpp @@ -35,6 +35,34 @@ namespace Slang { return areAllEqual(slicesA, slicesB, equalFn); } +/* static */void StringUtil::appendSplitOnWhitespace(const UnownedStringSlice& in, List<UnownedStringSlice>& outSlices) +{ + const char* start = in.begin(); + const char* end = in.end(); + + // Skip any at the start + while (start < end && CharUtil::isWhitespace(*start)) start++; + + while (start < end) + { + // Find all the non white space in a run + const char* cur = start; + while (cur < end && !CharUtil::isWhitespace(*cur)) + { + cur++; + } + + // Add to output + outSlices.add(UnownedStringSlice(start, cur)); + + // Find the next start + start = cur + 1; + + // Skip the split + while (start < end && CharUtil::isWhitespace(*start)) start++; + } +} + /* static */void StringUtil::appendSplit(const UnownedStringSlice& in, char splitChar, List<UnownedStringSlice>& outSlices) { const char* start = in.begin(); @@ -113,6 +141,12 @@ namespace Slang { appendSplit(in, splitSlice, outSlices); } +/* static */void StringUtil::splitOnWhitespace(const UnownedStringSlice& in, List<UnownedStringSlice>& outSlices) +{ + outSlices.clear(); + appendSplitOnWhitespace(in, outSlices); +} + /* static */Index StringUtil::split(const UnownedStringSlice& in, char splitChar, Index maxSlices, UnownedStringSlice* outSlices) { Index index = 0; |
