summaryrefslogtreecommitdiff
path: root/source/core/slang-string.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-06-09 12:38:24 -0400
committerGitHub <noreply@github.com>2023-06-09 12:38:24 -0400
commitd9118d260034319d58376c2ecf67b339568d85fb (patch)
tree3146461052bd96146b1db5e987b65f6bf6f587be /source/core/slang-string.h
parent3913091a021a8f4525f0050dfb83d1c2b8fc6f6b (diff)
Small improvements around StringBlob (#2924)
* #include an absolute path didn't work - because paths were taken to always be relative. * Small fixes and improvements around reflection tool. * Make PrettyWriter printing a class. * Sundary improvements around StringBlob.
Diffstat (limited to 'source/core/slang-string.h')
-rw-r--r--source/core/slang-string.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/core/slang-string.h b/source/core/slang-string.h
index b4583d0b2..65fd3a315 100644
--- a/source/core/slang-string.h
+++ b/source/core/slang-string.h
@@ -81,6 +81,10 @@ namespace Slang
public:
typedef UnownedStringSlice ThisType;
+ // Type to indicate that a ctor is with a length to disabmiguate 0/nullptr
+ // causing ambiguity.
+ struct WithLength {};
+
UnownedStringSlice()
: m_begin(nullptr)
, m_end(nullptr)
@@ -98,6 +102,10 @@ namespace Slang
: m_begin(b)
, m_end(b + len)
{}
+ UnownedStringSlice(WithLength, char const* b, size_t len)
+ : m_begin(b)
+ , m_end(b + len)
+ {}
SLANG_FORCE_INLINE char const* begin() const { return m_begin; }
@@ -190,6 +198,7 @@ namespace Slang
SLANG_FORCE_INLINE static UnownedStringSlice fromLiteral(const char (&in)[SIZE]) { return UnownedStringSlice(in, SIZE - 1); }
protected:
+
char const* m_begin;
char const* m_end;
};
@@ -216,6 +225,9 @@ namespace Slang
template <size_t SIZE>
SLANG_FORCE_INLINE static ThisType fromLiteral(const char(&in)[SIZE]) { return ThisType(in, SIZE - 1); }
+ /// Default constructor
+ UnownedTerminatedStringSlice():Super(Super::WithLength(), "", 0) {}
+
/// Note, b cannot be null because if it were then the string would not be null terminated
UnownedTerminatedStringSlice(char const* b)
: Super(b, b + strlen(b))