TypeBase Class Reference

#include <TypeBase.h>

Inheritance diagram for TypeBase:

Inheritance graph
[legend]
Collaboration diagram for TypeBase:

Collaboration graph
[legend]

List of all members.

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 Wsdlm_wsdl
const Xml::XmlNode & m_node
std::string m_ns_href
std::string m_type
bool m_b_is_numeric


Detailed Description

Definition at line 31 of file TypeBase.h.


Constructor & Destructor Documentation

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 (  ) 

Definition at line 44 of file TypeBase.cpp.

00045 {
00046 }


Member Function Documentation

const std::string& TypeBase::Type (  )  const [inline]

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]

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

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; }


Member Data Documentation

const Wsdl& TypeBase::m_wsdl [protected]

const Xml::XmlNode& TypeBase::m_node [protected]

std::string TypeBase::m_ns_href [protected]

std::string TypeBase::m_type [protected]

bool TypeBase::m_b_is_numeric [protected]

Definition at line 53 of file TypeBase.h.

Referenced by IsNumeric(), and SetType().


The documentation for this class was generated from the following files:

Generated on Sun Oct 11 10:57:20 2009 for Xml Schema class generator by  doxygen 1.5.5