1 // SciTE - Scintilla based Text Editor
2 /** @file StringList.h
3  ** Definition of class holding a list of strings.
4  **/
5 // Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
7 
8 #ifndef STRINGLIST_H
9 #define STRINGLIST_H
10 
11 class StringList {
12 	// Text pointed into by words and wordsNoCase
13 	std::string listText;
14 	// Each word contains at least one character.
15 	std::vector<char *> words;
16 	std::vector<char *> wordsNoCase;
17 	bool onlyLineEnds;	///< Delimited by any white space or only line ends
18 	bool sorted;
19 	bool sortedNoCase;
20 	void SetFromListText();
21 	void SortIfNeeded(bool ignoreCase);
22 public:
23 	explicit StringList(bool onlyLineEnds_ = false) :
24 		words(0), wordsNoCase(0), onlyLineEnds(onlyLineEnds_),
25 		sorted(false), sortedNoCase(false) {}
Length()26 	size_t Length() const noexcept { return words.size(); }
27 	operator bool() const noexcept { return !words.empty(); }
28 	char *operator[](size_t ind) { return words[ind]; }
29 	void Clear() noexcept;
30 	void Set(const char *s);
31 	void Set(const std::vector<char> &data);
32 	std::string GetNearestWord(const char *wordStart, size_t searchLen,
33 				   bool ignoreCase, const std::string &wordCharacters, int wordIndex);
34 	std::string GetNearestWords(const char *wordStart, size_t searchLen,
35 				    bool ignoreCase, char otherSeparator='\0', bool exactLen=false);
36 };
37 
38 #endif
39