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 | 4333970abdd54863a591f95df3c3e7e968aa2519 (patch) | |
| tree | 4ce4c0328efa72601422bb1674fcabd8942c1051 /src/UniqueString.h | |
| parent | d2bb3203067343b51bf3c543b331741f6fa4ad21 (diff) | |
| download | scintilla-mirror-4333970abdd54863a591f95df3c3e7e968aa2519.tar.gz | |
Rename FontNames to UniqueStringSet and move into UniqueString.
It may be useful in more situations than just font names.
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 | 
