]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/stc/scintilla/include/PropSet.h
don't use wxStaticCast to wxBookCtrlBase -- it doesn't work
[wxWidgets.git] / contrib / 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
RD
15
16struct Property {
17 unsigned int hash;
18 char *key;
19 char *val;
20 Property *next;
21 Property() : hash(0), key(0), val(0), next(0) {}
9ce192d4
RD
22};
23
65ec6247
RD
24/**
25 */
9ce192d4 26class PropSet {
88a8b04e 27protected:
d134f170
RD
28 enum { hashRoots=31 };
29 Property *props[hashRoots];
65ec6247
RD
30 Property *enumnext;
31 int enumhash;
88a8b04e
RD
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);
a33203cb 42
9ce192d4
RD
43public:
44 PropSet *superPS;
45 PropSet();
46 ~PropSet();
65ec6247
RD
47 void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
48 void Set(const char *keyVal);
a33203cb 49 void Unset(const char *key, int lenKey=-1);
65ec6247 50 void SetMultiple(const char *s);
9ce192d4 51 SString Get(const char *key);
d134f170 52 SString GetExpanded(const char *key);
e14d10b0 53 SString Expand(const char *withVars, int maxExpands=100);
9ce192d4
RD
54 int GetInt(const char *key, int defaultValue=0);
55 SString GetWild(const char *keybase, const char *filename);
1a2fb4cd 56 SString GetNewExpand(const char *keybase, const char *filename="");
9ce192d4 57 void Clear();
65ec6247
RD
58 char *ToString(); // Caller must delete[] the return value
59 bool GetFirst(char **key, char **val);
60 bool GetNext(char **key, char **val);
591d01be
RD
61
62private:
63 // copy-value semantics not implemented
64 PropSet(const PropSet &copy);
65 void operator=(const PropSet &assign);
9ce192d4
RD
66};
67
65ec6247
RD
68/**
69 */
9ce192d4
RD
70class WordList {
71public:
65ec6247 72 // Each word contains at least one character - a empty word acts as sentinel at the end.
9ce192d4 73 char **words;
d134f170 74 char **wordsNoCase;
9ce192d4
RD
75 char *list;
76 int len;
65ec6247 77 bool onlyLineEnds; ///< Delimited by any white space or only line ends
d134f170 78 bool sorted;
9ce192d4 79 int starts[256];
9e730a78 80 WordList(bool onlyLineEnds_ = false) :
d134f170 81 words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), sorted(false) {}
9ce192d4 82 ~WordList() { Clear(); }
65ec6247
RD
83 operator bool() { return len ? true : false; }
84 char *operator[](int ind) { return words[ind]; }
9ce192d4
RD
85 void Clear();
86 void Set(const char *s);
87 char *Allocate(int size);
88 void SetFromAllocated();
89 bool InList(const char *s);
a33203cb 90 const char *GetNearestWord(const char *wordStart, int searchLen,
8e54aaed 91 bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1);
a33203cb 92 char *GetNearestWords(const char *wordStart, int searchLen,
591d01be 93 bool ignoreCase=false, char otherSeparator='\0', bool exactLen=false);
9ce192d4
RD
94};
95
65ec6247
RD
96inline bool IsAlphabetic(unsigned int ch) {
97 return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z'));
98}
99
591d01be
RD
100
101#ifdef _MSC_VER
102// Visual C++ doesn't like the private copy idiom for disabling
103// the default copy constructor and operator=, but it's fine.
104#pragma warning(disable: 4511 4512)
105#endif
106
9ce192d4 107#endif