uxmlgrammar.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  uxmlgrammar.hpp
00004 *  Ubit Project
00005 *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006 *  (C) 1999-2006 Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007 *
00008 * ***********************************************************************
00009 * COPYRIGHT NOTICE :
00010 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
00011 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00012 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
00013 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
00014 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016 * ***********************************************************************
00017 * ==================================================== [(c)Elc] ======= *
00018 * ==================================================== ======== ======= */
00019 
00020 #ifndef _uxmlgrammar_hpp_
00021 #define _uxmlgrammar_hpp_
00022 //pragma ident  "@(#)uxmlgrammar.hpp    ubit:05.05.00"
00023 #include <map>
00024 #include <vector>
00025 #include <ubit/udom.hpp>
00026 namespace ubit {
00027 
00028 /* ==================================================== ===== ======= */
00031 class UXmlGrammar {
00032 public:
00033   UXmlGrammar();
00034   virtual ~UXmlGrammar();
00035 
00036   virtual void addAttrClass(const UAttributeClass&);
00037   virtual void addElementClass(const UElementClass&);
00038   virtual void addCharEntityRef(const UStr& entity_name, unsigned short entity_value);
00039 
00040   virtual const UAttributeClass* getAttrClass(const UStr& classname) const;
00041   virtual const UElementClass* getElementClass(const UStr& classname) const;
00042   virtual unsigned short getCharEntityRef(const UStr& entity_name) const;
00043 
00044   static UXmlGrammar& getSharedUndefGrammar();  
00045   static UAttributeClass* addUndefAttrClass(const UStr& classname); 
00046   static UElementClass* addUndefElementClass(const UStr& classname); 
00047   virtual void createDefaultCharEntityRefs(); 
00048 
00049 protected:
00050   struct Comp {
00051     bool operator()(const UStr*a,const UStr*b) const {return a->compare(*b)<0;}
00052   };
00053   typedef std::map<const UStr*, unsigned short, Comp> CharEntityRefMap;
00054   
00055   CharEntityRefMap char_entity_refs;
00056   UElementClassMap element_classes;
00057   UAttributeClassMap attr_classes;
00058 };
00059 
00060 /* ==================================================== ===== ======= */
00063 class UXmlGrammars {
00064 public:  
00065   void addGrammar(const UXmlGrammar&);
00066   void addGrammars(const UXmlGrammars&);
00067   
00068   const UAttributeClass* getAttrClass(const UStr& classname) const;
00069   const UElementClass* getElementClass(const UStr& classname) const;
00070   unsigned short getCharEntityRef(const UStr& entityname) const;
00071   
00072 protected:
00073   typedef std::vector<const UXmlGrammar*> GrammarList;
00074   GrammarList glist;
00075 };
00076 
00077 
00078 }
00079 #endif
00080 /* ==================================================== [TheEnd] ======= */
00081 /* ==================================================== [(c)Elc] ======= */
00082 

Generated on Mon Jan 29 00:20:41 2007 for Ubit by  doxygen 1.4.7