Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ContentModel.h

Go to the documentation of this file.
00001 /* 
00002  * wsdlpull - A C++ parser  for WSDL  (Web services description language)
00003  * Copyright (C) 2005-2007 Vivek Krishna
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 #ifndef _CONTENTMODELH
00021 #define _CONTENTMODELH
00022 
00023 #include <list>
00024 #include <utility>
00025 #include <xmlpull/Qname.h>
00026 #include <xmlpull/XmlUtils.h>
00027 #include <schemaparser/Schema.h>
00028 #include <schemaparser/SchemaParserException.h>
00029 
00030 class Group;
00031 class Element;
00032 
00033 class ContentModel
00034 {
00035 public:
00036 
00037   typedef union
00038   {
00039     Element* e;
00040     Group * g;
00041     ContentModel *c;
00042   }ContentType;
00043 
00044   typedef enum {
00045     Particle,
00046     ParticleGroup,
00047     Container
00048   } ContentDiscriminator;
00049 
00050   typedef pair<ContentType,ContentDiscriminator> ContentHolder;
00051   typedef list<ContentHolder> Contents;
00052   typedef list<ContentHolder>::iterator ContentsIterator;
00053   
00054   
00055   ContentModel(Schema::Compositor);
00056   ~ContentModel();
00057   Schema::Compositor getCompositor()const;
00058   ContentsIterator begin();
00059   ContentsIterator end();
00060   void addElement(const Element & e);
00061   void addGroup(const Group & e ,bool own=false);
00062   void addContentModel(const ContentModel* c);
00063   void setMin(const int & m);
00064   void setMax(const int & m);
00065   int min()const;
00066   int max()const;
00067   int getNumParticles()const;
00068   bool anyContents()const;
00069   void matchforwardRef(const std::string &name,Element &e);
00070 
00071 private:
00072   Schema::Compositor m_compositor;
00073   Contents contents_;
00074   int minOccurs,maxOccurs;
00075   int nParticles;
00076   bool anyContent_;
00077 };
00078 
00079 inline
00080 Schema::Compositor 
00081 ContentModel::getCompositor()const
00082 {
00083   return m_compositor;
00084 }
00085 
00086 inline 
00087 ContentModel::ContentsIterator
00088 ContentModel::begin()
00089 {
00090   return contents_.begin();
00091 }
00092 
00093 inline
00094 ContentModel::ContentsIterator
00095 ContentModel::end()
00096 {
00097   return contents_.end();
00098 }
00099 
00100 
00101 inline
00102 int
00103 ContentModel::min()const
00104 {
00105   return minOccurs;
00106   
00107 }
00108 
00109 inline
00110 int
00111 ContentModel::max()const
00112 {
00113   return maxOccurs;
00114   
00115 }
00116 
00117 inline
00118 void
00119 ContentModel::setMin(const int & m)
00120 {
00121   minOccurs=m;
00122   
00123 }
00124 
00125 inline
00126 void
00127 ContentModel::setMax(const int & m)
00128 {
00129   maxOccurs=m;
00130   
00131 }
00132 
00133 inline
00134 int
00135 ContentModel::getNumParticles()const
00136 {
00137   return nParticles;
00138 }
00139 
00140 inline
00141 bool
00142 ContentModel::anyContents()const
00143 {
00144   return anyContent_;
00145 }
00146 #endif                                            /*  */

Generated on Sun Oct 16 10:11:52 2005 for wsdlpull by  doxygen 1.3.9.1