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 namespace Schema {
00031 
00032 class Group;
00033 class Element;
00034 
00035 class ContentModel
00036 {
00037 public:
00038 
00039   typedef union
00040   {
00041     Element* e;
00042     Group * g;
00043     ContentModel *c;
00044   }ContentType;
00045 
00046   typedef enum {
00047     Particle,
00048     ParticleGroup,
00049     Container
00050   } ContentDiscriminator;
00051 
00052   typedef std::pair<ContentType,ContentDiscriminator> ContentHolder;
00053   typedef std::list<ContentHolder> Contents;
00054   typedef std::list<ContentHolder>::iterator ContentsIterator;
00055   
00056   
00057   ContentModel(Schema::Compositor);
00058   ~ContentModel();
00059   Schema::Compositor getCompositor()const;
00060   ContentsIterator begin();
00061   ContentsIterator end();
00062   void addElement(const Element & e);
00063   void addGroup(const Group & e ,bool own=false);
00064   void addContentModel(const ContentModel* c);
00065   void setMin(const int & m);
00066   void setMax(const int & m);
00067   int getMin()const;
00068   int getMax()const;
00069   int getNumParticles()const;
00070   bool anyContents()const;
00071   void matchforwardRef(const std::string &name,Element &e);
00072 
00073 private:
00074   Schema::Compositor m_compositor;
00075   Contents contents_;
00076   int minOccurs,maxOccurs;
00077   int nParticles;
00078   bool anyContent_;
00079 };
00080 
00081 inline
00082 Schema::Compositor 
00083 ContentModel::getCompositor()const
00084 {
00085   return m_compositor;
00086 }
00087 
00088 inline 
00089 ContentModel::ContentsIterator
00090 ContentModel::begin()
00091 {
00092   return contents_.begin();
00093 }
00094 
00095 inline
00096 ContentModel::ContentsIterator
00097 ContentModel::end()
00098 {
00099   return contents_.end();
00100 }
00101 
00102 
00103 inline
00104 int
00105 ContentModel::getMin()const
00106 {
00107   return minOccurs;
00108   
00109 }
00110 
00111 inline
00112 int
00113 ContentModel::getMax()const
00114 {
00115   return maxOccurs;
00116   
00117 }
00118 
00119 inline
00120 void
00121 ContentModel::setMin(const int & m)
00122 {
00123   minOccurs=m;
00124   
00125 }
00126 
00127 inline
00128 void
00129 ContentModel::setMax(const int & m)
00130 {
00131   maxOccurs=m;
00132   
00133 }
00134 
00135 inline
00136 int
00137 ContentModel::getNumParticles()const
00138 {
00139   return nParticles;
00140 }
00141 
00142 inline
00143 bool
00144 ContentModel::anyContents()const
00145 {
00146   return anyContent_;
00147 }
00148 }
00149 #endif                                            /*  */

Generated on Mon Feb 6 23:02:42 2006 for wsdlpull by  doxygen 1.3.9.1