X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltoolingtest%2FXMLObjectBaseTestCase.h;h=85d42b129c7dd8f10c119711bc46909354240c64;hb=77769b2e300d1295b8a5d717d9ede50e27d70cea;hp=ee5fa889177ea560a62a87d39509b3df02f1c234;hpb=7c2636878325d3c99889f626a93dc876b5a77d65;p=shibboleth%2Fcpp-xmltooling.git diff --git a/xmltoolingtest/XMLObjectBaseTestCase.h b/xmltoolingtest/XMLObjectBaseTestCase.h index ee5fa88..85d42b1 100644 --- a/xmltoolingtest/XMLObjectBaseTestCase.h +++ b/xmltoolingtest/XMLObjectBaseTestCase.h @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -23,19 +24,19 @@ #include #include #include -#ifndef XMLTOOLING_NO_XMLSEC - #include -#endif #include #include #include #include +#ifndef XMLTOOLING_NO_XMLSEC + #include + using namespace xmlsignature; +#endif + using namespace xmltooling; using namespace std; -extern ParserPool* validatingPool; -extern ParserPool* nonvalidatingPool; extern string data_path; #if defined (_MSC_VER) @@ -43,11 +44,16 @@ extern string data_path; #pragma warning( disable : 4250 4251 ) #endif -class SimpleXMLObject : public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller +class SimpleXMLObject + : public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller { protected: - SimpleXMLObject(const SimpleXMLObject& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), - m_id(XMLString::replicate(src.m_id)), m_value(XMLString::replicate(src.m_value)) { + SimpleXMLObject(const SimpleXMLObject& src) + : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src), + m_id(XMLString::replicate(src.m_id)) { #ifndef XMLTOOLING_NO_XMLSEC m_children.push_back(NULL); m_signature=m_children.begin(); @@ -68,7 +74,7 @@ public: SimpleXMLObject( const XMLCh* nsURI=NULL, const XMLCh* localName=NULL, const XMLCh* prefix=NULL, const QName* schemaType=NULL - ) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_id(NULL), m_value(NULL) { + ) : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_id(NULL) { #ifndef XMLTOOLING_NO_XMLSEC m_children.push_back(NULL); m_signature=m_children.begin(); @@ -77,7 +83,6 @@ public: virtual ~SimpleXMLObject() { XMLString::release(&m_id); - XMLString::release(&m_value); } SimpleXMLObject* clone() const { @@ -91,11 +96,12 @@ public: return new SimpleXMLObject(*this); } + const XMLCh* getXMLID() const { return getId(); } const XMLCh* getId() const { return m_id; } void setId(const XMLCh* id) { m_id=prepareForAssignment(m_id,id); } - const XMLCh* getValue() const { return m_value; } - void setValue(const XMLCh* value) { m_value=prepareForAssignment(m_value,value); } + const XMLCh* getValue() const { return getTextContent(); } + void setValue(const XMLCh* value) { setTextContent(value); } #ifndef XMLTOOLING_NO_XMLSEC Signature* getSignature() const { @@ -123,12 +129,6 @@ protected: } } - void marshallElementContent(DOMElement* domElement) const { - if(getValue()) { - domElement->setTextContent(getValue()); - } - } - void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { SimpleXMLObject* simple=dynamic_cast(childXMLObject); if (simple) { @@ -154,13 +154,8 @@ protected: throw UnmarshallingException("Unknown attribute cannot be processed by parent object."); } - void processElementContent(const XMLCh* elementContent) { - setValue(elementContent); - } - private: XMLCh* m_id; - XMLCh* m_value; vector m_simples; #ifndef XMLTOOLING_NO_XMLSEC list::iterator m_signature; @@ -179,6 +174,15 @@ public: ) const { return new SimpleXMLObject(nsURI, localName, prefix, schemaType); } + + static SimpleXMLObject* newSimpleXMLObject() { + const SimpleXMLObjectBuilder* b = dynamic_cast( + XMLObjectBuilder::getBuilder(QName(SimpleXMLObject::NAMESPACE,SimpleXMLObject::LOCAL_NAME)) + ); + if (b) + return b->buildObject(); + throw XMLObjectException("Unable to obtain typed builder for SimpleXMLObject."); + } }; #if defined (_MSC_VER)