diff options
author | Neil <nyamatongwe@gmail.com> | 2019-04-08 08:34:52 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2019-04-08 08:34:52 +1000 |
commit | 4a44fd852450d9e97032633524f92d1fad5f7187 (patch) | |
tree | e7e99b2532a0766190cba557131431b05ec4ceb2 /src/UniqueString.h | |
parent | bdfbc5325157c037fdaa70d6c7fe757046f08906 (diff) | |
download | scintilla-mirror-4a44fd852450d9e97032633524f92d1fad5f7187.tar.gz |
Backport: Rename FontNames to UniqueStringSet and move into UniqueString.
It may be useful in more situations than just font names.
Backport of changeset 7409:a70a4ee51448.
Diffstat (limited to 'src/UniqueString.h')
-rw-r--r-- | src/UniqueString.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/UniqueString.h b/src/UniqueString.h index 44ba26652..f7f7ebbdc 100644 --- a/src/UniqueString.h +++ b/src/UniqueString.h @@ -2,6 +2,8 @@ /** @file UniqueString.h ** Define UniqueString, a unique_ptr based string type for storage in containers ** and an allocator for UniqueString. + ** Define UniqueStringSet which holds a set of strings, used to avoid holding many copies + ** of font names. **/ // Copyright 2017 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. @@ -21,6 +23,24 @@ using UniqueString = std::unique_ptr<const char[]>; /// into collections. UniqueString UniqueStringCopy(const char *text); +// A set of strings that always returns the same pointer for each string. + +class UniqueStringSet { +private: + std::vector<UniqueString> strings; +public: + UniqueStringSet() noexcept; + // UniqueStringSet objects can not be copied. + UniqueStringSet(const UniqueStringSet &) = delete; + UniqueStringSet &operator=(const UniqueStringSet &) = delete; + // UniqueStringSet objects can be moved. + UniqueStringSet(UniqueStringSet &&) = default; + UniqueStringSet &operator=(UniqueStringSet &&) = default; + ~UniqueStringSet(); + void Clear() noexcept; + const char *Save(const char *text); +}; + } #endif |