ubit
uxmlgrammar.hpp
1 /* ==================================================== ======== ======= *
2  *
3  * uxmlgrammar.hpp
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uxmlgrammar_hpp_
18 #define _uxmlgrammar_hpp_ 1
19 #include <map>
20 #include <vector>
21 #include <ubit/udom.hpp>
22 namespace ubit {
23 
24 
27  class UXmlGrammar {
28  public:
29  UXmlGrammar();
30  virtual ~UXmlGrammar();
31 
32  virtual void addAttrClass(const UClass&);
33  virtual void addElementClass(const UClass&);
34  virtual void addCharEntityRef(const UStr& entity_name, unsigned short entity_value);
35 
36  virtual const UClass* getAttrClass(const UStr& classname) const;
37  virtual const UClass* getElementClass(const UStr& classname) const;
38  virtual unsigned short getCharEntityRef(const UStr& entity_name) const;
39 
41  static UClass* addUndefAttrClass(const UStr& classname);
42  static UClass* addUndefElementClass(const UStr& classname);
43  virtual void createDefaultCharEntityRefs();
44 
45  protected:
46  struct Comp {
47  bool operator()(const UStr*a,const UStr*b) const {return a->compare(*b)<0;}
48  };
49  typedef std::map<const UStr*, unsigned short, Comp> CharEntityRefMap;
50 
51  CharEntityRefMap char_entity_refs;
52  UElemClassMap element_classes;
53  UAttrClassMap attr_classes;
54  };
55 
56  /* ==================================================== ===== ======= */
59  class UXmlGrammars {
60  public:
61  void addGrammar(const UXmlGrammar&);
62  void addGrammars(const UXmlGrammars&);
63 
64  const UClass* getAttrClass(const UStr& classname) const;
65  const UClass* getElementClass(const UStr& classname) const;
66  unsigned short getCharEntityRef(const UStr& entityname) const;
67 
68  protected:
69  typedef std::vector<const UXmlGrammar*> GrammarList;
70  GrammarList glist;
71  };
72 
73 
74 }
75 #endif
76 /* ==================================================== [TheEnd] ======= */
77 /* ==================================================== [(c)Elc] ======= */
78 
Definition: uxmlgrammar.hpp:46
virtual void createDefaultCharEntityRefs()
TO BE CHANGED !!!
Definition: uxmlgrammar.cpp:122
Definition: uclassImpl.hpp:132
static UClass * addUndefAttrClass(const UStr &classname)
TO BE CHANGED !!!
Definition: uxmlgrammar.cpp:104
Definition: uclassImpl.hpp:108
static UXmlGrammar & getSharedUndefGrammar()
TO BE CHANGED !!!
Definition: uxmlgrammar.cpp:93
XML Grammar.
Definition: uxmlgrammar.hpp:27
Ubit class.
Definition: uclass.hpp:74
static UClass * addUndefElementClass(const UStr &classname)
TO BE CHANGED !!!
Definition: uxmlgrammar.cpp:98
Definition: uhardfont.hpp:31
List of XML Grammars.
Definition: uxmlgrammar.hpp:59
virtual int compare(const char *, bool ignore_case=false) const
compare strings lexicographically, ignores case if last argument is true.
Ubit String.
Definition: ustr.hpp:72