//%///////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM, // The Open Group, Tivoli Systems // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //============================================================================== // // Author: Mike Brasher (mbrasher@bmc.com) // // Modified By: // Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) // //%///////////////////////////////////////////////////////////////////////////// #ifndef Pegasus_XmlWriter_h #define Pegasus_XmlWriter_h #include #include #include #include #include #include #include #include #include #include PEGASUS_NAMESPACE_BEGIN class CIMConstQualifierDecl; class CIMConstClass; class CIMConstInstance; class PEGASUS_COMMON_LINKAGE XmlWriter { public: static void append(Array& out, Char16 x); static void append(Array& out, char x) { append(out, Char16(x)); } static void append(Array& out, Uint32 x); static void append(Array& out, const char* str); static void append(Array& out, const String& str); static void append(Array& out, const Indentor& x); static void appendSpecial(Array& out, Char16 x); static void appendSpecial(Array& out, char x); static void appendSpecial(Array& out, const char* str); static void appendSpecial(Array& out, const String& str); static void appendLocalNameSpacePathElement( Array& out, const String& nameSpace); static void appendNameSpacePathElement( Array& out, const String& host, const String& nameSpace); static void appendClassNameElement( Array& out, const String& className); static void appendInstanceNameElement( Array& out, const CIMReference& instanceName); static void appendClassPathElement( Array& out, const CIMReference& classPath); static void appendInstancePathElement( Array& out, const CIMReference& instancePath); static void appendLocalClassPathElement( Array& out, const CIMReference& classPath); static void appendLocalInstancePathElement( Array& out, const CIMReference& instancePath); static void appendLocalObjectPathElement( Array& out, const CIMReference& objectPath); static void appendMethodCallHeader( Array& out, const char* host, const char* cimMethod, const String& cimObject, const String& authenticationHeader, Uint32 contentLength); static void appendMethodResponseHeader( Array& out, Uint32 contentLength); static void appendHttpErrorResponseHeader( Array& out, const String& status, const String& cimError = String::EMPTY, const String& errorDetail = String::EMPTY); static void appendUnauthorizedResponseHeader( Array& out, const String& content); static void appendReturnValueElement( Array& out, const CIMValue& value); static void appendBooleanIParameter( Array& out, const char* name, Boolean flag); static void appendStringIParameter( Array& out, const char* name, const String& str); static void appendQualifierNameIParameter( Array& out, const char* name, const String& qualifierName); static void appendClassNameIParameter( Array& out, const char* name, const String& className); static void appendInstanceNameIParameter( Array& out, const char* name, const CIMReference& instanceName); static void appendObjectNameIParameter( Array& out, const char* name, const CIMReference& objectName); static void appendClassIParameter( Array& out, const char* name, const CIMConstClass& cimClass); static void appendInstanceIParameter( Array& out, const char* name, const CIMConstInstance& instance); static void appendNamedInstanceIParameter( Array& out, const char* name, const CIMNamedInstance& namedInstance); static void appendPropertyNameIParameter( Array& out, const String& propertyName); static void appendPropertyValueIParameter( Array& out, const char* name, const CIMValue& value); static void appendPropertyListIParameter( Array& out, const CIMPropertyList& propertyList); static void appendQualifierDeclarationIParameter( Array& out, const char* name, const CIMConstQualifierDecl& qualifierDecl); static Array formatHttpErrorRspMessage( const String& status, const String& cimError = String::EMPTY, const String& errorDetail = String::EMPTY); static Array formatSimpleMethodReqMessage( const char* host, const String& nameSpace, const CIMReference& path, const char* methodName, const Array& parameters, const String& messageId, const String& authenticationHeader); static Array formatSimpleMethodRspMessage( const char* methodName, const String& messageId, const Array& body); static Array formatSimpleMethodErrorRspMessage( const String& methodName, const String& messageId, const CIMException& cimException); static Array formatSimpleIMethodReqMessage( const char* host, const String& nameSpace, const char* iMethodName, const String& messageId, const String& authenticationHeader, const Array& body); static Array formatSimpleIMethodRspMessage( const char* iMethodName, const String& messageId, const Array& body); static Array formatSimpleIMethodErrorRspMessage( const String& iMethodName, const String& messageId, const CIMException& cimException); static void appendEMethodRequestHeader( Array& out, const char* host, const char* cimMethod, const String& authenticationHeader, Uint32 contentLength); static void appendEMethodResponseHeader( Array& out, Uint32 contentLength); static Array formatSimpleEMethodReqMessage( const char* host, const char* eMethodName, const String& messageId, const String& authenticationHeader, const Array& body); static Array formatSimpleEMethodRspMessage( const char* eMethodName, const String& messageId, const Array& body); static Array formatSimpleEMethodErrorRspMessage( const String& eMethodName, const String& messageId, const CIMException& cimException); static void indentedPrint( PEGASUS_STD(ostream)& os, const char* text, Uint32 indentChars = 2); static String getNextMessageId(); private: static void _appendMessageElementBegin( Array& out, const String& messageId); static void _appendMessageElementEnd( Array& out); static void _appendSimpleReqElementBegin(Array& out); static void _appendSimpleReqElementEnd(Array& out); static void _appendMethodCallElementBegin( Array& out, const char* name); static void _appendMethodCallElementEnd( Array& out); static void _appendIMethodCallElementBegin( Array& out, const char* name); static void _appendIMethodCallElementEnd( Array& out); static void _appendIParamValueElementBegin( Array& out, const char* name); static void _appendIParamValueElementEnd( Array& out); static void _appendSimpleRspElementBegin(Array& out); static void _appendSimpleRspElementEnd(Array& out); static void _appendMethodResponseElementBegin( Array& out, const char* name); static void _appendMethodResponseElementEnd( Array& out); static void _appendIMethodResponseElementBegin( Array& out, const char* name); static void _appendIMethodResponseElementEnd( Array& out); static void _appendErrorElement( Array& out, const CIMException& cimException); static void _appendIReturnValueElementBegin(Array& out); static void _appendIReturnValueElementEnd(Array& out); static void _appendSimpleExportReqElementBegin(Array& out); static void _appendSimpleExportReqElementEnd(Array& out); static void _appendEMethodCallElementBegin( Array& out, const char* name); static void _appendEMethodCallElementEnd( Array& out); static void _appendSimpleExportRspElementBegin(Array& out); static void _appendSimpleExportRspElementEnd(Array& out); static void _appendEMethodResponseElementBegin( Array& out, const char* name); static void _appendEMethodResponseElementEnd( Array& out); XmlWriter() { } }; PEGASUS_COMMON_LINKAGE Array& operator<<( Array& out, const char* x); PEGASUS_COMMON_LINKAGE Array& operator<<(Array& out, char x); PEGASUS_COMMON_LINKAGE Array& operator<<(Array& out, Char16 x); PEGASUS_COMMON_LINKAGE Array& operator<<( Array& out, const String& x); PEGASUS_COMMON_LINKAGE Array& operator<<( Array& out, const Indentor& x); PEGASUS_COMMON_LINKAGE Array& operator<<( Array& out, const Array& x); PEGASUS_COMMON_LINKAGE Array& operator<<( Array& out, Uint32 x); PEGASUS_NAMESPACE_END #endif /* Pegasus_XmlWriter_h */