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

Generated by  doxygen 1.6.2