]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/include/PropSet.h
1 // SciTE - Scintilla based Text Editor
2 // PropSet.h - a java style properties file module
3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4 // The License.txt file describes the conditions under which this software may be distributed.
9 bool EqualCaseInsensitive(const char *a
, const char *b
);
11 // Define another string class.
12 // While it would be 'better' to use std::string, that doubles the executable size.
14 inline char *StringDup(const char *s
) {
17 char *sNew
= new char[strlen(s
) + 1];
29 SString(const SString
&source
) {
30 s
= StringDup(source
.s
);
32 SString(const char *s_
) {
37 sprintf(number
, "%0d", i
);
38 //itoa(i, number, 10);
39 s
= StringDup(number
);
45 SString
&operator=(const SString
&source
) {
46 if (this != &source
) {
48 s
= StringDup(source
.s
);
52 bool operator==(const SString
&other
) const {
53 if ((s
== 0) && (other
.s
== 0))
55 if ((s
== 0) || (other
.s
== 0))
57 return strcmp(s
, other
.s
) == 0;
59 bool operator==(const char *sother
) const {
60 if ((s
== 0) && (sother
== 0))
62 if ((s
== 0) || (sother
== 0))
64 return strcmp(s
, sother
) == 0;
66 const char *c_str() const {
78 char operator[](int i
) {
84 SString
&operator +=(const char *sother
) {
86 int lenOther
= strlen(sother
);
87 char *sNew
= new char[len
+ lenOther
+ 1];
91 memcpy(sNew
+ len
, sother
, lenOther
);
92 sNew
[len
+ lenOther
] = '\0';
115 void EnsureCanAddEntry();
116 void Set(const char *key
, const char *val
);
117 void Set(char *keyval
);
118 SString
Get(const char *key
);
119 int GetInt(const char *key
, int defaultValue
=0);
120 SString
GetWild(const char *keybase
, const char *filename
);
121 SString
GetNewExpand(const char *keybase
, const char *filename
);
123 void ReadFromMemory(const char *data
, int len
);
124 void Read(const char *filename
);
127 // This is a fixed length list of strings suitable for display in combo boxes
128 // as a memory of user entries
133 void Insert(SString s
) {
134 for (int i
=0;i
<sz
;i
++) {
135 if (entries
[i
] == s
) {
136 for (int j
=i
;j
>0;j
--) {
137 entries
[j
] = entries
[j
-1];
143 for (int k
=sz
-1;k
>0;k
--) {
144 entries
[k
] = entries
[k
-1];
150 for (int i
=0;i
<sz
;i
++)
151 if (entries
[i
].length())
155 SString
At(int n
) const {
162 // Each word contains at least one character - a empty word acts as sentinal at the end.
166 bool onlyLineEnds
; // Delimited by any white space or only line ends
168 WordList(bool onlyLineEnds_
= false) :
169 words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_
) {}
170 ~WordList() { Clear(); }
171 operator bool() { return list
; }
172 const char *operator[](int ind
) { return words
[ind
]; }
174 void Set(const char *s
);
175 char *Allocate(int size
);
176 void SetFromAllocated();
177 bool InList(const char *s
);