]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/include/PropSet.h
Update to Scintilla 1.53
[wxWidgets.git] / contrib / src / stc / scintilla / include / PropSet.h
1 // Scintilla source code edit control
2 /** @file PropSet.h
3 ** A Java style properties file module.
4 **/
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
7
8 #ifndef PROPSET_H
9 #define PROPSET_H
10 #include "SString.h"
11
12 bool EqualCaseInsensitive(const char *a, const char *b);
13
14 bool isprefix(const char *target, const char *prefix);
15
16 struct Property {
17 unsigned int hash;
18 char *key;
19 char *val;
20 Property *next;
21 Property() : hash(0), key(0), val(0), next(0) {}
22 };
23
24 /**
25 */
26 class PropSet {
27 private:
28 enum { hashRoots=31 };
29 Property *props[hashRoots];
30 Property *enumnext;
31 int enumhash;
32 public:
33 PropSet *superPS;
34 PropSet();
35 ~PropSet();
36 void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
37 void Set(const char *keyVal);
38 void SetMultiple(const char *s);
39 SString Get(const char *key);
40 SString GetExpanded(const char *key);
41 SString Expand(const char *withVars, int maxExpands=100);
42 int GetInt(const char *key, int defaultValue=0);
43 SString GetWild(const char *keybase, const char *filename);
44 SString GetNewExpand(const char *keybase, const char *filename="");
45 void Clear();
46 char *ToString(); // Caller must delete[] the return value
47 bool GetFirst(char **key, char **val);
48 bool GetNext(char **key, char **val);
49 };
50
51 /**
52 */
53 class WordList {
54 public:
55 // Each word contains at least one character - a empty word acts as sentinel at the end.
56 char **words;
57 char **wordsNoCase;
58 char *list;
59 int len;
60 bool onlyLineEnds; ///< Delimited by any white space or only line ends
61 bool sorted;
62 int starts[256];
63 WordList(bool onlyLineEnds_ = false) :
64 words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {}
65 ~WordList() { Clear(); }
66 operator bool() { return len ? true : false; }
67 char *operator[](int ind) { return words[ind]; }
68 void Clear();
69 void Set(const char *s);
70 char *Allocate(int size);
71 void SetFromAllocated();
72 bool InList(const char *s);
73 const char *GetNearestWord(const char *wordStart, int searchLen = -1,
74 bool ignoreCase = false, SString wordCharacters="");
75 char *GetNearestWords(const char *wordStart, int searchLen=-1,
76 bool ignoreCase=false, char otherSeparator='\0');
77 };
78
79 inline bool IsAlphabetic(unsigned int ch) {
80 return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
81 }
82
83 #endif