Element Class Reference

#include <Element.h>

Inheritance diagram for Element:

Inheritance graph
[legend]
Collaboration diagram for Element:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Element (const Wsdl &wsdl, const Xml::XmlNode &node, bool in_sequence, bool in_choice, const std::string &name="", const std::string &ns_prefix="")
 ~Element ()
const std::string & Name () const
const std::string & BaseType () const
const std::string Documentation () const
void CreateInterface (FILE *fil) const
bool IsOptional () const
bool IsVector () const
const std::string CName () const
const std::string CName1up () const
const std::string CType_decl () const
const std::string CType_in () const
const std::string CType_out () const
const std::string DefaultValue () const
bool IsComplexType () const
bool IsSimpleType () const

Private Attributes

Applicationm_appl
std::string m_name
std::string m_base_type
int m_minOccurs
int m_maxOccurs


Detailed Description

Definition at line 33 of file Element.h.


Constructor & Destructor Documentation

Element::Element ( const Wsdl wsdl,
const Xml::XmlNode &  node,
bool  in_sequence,
bool  in_choice,
const std::string &  name = "",
const std::string &  ns_prefix = "" 
)

Definition at line 32 of file Element.cpp.

References SimpleType::CType(), TypeBase::CType(), Wsdl::FindSimpleType(), Wsdl::GetElement(), IsSimpleType(), m_base_type, m_maxOccurs, m_name, TypeBase::m_ns_href, TypeBase::m_type, TypeBase::m_wsdl, TypeBase::SetType(), and TypeBase::Type().

00033 : TypeBase(wsdl, node, ns_prefix, "")
00034 , m_appl(wsdl.GetApplication())
00035 , m_name(!name.empty() ? name : node.PropertyExists("name") ? node.GetProperty("name") : "")
00036 , m_minOccurs(node.PropertyExists("minOccurs") ? atoi(node.GetProperty("minOccurs").c_str()) : 1)
00037 , m_maxOccurs(1)
00038 {
00039         if (node.PropertyExists("type"))
00040         {
00041                 std::string type = node.GetProperty("type");
00042                 SetType(type);
00043         }
00044         else
00045         if (node.PropertyExists("ref"))
00046         {
00047                 m_name = node.GetProperty("ref");
00048                 Xml::XmlNode n = wsdl.GetElement( m_name );
00049                 if (n)
00050                 {
00051                         if (n.PropertyExists("type"))
00052                         {
00053                                 std::string type = n.GetProperty("type");
00054                                 SetType(type);
00055                         }
00056                 }
00057         }
00058         else
00059         {
00060                 Xml::XmlNode n(node, "complexType");
00061                 if (n)
00062                 {
00063                         std::string prefix = node.GetNsMapRe()[ns_prefix];
00064                         std::string type = prefix + ":" + m_name + "_t";
00065                         SetType(type);
00066                 }
00067         }
00068         if (node.PropertyExists("maxOccurs"))
00069         {
00070                 std::string max = node.GetProperty("maxOccurs");
00071                 if (max == "unbounded")
00072                 {
00073                         if (!in_sequence)
00074                                 throw WsdlException("Using 'unbounded' on maxOccurs outside sequence");
00075                         m_maxOccurs = -1;
00076                 }
00077                 else
00078                         m_maxOccurs = atoi(max.c_str());
00079         }
00080         //
00081         std::string t = TypeBase::CType();
00082         if (IsSimpleType())
00083         {
00084                 Xml::XmlNode n = m_wsdl.FindSimpleType(m_ns_href, m_type);
00085                 SimpleType sim(m_wsdl, n, Split(m_type).Type, Split(m_type).NS);
00086                 t = sim.CType(); //TypeBase::CType(sim.Type());
00087         }
00088         m_base_type = t;
00089 }

Element::~Element (  ) 

Definition at line 92 of file Element.cpp.

00093 {
00094 }


Member Function Documentation

const std::string& Element::Name (  )  const [inline]

