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