00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00042
00043
00044
00045 bool isSimple() const;
00046
00047
00048 int getContentType() const;
00049
00050
00051 int getNumAttributes() const;
00052
00053
00054 int getAttributeType(int index);
00055
00056
00057 std::string getAttributeName(int index)const;
00058
00059
00060 ContentModel* getContents()const;
00061
00062
00063 const Attribute *getAttribute(const std::string & name)const;
00064
00065 const Attribute *getAttribute(int index)const;
00066
00067 std::list < Attribute > & pAttributeList() ;
00068
00069
00070
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
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_;
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