Definition at line 39 of file Element.h.

References m_name.

Referenced by ComplexType::from_xml(), and ComplexType::to_string().

00039 { return m_name; }

const std::string& Element::BaseType (  )  const [inline]

Definition at line 40 of file Element.h.

References m_base_type.

Referenced by ComplexType::from_xml(), and ComplexType::to_string().

00040 { return m_base_type; }

const std::string Element::Documentation (  )  const

Definition at line 97 of file Element.cpp.

References TypeBase::m_node.

Referenced by ComplexType::CreateInterface().

00098 {
00099         Xml::XmlNode n(m_node, "annotation");
00100         if (n)
00101         {
00102                 Xml::XmlNode n2(n, "documentation");
00103                 if (n2)
00104                 {
00105                         return n2.GetContent();
00106                 }
00107         }
00108         return "";
00109 }

void Element::CreateInterface ( FILE *  fil  )  const

Definition at line 112 of file Element.cpp.

00113 {
00114 }

bool Element::IsOptional (  )  const [inline]

Definition at line 45 of file Element.h.

References m_minOccurs.

Referenced by ComplexType::from_xml(), and ComplexType::to_string().

00045 { return m_minOccurs == 0; }

bool Element::IsVector (  )  const [inline]

const std::string Element::CName (  )  const

const std::string Element::CName1up (  )  const

Definition at line 200 of file Element.cpp.

References m_name.

Referenced by ComplexType::CreateImplementation(), ComplexType::CreateInterface(), and ComplexType::from_xml().

00201 {
00202         return Split(m_name).CName1up;
00203 }

const std::string Element::CType_decl (  )  const

Definition at line 117 of file Element.cpp.

References SimpleType::CType(), TypeBase::CType(), Wsdl::FindSimpleType(), IsSimpleType(), IsVector(), Application::ListType(), m_appl, TypeBase::m_ns_href, TypeBase::m_type, TypeBase::m_wsdl, and TypeBase::Type().

Referenced by ComplexType::CreateInterface().

00118 {
00119         std::string t = TypeBase::CType();
00120         if (IsSimpleType())
00121         {
00122                 Xml::XmlNode n = m_wsdl.FindSimpleType(m_ns_href, m_type);
00123                 SimpleType sim(m_wsdl, n, Split(m_type).Type, Split(m_type).NS);
00124                 t = sim.CType(); //TypeBase::CType(sim.Type());
00125         }
00126         if (IsVector())
00127         {
00128                 t = m_appl.ListType() + "<" + t + ">";
00129         }
00130         return t;
00131 }

const std::string Element::CType_in (  )  const

Definition at line 134 of file Element.cpp.

References SimpleType::CType(), TypeBase::CType(), Wsdl::FindSimpleType(), TypeBase::IsBuiltin(), IsSimpleType(), IsVector(), Application::ListType(), m_appl, TypeBase::m_ns_href, TypeBase::m_type, TypeBase::m_wsdl, and TypeBase::Type().

Referenced by ComplexType::CreateImplementation(), and ComplexType::CreateInterface().

00135 {
00136         std::string t = TypeBase::CType();
00137         if (IsSimpleType())
00138         {
00139                 Xml::XmlNode n = m_wsdl.FindSimpleType(m_ns_href, m_type);
00140                 SimpleType sim(m_wsdl, n, Split(m_type).Type, Split(m_type).NS);
00141                 t = sim.CType(); //TypeBase::CType(sim.Type());
00142         }
00143         if (IsBuiltin() || IsSimpleType())
00144         {
00145                 if (t == "std::string")
00146                 {
00147                         if (!IsVector())
00148                                 t = "const " + t + "&";
00149                 }
00150         }
00151         else
00152         {
00153                 if (!IsVector())
00154                         t = "const " + t + "&";
00155         }
00156         if (IsVector())
00157         {
00158                 t = "const " + m_appl.ListType() + "<" + t + ">&";
00159         }
00160         return t;
00161 }

