]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/include/PropSet.h
get rid of several dozen of warnings when using g++ >= 4.2 about string literals...
[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 #ifdef SCI_NAMESPACE
17 namespace Scintilla {
18 #endif
19
20 struct Property {
21 unsigned int hash;
22 char *key;
23 char *val;
24 Property *next;
25 Property() : hash(0), key(0), val(0), next(0) {}
26 };
27
28 /**
29 */
30 class PropSet {
31 protected:
32 enum { hashRoots=31 };
33 Property *props[hashRoots];
34 Property *enumnext;
35 int enumhash;
36 static unsigned int HashString(const char *s, size_t len) {
37 unsigned int ret = 0;
38 while (len--) {
39 ret <<= 4;
40 ret ^= *s;
41 s++;
42 }
43 return ret;
44 }
45
46 public:
47 PropSet *superPS;
48 PropSet();
49 ~PropSet();
50 void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
51 void Set(const char *keyVal);
52 void Unset(const char *key, int lenKey=-1);
53 void SetMultiple(const char *s);
54 SString Get(const char *key) const;
55 SString GetExpanded(const char *key) const;
56 SString Expand(const char *withVars, int maxExpands=100) const;
57 int GetInt(const char *key, int defaultValue=0) const;
58 void Clear();
59 char *ToString() const; // Caller must delete[] the return value
60
61 private:
62 // copy-value semantics not implemented
63 PropSet(const PropSet &copy);
64 void operator=(const PropSet &assign);
65 };
66
67 /**
68 */
69 class WordList {
70 public:
71 // Each word contains at least one character - a empty word acts as sentinel at the end.
72 char **words;
73 char *list;
74 int len;
75 bool onlyLineEnds; ///< Delimited by any white space or only line ends
76 bool sorted;
77 int starts[256];
78 WordList(bool onlyLineEnds_ = false) :
79 words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_),
80 sorted(false)
81 {}
82 ~WordList() { Clear(); }
83 operator bool() { return len ? true : false; }
84 void Clear();
85 void Set(const char *s);
86 bool InList(const char *s);
87 bool InListAbbreviated(const char *s, const char marker);
88 };
89
90 inline bool IsAlphabetic(unsigned int ch) {
91 return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
92 }
93
94 #ifdef SCI_NAMESPACE
95 }
96 #endif
97
98 #ifdef _MSC_VER
99 // Visual C++ doesn't like the private copy idiom for disabling
100 // the default copy constructor and operator=, but it's fine.
101 #pragma warning(disable: 4511 4512)
102 #endif
103
104 #endif