summaryrefslogtreecommitdiffstats
path: root/src/triestring.h
blob: baa691198ca996c6a27984a2c8527c3f1f0bb411 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
  This file belong to the KMPlayer project, a movie player plugin for Konqueror
  Copyright (C) 2007  Koos Vriezen <koos.vriezen@gmail.com>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
**/

#ifndef _TRIE_STRING_H_
#define _TRIE_STRING_H_

#include <tqstring.h>

namespace KMPlayer {

class TrieNode;

class KMPLAYER_EXPORT TrieString {
    TrieNode * node;
    friend bool operator == (const TrieString & s1, const TrieString & s2);
    friend bool operator == (const TrieString & s, const char * utf8);
    friend bool operator == (const char * utf8, const TrieString & s);
    friend bool operator != (const TrieString & s1, const TrieString & s2);
public:
    TrieString ();
    TrieString (const TQString & s);
    TrieString (const char * utf8);
    TrieString (const TrieString & s);
    ~TrieString ();

    TQString toString () const;
    bool isNull () const;
    void clear ();
    bool startsWith (const TrieString & s) const;
    bool startsWith (const char * str) const;
    TrieString & operator = (const TrieString & s);
    TrieString & operator = (const char * utf8);
    bool operator < (const TrieString & s) const;
};

inline TrieString::TrieString () : node (0L) {}

class KMPLAYER_EXPORT StringPool {
public:
    static void init();
    static void reset();

    static TrieString attr_id;
    static TrieString attr_name;
    static TrieString attr_src;
    static TrieString attr_url;
    static TrieString attr_href;
    static TrieString attr_width;
    static TrieString attr_height;
    static TrieString attr_top;
    static TrieString attr_left;
    static TrieString attr_bottom;
    static TrieString attr_right;
    static TrieString attr_title;
    static TrieString attr_begin;
    static TrieString attr_dur;
    static TrieString attr_end;
    static TrieString attr_region;
    static TrieString attr_target;
    static TrieString attr_type;
    static TrieString attr_value;
    static TrieString attr_fill;
};

inline bool TrieString::isNull () const {
    return !node;
}

inline bool operator == (const TrieString & s1, const TrieString & s2) {
    return s1.node == s2.node;
}

bool operator == (const TrieString & s, const char * utf8);

inline bool operator == (const char * utf8, const TrieString & s) {
    return s == utf8;
}

inline bool operator != (const TrieString & s1, const TrieString & s2) {
    return s1.node != s2.node;
}

void dumpTrie ();

} // namespace

#endif // _TRIE_STRING_H_