File indexing completed on 2024-04-21 15:38:28

0001 /**
0002   This file belong to the KMPlayer project, a movie player plugin for Konqueror
0003   Copyright (C) 2007  Koos Vriezen <koos.vriezen@gmail.com>
0004 
0005   This library is free software; you can redistribute it and/or
0006   modify it under the terms of the GNU Lesser General Public
0007   License as published by the Free Software Foundation; either
0008   version 2 of the License, or (at your option) any later version.
0009 
0010   This library is distributed in the hope that it will be useful,
0011   but WITHOUT ANY WARRANTY; without even the implied warranty of
0012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013   Lesser General Public License for more details.
0014 
0015   You should have received a copy of the GNU Lesser General Public
0016   License along with this library; if not, write to the Free Software
0017   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018 **/
0019 
0020 #ifndef _TRIE_STRING_H_
0021 #define _TRIE_STRING_H_
0022 
0023 #include <qstring.h>
0024 
0025 namespace KMPlayer {
0026 
0027 class TrieNode;
0028 
0029 class KMPLAYER_EXPORT TrieString {
0030     TrieNode * node;
0031     friend bool operator == (const TrieString & s1, const TrieString & s2);
0032     friend bool operator == (const TrieString & s, const char * utf8);
0033     friend bool operator == (const char * utf8, const TrieString & s);
0034     friend bool operator != (const TrieString & s1, const TrieString & s2);
0035 public:
0036     TrieString ();
0037     TrieString (const QString & s);
0038     TrieString (const char * utf8);
0039     TrieString (const char *utf8, int length);
0040     TrieString (const TrieString & s);
0041     ~TrieString ();
0042 
0043     QString toString () const;
0044     bool isNull () const;
0045     void clear ();
0046     bool startsWith (const TrieString & s) const;
0047     bool startsWith (const char * str) const;
0048     TrieString & operator = (const TrieString & s);
0049     TrieString & operator = (const char * utf8);
0050     bool operator < (const TrieString & s) const;
0051 };
0052 
0053 inline TrieString::TrieString () : node (0L) {}
0054 
0055 class KMPLAYER_EXPORT Ids {
0056 public:
0057     static void init();
0058     static void reset();
0059 
0060     static TrieString attr_id;
0061     static TrieString attr_name;
0062     static TrieString attr_src;
0063     static TrieString attr_url;
0064     static TrieString attr_href;
0065     static TrieString attr_width;
0066     static TrieString attr_height;
0067     static TrieString attr_top;
0068     static TrieString attr_left;
0069     static TrieString attr_bottom;
0070     static TrieString attr_right;
0071     static TrieString attr_title;
0072     static TrieString attr_begin;
0073     static TrieString attr_dur;
0074     static TrieString attr_end;
0075     static TrieString attr_region;
0076     static TrieString attr_target;
0077     static TrieString attr_type;
0078     static TrieString attr_value;
0079     static TrieString attr_fill;
0080     static TrieString attr_fit;
0081 };
0082 
0083 inline bool TrieString::isNull () const {
0084     return !node;
0085 }
0086 
0087 inline bool operator == (const TrieString & s1, const TrieString & s2) {
0088     return s1.node == s2.node;
0089 }
0090 
0091 bool operator == (const TrieString & s, const char * utf8);
0092 
0093 inline bool operator == (const char * utf8, const TrieString & s) {
0094     return s == utf8;
0095 }
0096 
0097 inline bool operator != (const TrieString & s1, const TrieString & s2) {
0098     return s1.node != s2.node;
0099 }
0100 
0101 void dumpTrie ();
0102 
0103 } // namespace
0104 
0105 #endif // _TRIE_STRING_H_