00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TYPESTABLEH
00022 #define _TYPESTABLEH
00023
00024 #include <string>
00025 #include <vector>
00026 #include <map>
00027 #include <sstream>
00028 #include "xmlpull/XmlUtils.h"
00029 #include "schemaparser/SimpleType.h"
00030 #include "schemaparser/ComplexType.h"
00031
00032 namespace Schema {
00033
00034 class TypesTable
00035 {
00036 public:
00037
00038 TypesTable();
00039 ~TypesTable();
00040
00041
00042 void clean();
00043
00044
00045 int addType(XSDType * type);
00046 int addExtType(XSDType * type, int id);
00047
00048
00049 int getTypeId(const Qname & name, bool create = false);
00050 std::string getAtomicTypeName(Schema::Type t)const;
00051
00052
00053 int addExternalTypeId(const Qname & type, XSDType * pType);
00054 int getNumExtRefs()
00055 {
00056 return extRefs_.size();
00057 }
00058 Qname & getExtRefName(int index)
00059 {
00060 return extRefs_[index].qname;
00061 }
00062 int getExtRefType(int index)
00063 {
00064 return extRefs_[index].localTypeId;
00065 }
00066 void resolveForwardElementRefs(const std::string & name, Element & e);
00067 void resolveForwardAttributeRefs(const std::string & name, Attribute & a);
00068
00069
00070 int getCompleteXpath(int elemId, std::string & childName, int *xPath,
00071 int limits, int &offset);
00072
00073
00074 XSDType *getTypePtr(int id) const
00075 {
00076
00077
00078 if (id < Schema::XSD_ANYURI + 1 || id > Schema::XSD_ANYURI + numTypes)
00079 return 0;
00080 return typesArray[id - (Schema::XSD_ANYURI + 1)];
00081 }
00082 int getNumTypes(void) const
00083 {
00084 return numTypes;
00085 } bool detectUndefinedTypes(void);
00086 void setTargetNamespace(std::string Uri)
00087 {
00088 m_tnsUri = Uri;
00089 }
00090 std::string getTargetNamespace(void)
00091 {
00092 return m_tnsUri;
00093 }
00094 void printUndefinedTypes(std::ostream & out);
00095
00096 #ifdef LOGGING
00097
00098 void printTypes(std::ostream & out);
00099 #endif
00100 private:
00101
00102 XSDType ** typesArray;
00103
00104
00105 std::map < std::string, int >Id;
00106
00107
00108 std::map < std::string, int >basicTypes;
00109 int currentId;
00110 int numTypes, nSize;
00111 std::string m_tnsUri;
00112
00113 typedef struct
00114 {
00115 int localTypeId;
00116 Qname qname;
00117 }extRefs;
00118 std::vector<extRefs> extRefs_;
00119 void ensureCapacity();
00120 };
00121 }
00122 #endif