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

ComplexType.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 _COMPLEXTYPEH
00021 #define _COMPLEXTYPEH
00022 
00023 #include <list>
00024 #include "xmlpull/Qname.h"
00025 #include "xmlpull/XmlUtils.h"
00026 #include "schemaparser/XSDType.h"
00027 #include "schemaparser/ContentModel.h"
00028 #include "schemaparser/Attribute.h"
00029 #include "schemaparser/SchemaParserException.h"
00030 
00031 namespace Schema {
00032 
00033 class ComplexType:public XSDType
00034 {
00035  public:
00036        
00037   ComplexType(const std::string& );
00038   ~ComplexType();
00039 
00040   /*
00041    * Various getter methods
00042    */
00043 
00044   //virtual function ,always return false for complex types
00045   bool isSimple() const;
00046 
00047   //returns the content type for complex types whose content model is SIMPLE
00048   int getContentType() const;
00049 
00050   //returns the number of attributes ,indices start from 0 to n-1
00051   int getNumAttributes() const;
00052   
00053   //gets the id of the attribute at the position "index"
00054   int getAttributeType(int index);
00055   
00056   //gets the NCName of the attribute
00057   std::string getAttributeName(int index)const;
00058   
00059   //returns the content model structure
00060   ContentModel*  getContents()const;
00061   
00062   //returns a pointer to the attribute
00063   const Attribute *getAttribute(const std::string & name)const;
00064 
00065   const Attribute *getAttribute(int index)const;
00066   //returns the list of  attributes
00067   std::list < Attribute > & pAttributeList() ;
00068   
00069   /*
00070    * Various setter methods
00071    */
00072 
00073   void setSimpleContentType(int id);
00074 
00075   void setContents(ContentModel* ct);
00076   
00077   void addAttribute(const Attribute &a,
00078                     bool fwdRef=false);
00079    //forward reference to attributeGroup
00080    void addAttributeGroupName(const Qname & qn);
00081 
00082   void matchAttributeRef(const std::string & name, Attribute & a);
00083   void matchElementRef(const std::string & name, Element & e);
00084   bool checkOccurrences(void);
00085   void resetCounters(void);
00086 
00087 
00088 #ifdef LOGGING
00089   void print(std::ostream & out);
00090 #endif
00091 
00092  private:
00093   std::list < Attribute > attList_;
00094   int simpleContentTypeId_;                            //for simple content
00095   ContentModel* cm_;
00096   void error(std::string msg) const;
00097   bool fwdElemRef_, fwdAttrRef_;
00098 };
00099 
00100 
00101 inline
00102 int 
00103 ComplexType::getContentType() const
00104 {
00105   return simpleContentTypeId_;
00106 }
00107 
00108 inline
00109 bool 
00110 ComplexType::isSimple() const
00111 {
00112   return false;
00113 }
00114 
00115 inline
00116 int 
00117 ComplexType::getNumAttributes() const
00118 {
00119   return attList_.size();
00120 }
00121 
00122 inline
00123 int
00124 ComplexType::getAttributeType(int index)
00125 {
00126   return getAttribute(index)->getType();
00127 }
00128 
00129 inline
00130 std::string 
00131 ComplexType::getAttributeName(int index)const
00132 {
00133   return getAttribute(index)->getName();
00134 }
00135 
00136 inline
00137 std::list < Attribute > & 
00138 ComplexType::pAttributeList() 
00139 {
00140   return attList_;
00141 }
00142 
00143 
00144 inline
00145 void 
00146 ComplexType::setSimpleContentType(int id)
00147 {
00148   simpleContentTypeId_ = id;
00149 }
00150 
00151 
00152 inline
00153 ContentModel*  
00154 ComplexType::getContents()const
00155 {
00156   return cm_;
00157   
00158 }
00159 
00160 inline
00161 void 
00162 ComplexType::setContents(ContentModel* ct)
00163 {
00164   cm_=ct;
00165 }
00166 
00167 
00168 inline
00169 ComplexType::~ComplexType()
00170 {
00171   if(cm_)
00172     delete cm_;
00173 }
00174 }
00175 #endif                                            /*  */

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