#include <TypeBase.h>
Public Member Functions | |
TypeBase (const Wsdl &wsdl, const Xml::XmlNode &node, const std::string &ns_prefix, const std::string &type) | |
~TypeBase () | |
const std::string & | Type () const |
const std::string | Documentation (const Xml::XmlNode &) const |
const std::string | CType () const |
const std::string & | NsHref () const |
void | SetType (const std::string &x) |
bool | IsBuiltin () const |
bool | IsNumeric () const |
Protected Attributes | |
const Wsdl & | m_wsdl |
const Xml::XmlNode & | m_node |
std::string | m_ns_href |
std::string | m_type |
bool | m_b_is_numeric |
Definition at line 31 of file TypeBase.h.
TypeBase::TypeBase | ( | const Wsdl & | wsdl, | |
const Xml::XmlNode & | node, | |||
const std::string & | ns_prefix, | |||
const std::string & | type | |||
) |
Definition at line 31 of file TypeBase.cpp.
References SetType().
00031 : m_wsdl(wsdl) 00032 , m_node(node) 00033 , m_ns_href( ns_prefix ) 00034 , m_type(type) 00035 , m_b_is_numeric(false) 00036 { 00037 if (!type.empty()) 00038 { 00039 SetType( type ); 00040 } 00041 }
TypeBase::~TypeBase | ( | ) |
const std::string& TypeBase::Type | ( | ) | const [inline] |
Definition at line 37 of file TypeBase.h.
References m_type.
Referenced by Attribute::Attribute(), ComplexType::ComplexType(), Element::CType_decl(), Attribute::CType_decl(), Element::CType_in(), Attribute::CType_in(), Element::CType_out(), Attribute::CType_out(), Element::Element(), and ComplexType::OkToGenerate().
00037 { return m_type; }
const std::string TypeBase::Documentation | ( | const Xml::XmlNode & | node | ) | const |
Definition at line 49 of file TypeBase.cpp.
Referenced by SimpleType::Documentation(), ComplexType::Documentation(), Attribute::Documentation(), and SimpleType::SimpleType().
00050 { 00051 Xml::XmlNode n(node, "annotation"); 00052 if (n) 00053 { 00054 Xml::XmlNode n2(n, "documentation"); 00055 if (n2) 00056 { 00057 return n2.GetContent(); 00058 } 00059 } 00060 return ""; 00061 }
const std::string TypeBase::CType | ( | ) | const |
Reimplemented in Attribute, and SimpleType.
Definition at line 64 of file TypeBase.cpp.
References Wsdl::GetNamespace(), Wsdl::GetParent(), IsBuiltin(), m_ns_href, m_type, and m_wsdl.
Referenced by Attribute::Attribute(), ComplexType::CreateInterface(), SimpleType::CType(), Attribute::CType(), Element::CType_decl(), Attribute::CType_decl(), Element::CType_in(), Attribute::CType_in(), Element::CType_out(), Attribute::CType_out(), Element::Element(), ComplexType::from_xml(), SetType(), and ComplexType::to_string().
00065 { 00066 std::string t; 00067 if (IsBuiltin()) 00068 { 00069 t = Split(m_type).CName; 00070 if (t == "string" || t == "date" || t == "dateTime" || 00071 t == "anySimpleType" || t == "anyURI" || 00072 t == "time" 00073 ) 00074 { 00075 t = "std::string"; 00076 } 00077 if (t == "boolean") 00078 t = "bool"; 00079 if (t == "byte") 00080 t = "char"; 00081 if (t == "decimal") 00082 t = "double"; 00083 if (t == "integer") 00084 t = "int"; 00085 if (t == "unsignedByte") 00086 t = "unsigned char"; 00087 if (t == "unsignedInt") 00088 t = "unsigned int"; 00089 if (t == "unsignedShort") 00090 t = "unsigned short"; 00091 } 00092 else 00093 { 00094 std::string parent = m_wsdl.GetParent(m_ns_href, m_type); 00095 std::string tmp; 00096 while (!parent.empty()) 00097 { 00098 tmp = Split(parent).CName1up + "::" + tmp; 00099 parent = m_wsdl.GetParent(m_ns_href, parent); 00100 } 00101 if (m_wsdl.GetNamespace(m_ns_href).empty()) 00102 t = tmp + Split(m_type).CName1up; 00103 else 00104 t = m_wsdl.GetNamespace(m_ns_href) + "::" + tmp + Split(m_type).CName1up; 00105 } 00106 return t; 00107 }
const std::string& TypeBase::NsHref | ( | ) | const [inline] |
Definition at line 41 of file TypeBase.h.
References m_ns_href.
Referenced by ComplexType::CreateImplementation(), ComplexType::CreateInterface(), ComplexType::from_xml(), ComplexType::OkToGenerate(), ComplexType::reset_members(), and ComplexType::to_string().
00041 { return m_ns_href; }
void TypeBase::SetType | ( | const std::string & | x | ) |
Definition at line 110 of file TypeBase.cpp.
References CType(), DEB, Wsdl::GetTargetNamespace(), m_b_is_numeric, m_node, m_ns_href, m_type, and m_wsdl.
Referenced by Attribute::Attribute(), ComplexType::ComplexType(), Element::Element(), SimpleType::SimpleType(), and TypeBase().
00111 { 00112 std::string href = m_node.GetNsMap()[Split(x).NS]; 00113 if (Split(x).NS.empty()) 00114 { 00115 href = m_wsdl.GetTargetNamespace(); 00116 Xml::XmlNode n(m_node); 00117 std::string alt = n.FindProperty("targetNamespace", true); 00118 if (!alt.empty() && alt != href) 00119 { 00120 href = alt; 00121 } 00122 } 00123 if (href.empty()) 00124 { 00125 std::map<std::string, std::string> mmap = m_node.GetNsMap(); 00126 DEB( for (std::map<std::string, std::string>::iterator it = mmap.begin(); it != mmap.end(); it++) 00127 { 00128 printf("prefix '%s' namespace '%s'\n", it -> first.c_str(), it -> second.c_str()); 00129 }) 00130 throw WsdlException("Empty href, type = \"" + x + "\""); 00131 } 00132 m_ns_href = href; 00133 m_type = Split(x).Type; 00134 std::string ctype = CType(); 00135 if (ctype.find("int") != std::string::npos || 00136 ctype.find("short") != std::string::npos || 00137 ctype.find("double") != std::string::npos) 00138 { 00139 m_b_is_numeric = true; 00140 } 00141 }
bool TypeBase::IsBuiltin | ( | ) | const |
Definition at line 144 of file TypeBase.cpp.
References m_ns_href.
Referenced by CType(), Element::CType_in(), Attribute::CType_in(), Element::CType_out(), Attribute::CType_out(), Element::DefaultValue(), Element::IsComplexType(), Element::IsSimpleType(), Attribute::IsSimpleType(), and ComplexType::reset_members().
00145 { 00146 return m_ns_href == "http://www.w3.org/2001/XMLSchema"; 00147 }
bool TypeBase::IsNumeric | ( | ) | const [inline] |
Definition at line 46 of file TypeBase.h.
References m_b_is_numeric.
Referenced by Attribute::DefaultValue(), and ComplexType::reset_members().
00046 { return m_b_is_numeric; }
const Wsdl& TypeBase::m_wsdl [protected] |
Definition at line 49 of file TypeBase.h.
Referenced by Attribute::Attribute(), ComplexType::ComplexType(), ComplexType::CreateImplementation(), ComplexType::CreateInterface(), CType(), Element::CType_decl(), Attribute::CType_decl(), Element::CType_in(), Attribute::CType_in(), Element::CType_out(), Attribute::CType_out(), Element::Element(), ComplexType::from_xml(), Element::IsComplexType(), Element::IsSimpleType(), Attribute::IsSimpleType(), ComplexType::OkToGenerate(), ComplexType::reset_members(), SetType(), and ComplexType::to_string().
const Xml::XmlNode& TypeBase::m_node [protected] |
Definition at line 50 of file TypeBase.h.
Referenced by ComplexType::ComplexType(), SimpleType::Documentation(), Element::Documentation(), ComplexType::Documentation(), Attribute::Documentation(), SetType(), and ComplexType::Start().
std::string TypeBase::m_ns_href [protected] |
Definition at line 51 of file TypeBase.h.
Referenced by Attribute::Attribute(), ComplexType::CreateInterface(), CType(), Element::CType_decl(), Attribute::CType_decl(), Element::CType_in(), Attribute::CType_in(), Element::CType_out(), Attribute::CType_out(), Element::Element(), IsBuiltin(), Element::IsComplexType(), Element::IsSimpleType(), Attribute::IsSimpleType(), NsHref(), ComplexType::OkToGenerate(), and SetType().
std::string TypeBase::m_type [protected] |
Definition at line 52 of file TypeBase.h.
Referenced by Attribute::Attribute(), CType(), Element::CType_decl(), Attribute::CType_decl(), Element::CType_in(), Attribute::CType_in(), Element::CType_out(), Attribute::CType_out(), Element::DefaultValue(), Element::Element(), Element::IsComplexType(), Element::IsSimpleType(), Attribute::IsSimpleType(), SetType(), and Type().
bool TypeBase::m_b_is_numeric [protected] |