]> git.saurik.com Git - wxWidgets.git/blame - src/stc/scintilla/include/PropSet.h
mac paths updated
[wxWidgets.git] / src / stc / scintilla / include / PropSet.h
CommitLineData
65ec6247
RD
1// Scintilla source code edit control
2/** @file PropSet.h
3 ** A Java style properties file module.
4 **/
1a2fb4cd 5// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
9ce192d4
RD
6// The License.txt file describes the conditions under which this software may be distributed.
7
8#ifndef PROPSET_H
9#define PROPSET_H
65ec6247 10#include "SString.h"
9ce192d4
RD
11
12bool EqualCaseInsensitive(const char *a, const char *b);
13
65ec6247 14bool isprefix(const char *target, const char *prefix);
d134f170 15
7e0c58e9
RD
16#ifdef SCI_NAMESPACE
17namespace Scintilla {
18#endif
19
d134f170
RD
20struct Property {
21 unsigned int hash;
22 char *key;
23 char *val;
24 Property *next;
25 Property() : hash(0), key(0), val(0), next(0) {}
9ce192d4
RD
26};
27
65ec6247
RD
28/**
29 */
9ce192d4 30class PropSet {
88a8b04e 31protected:
d134f170
RD
32 enum { hashRoots=31 };
33 Property *props[hashRoots];
65ec6247
RD
34 Property *enumnext;
35 int enumhash;
88a8b04e
RD
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 }
a33203cb 45
9ce192d4
RD
46public:
47 PropSet *superPS;
48 PropSet();
49 ~PropSet();
65ec6247
RD
50 void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
51 void Set(const char *keyVal);
a33203cb 52 void Unset(const char *key, int lenKey=-1);
65ec6247 53 void SetMultiple(const char *s);
7e0c58e9
RD
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;
9ce192d4 58 void Clear();
7e0c58e9 59 char *ToString() const; // Caller must delete[] the return value
591d01be
RD
60
61private:
1e9bafca 62 // copy-value semantics not implemented
591d01be
RD
63 PropSet(const PropSet &copy);
64 void operator=(const PropSet &assign);
9ce192d4
RD
65};
66
65ec6247
RD
67/**
68 */
9ce192d4
RD
69class WordList {
70public:
65ec6247 71 // Each word contains at least one character - a empty word acts as sentinel at the end.
9ce192d4
RD
72 char **words;
73 char *list;
74 int len;
65ec6247 75 bool onlyLineEnds; ///< Delimited by any white space or only line ends
d134f170 76 bool sorted;
9ce192d4 77 int starts[256];
9e730a78 78 WordList(bool onlyLineEnds_ = false) :
7e0c58e9
RD
79 words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_),
80 sorted(false)
81 {}
9ce192d4 82 ~WordList() { Clear(); }
65ec6247 83 operator bool() { return len ? true : false; }
9ce192d4
RD
84 void Clear();
85 void Set(const char *s);
9ce192d4 86 bool InList(const char *s);
1e9bafca 87 bool InListAbbreviated(const char *s, const char marker);
9ce192d4
RD
88};
89
65ec6247
RD
90inline bool IsAlphabetic(unsigned int ch) {
91 return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
92}
93
7e0c58e9
RD
94#ifdef SCI_NAMESPACE
95}
96#endif
591d01be
RD
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
9ce192d4 104#endif