const std::string Element::CType_out (  )  const

Definition at line 164 of file Element.cpp.

References SimpleType::CType(), TypeBase::CType(), Wsdl::FindSimpleType(), TypeBase::IsBuiltin(), IsSimpleType(), IsVector(), Application::ListType(), m_appl, TypeBase::m_ns_href, TypeBase::m_type, TypeBase::m_wsdl, and TypeBase::Type().

Referenced by ComplexType::CreateImplementation(), and ComplexType::CreateInterface().

00165 {
00166         std::string t = TypeBase::CType();
00167         if (IsSimpleType())
00168         {
00169                 Xml::XmlNode n = m_wsdl.FindSimpleType(m_ns_href, m_type);
00170                 SimpleType sim(m_wsdl, n, Split(m_type).Type, Split(m_type).NS);
00171                 t = sim.CType(); //TypeBase::CType(sim.Type());
00172         }
00173         if (IsBuiltin() || IsSimpleType())
00174         {
00175                 if (t == "std::string")
00176                 {
00177                         if (!IsVector())
00178                                 t = "const " + t + "&";
00179                 }
00180         }
00181         else
00182         {
00183                 if (!IsVector())
00184                         t = t + "&";
00185         }
00186         if (IsVector())
00187         {
00188                 t = m_appl.ListType() + "<" + t + ">&";
00189         }
00190         return t;
00191 }

const std::string Element::DefaultValue (  )  const

Definition at line 206 of file Element.cpp.

References TypeBase::IsBuiltin(), and TypeBase::m_type.

Referenced by ComplexType::reset_members().

00207 {
00208         if (IsBuiltin())
00209         {
00210                 std::string t = Split(m_type).CName;
00211                 if (t == "string" || t == "date" || t == "dateTime")
00212                 {
00213                 }
00214                 else
00215                         return "0";
00216         }
00217         return "";
00218 }

bool Element::IsComplexType (  )  const

Definition at line 221 of file Element.cpp.

References Wsdl::FindComplexType(), TypeBase::IsBuiltin(), TypeBase::m_ns_href, TypeBase::m_type, and TypeBase::m_wsdl.

Referenced by ComplexType::CreateImplementation(), ComplexType::CreateInterface(), ComplexType::from_xml(), ComplexType::OkToGenerate(), ComplexType::reset_members(), and ComplexType::to_string().

00222 {
00223         if (IsBuiltin())
00224                 return false;
00225         try
00226         {
00227                 Xml::XmlNode n = m_wsdl.FindComplexType(m_ns_href, m_type);
00228                 return true;
00229         }
00230         catch (const Exception& e)
00231         {
00232         }
00233         return false;
00234 }

bool Element::IsSimpleType (  )  const

Definition at line 237 of file Element.cpp.

References Wsdl::FindSimpleType(), TypeBase::IsBuiltin(), TypeBase::m_ns_href, TypeBase::m_type, and TypeBase::m_wsdl.

Referenced by CType_decl(), CType_in(), CType_out(), and Element().

00238 {
00239         if (IsBuiltin())
00240                 return false;
00241         try
00242         {
00243                 Xml::XmlNode n = m_wsdl.FindSimpleType(m_ns_href, m_type);
00244                 return true;
00245         }
00246         catch (const Exception& e)
00247         {
00248         }
00249         return false;
00250 }


Member Data Documentation

Definition at line 60 of file Element.h.

Referenced by CType_decl(), CType_in(), and CType_out().

std::string Element::m_name [private]

Definition at line 61 of file Element.h.

Referenced by CName(), CName1up(), Element(), and Name().

std::string Element::m_base_type [private]

Definition at line 62 of file Element.h.

Referenced by BaseType(), and Element().

int Element::m_minOccurs [private]

Definition at line 63 of file Element.h.

Referenced by IsOptional().

int Element::m_maxOccurs [private]

Definition at line 64 of file Element.h.

Referenced by Element(), and IsVector().


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