Prepare release and bump version numbers to 2.17.0.2
[TortoiseGit.git] / ext / scintilla / src / UniqueString.h
blob299cd820347d0c6a54c947d88f4a1c5d508e5bfc
1 // Scintilla source code edit control
2 /** @file UniqueString.h
3 ** Define UniqueString, a unique_ptr based string type for storage in containers
4 ** and an allocator for UniqueString.
5 ** Define UniqueStringSet which holds a set of strings, used to avoid holding many copies
6 ** of font names.
7 **/
8 // Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
9 // The License.txt file describes the conditions under which this software may be distributed.
11 #ifndef UNIQUESTRING_H
12 #define UNIQUESTRING_H
14 namespace Scintilla::Internal {
16 constexpr bool IsNullOrEmpty(const char *text) noexcept {
17 return text == nullptr || *text == '\0';
20 using UniqueString = std::unique_ptr<const char[]>;
22 /// Equivalent to strdup but produces a std::unique_ptr<const char[]> allocation to go
23 /// into collections.
24 UniqueString UniqueStringCopy(const char *text);
26 // A set of strings that always returns the same pointer for each string.
28 class UniqueStringSet {
29 private:
30 std::vector<UniqueString> strings;
31 public:
32 UniqueStringSet();
33 void Clear() noexcept;
34 const char *Save(const char *text);
39 #endif