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
00033 class TypesTable
00034 {
00035 public:
00036
00037 TypesTable();
00038 ~TypesTable();
00039
00040
00041 void clean();
00042
00043
00044 int addType(XSDType * type);
00045 int addExtType(XSDType * type, int id);
00046
00047
00048 int getTypeId(const Qname & name, bool create = false);
00049 std::string getAtomicTypeName(Schema::Type t)const;
00050
00051
00052 int addExternalTypeId(const Qname & type, XSDType * pType);
00053 int getNumExtRefs()
00054 {
00055 return extRefs_.size();
00056 }
00057 Qname & getExtRefName(int index)
00058 {
00059 return extRefs_[index].qname;
00060 }
00061 int getExtRefType(int index)
00062 {
00063 return extRefs_[index].localTypeId;
00064 }
00065 void resolveForwardElementRefs(const string & name, Element & e);
00066 void resolveForwardAttributeRefs(const string & name, Attribute & a);
00067
00068
00069 int getCompleteXpath(int elemId, string & childName, int *xPath,
00070 int limits, int &offset);
00071
00072
00073 XSDType *getTypePtr(int id) const
00074 {
00075
00076
00077 if (id < Schema::ANYURI + 1 || id > Schema::ANYURI + numTypes)
00078 return 0;
00079 return typesArray[id - (Schema::ANYURI + 1)];
00080 }
00081 int getNumTypes(void) const
00082 {
00083 return numTypes;
00084 } bool detectUndefinedTypes(void);
00085 void setTargetNamespace(string Uri)
00086 {
00087 m_tnsUri = Uri;
00088 }
00089 string getTargetNamespace(void)
00090 {
00091 return m_tnsUri;
00092 }
00093 void printUndefinedTypes(ostream & out);
00094
00095 #ifdef LOGGING
00096
00097 void printTypes(ostream & out);
00098 #endif
00099 private:
00100
00101 XSDType ** typesArray;
00102
00103
00104 map < string, int >Id;
00105
00106
00107 map < string, int >basicTypes;
00108 int currentId;
00109 int numTypes, nSize;
00110 string m_tnsUri;
00111
00112 typedef struct
00113 {
00114 int localTypeId;
00115 Qname qname;
00116 }extRefs;
00117 std::vector<extRefs> extRefs_;
00118 void ensureCapacity();
00119 };
00120 #endif