]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/include/PropSet.h
Added wxDC::GetPartialTextExtents
[wxWidgets.git] / 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 protected:
28 enum { hashRoots=31 };
29 Property *props[hashRoots];
30 Property *enumnext;
31 int enumhash;
32 static unsigned int HashString(const char *s, size_t len) {
33 unsigned int ret = 0;
34 while (len--) {
35 ret <<= 4;
36 ret ^= *s;
37 s++;
38 }
39 return ret;
40 }
41 static bool IncludesVar(const char *value, const char *key);
42 public:
43 PropSet *superPS;
44 PropSet();
45 ~PropSet();
46 void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
47 void Set(const char *keyVal);
48 void SetMultiple(const char *s);
49 SString Get(const char *key);
50 SString GetExpanded(const char *key);
51 SString Expand(const char *withVars, int maxExpands=100);
52 int GetInt(const char *key, int defaultValue=0);
53 SString GetWild(const char *keybase, const char *filename);
54 SString GetNewExpand(const char *keybase, const char *filename="");
55 void Clear();
56 char *ToString(); // Caller must delete[] the return value
57 bool GetFirst(char **key, char **val);
58 bool GetNext(char **key, char **val);
59 };
60
61 /**
62 */
63 class WordList {
64 public:
65 // Each word contains at least one character - a empty word acts as sentinel at the end.
66 char **words;
67 char **wordsNoCase;
68 char *list;
69 int len;
70 bool onlyLineEnds; ///< Delimited by any white space or only line ends
71 bool sorted;
72 int starts[256];
73 WordList(bool onlyLineEnds_ = false) :
74 words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {}
75 ~WordList() { Clear(); }
76 operator bool() { return len ? true : false; }
77 char *operator[](int ind) { return words[ind]; }
78 void Clear();
79 void Set(const char *s);
80 char *Allocate(int size);
81 void SetFromAllocated();
82 bool InList(const char *s);
83 const char *GetNearestWord(const char *wordStart, int searchLen = -1,
84 bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1);
85 char *GetNearestWords(const char *wordStart, int searchLen=-1,
86 bool ignoreCase=false, char otherSeparator='\0');
87 };
88
89 inline bool IsAlphabetic(unsigned int ch) {
90 return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
91 }
92
93 #endif