OSDN Git Service

Commit DialogBox compile Okay
[tortoisegit/TortoiseGitJp.git] / ext / scintilla / include / PropSet.h
1 // Scintilla source code edit control\r
2 /** @file PropSet.h\r
3  ** A Java style properties file module.\r
4  **/\r
5 // Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>\r
6 // The License.txt file describes the conditions under which this software may be distributed.\r
7 \r
8 #ifndef PROPSET_H\r
9 #define PROPSET_H\r
10 #include "SString.h"\r
11 \r
12 bool EqualCaseInsensitive(const char *a, const char *b);\r
13 \r
14 bool isprefix(const char *target, const char *prefix);\r
15 \r
16 #ifdef SCI_NAMESPACE\r
17 namespace Scintilla {\r
18 #endif\r
19 \r
20 struct Property {\r
21         unsigned int hash;\r
22         char *key;\r
23         char *val;\r
24         Property *next;\r
25         Property() : hash(0), key(0), val(0), next(0) {}\r
26 };\r
27 \r
28 /**\r
29  */\r
30 class PropSet {\r
31 protected:\r
32         enum { hashRoots=31 };\r
33         Property *props[hashRoots];\r
34         Property *enumnext;\r
35         int enumhash;\r
36         static unsigned int HashString(const char *s, size_t len) {\r
37                 unsigned int ret = 0;\r
38                 while (len--) {\r
39                         ret <<= 4;\r
40                         ret ^= *s;\r
41                         s++;\r
42                 }\r
43                 return ret;\r
44         }\r
45 \r
46 public:\r
47         PropSet *superPS;\r
48         PropSet();\r
49         ~PropSet();\r
50         void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);\r
51         void Set(const char *keyVal);\r
52         void Unset(const char *key, int lenKey=-1);\r
53         void SetMultiple(const char *s);\r
54         SString Get(const char *key) const;\r
55         SString GetExpanded(const char *key) const;\r
56         SString Expand(const char *withVars, int maxExpands=100) const;\r
57         int GetInt(const char *key, int defaultValue=0) const;\r
58         void Clear();\r
59         char *ToString() const; // Caller must delete[] the return value\r
60 \r
61 private:\r
62         // copy-value semantics not implemented\r
63         PropSet(const PropSet &copy);\r
64         void operator=(const PropSet &assign);\r
65 };\r
66 \r
67 /**\r
68  */\r
69 class WordList {\r
70 public:\r
71         // Each word contains at least one character - a empty word acts as sentinel at the end.\r
72         char **words;\r
73         char *list;\r
74         int len;\r
75         bool onlyLineEnds;      ///< Delimited by any white space or only line ends\r
76         bool sorted;\r
77         int starts[256];\r
78         WordList(bool onlyLineEnds_ = false) :\r
79                 words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_),\r
80                 sorted(false)\r
81                 {}\r
82         ~WordList() { Clear(); }\r
83         operator bool() { return len ? true : false; }\r
84         void Clear();\r
85         void Set(const char *s);\r
86         bool InList(const char *s);\r
87         bool InListAbbreviated(const char *s, const char marker);\r
88 };\r
89 \r
90 inline bool IsAlphabetic(unsigned int ch) {\r
91         return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));\r
92 }\r
93 \r
94 #ifdef SCI_NAMESPACE\r
95 }\r
96 #endif\r
97 \r
98 #ifdef _MSC_VER\r
99 // Visual C++ doesn't like the private copy idiom for disabling\r
100 // the default copy constructor and operator=, but it's fine.\r
101 #pragma warning(disable: 4511 4512)\r
102 #endif\r
103 \r
104 #endif\r