~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to scintilla/include/PropSet.h

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-08-07 03:23:12 UTC
  • mfrom: (1.4.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20100807032312-ot70ac9d50cn79we
Tags: upstream-0.19
ImportĀ upstreamĀ versionĀ 0.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Scintilla source code edit control
2
2
/** @file PropSet.h
3
 
 ** A Java style properties file module.
 
3
 ** An interface to the methods needed for access to property sets inside lexers.
4
4
 **/
5
 
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
 
5
// Copyright 1998-2009 by Neil Hodgson <neilh@scintilla.org>
6
6
// The License.txt file describes the conditions under which this software may be distributed.
7
7
 
8
8
#ifndef PROPSET_H
9
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
10
 
16
11
#ifdef SCI_NAMESPACE
17
12
namespace Scintilla {
18
13
#endif
19
14
 
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
 
}
 
15
class PropertyGet {
 
16
public:
 
17
        virtual char *ToString() const=0;       // Caller must delete[] the return value
 
18
        virtual int GetInt(const char *key, int defaultValue=0) const=0;
 
19
        virtual ~PropertyGet() {}
 
20
};
93
21
 
94
22
#ifdef SCI_NAMESPACE
95
23
}
96
24
#endif
97
25
 
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
26
#endif