version 1.11, 2001/04/25 22:20:56
|
version 1.24, 2002/02/20 03:51:31
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM |
// 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 |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// copy of this software and associated documentation files (the "Software"), |
// of this software and associated documentation files (the "Software"), to |
// to deal in the Software without restriction, including without limitation |
// deal in the Software without restriction, including without limitation the |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// and/or sell copies of the Software, and to permit persons to whom the |
// sell copies of the Software, and to permit persons to whom the Software is |
// Software is furnished to do so, subject to the following conditions: |
// furnished to do so, subject to the following conditions: |
// |
// |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// DEALINGS IN THE SOFTWARE. |
// 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) | // Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// Modified By: | // 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) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// XmlWriter.h |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
#ifndef Pegasus_XmlWriter_h | #ifndef Pegasus_XmlWriter_h |
#define Pegasus_XmlWriter_h | #define Pegasus_XmlWriter_h |
| |
|
|
#include <Pegasus/Common/String.h> | #include <Pegasus/Common/String.h> |
#include <Pegasus/Common/Indentor.h> | #include <Pegasus/Common/Indentor.h> |
#include <Pegasus/Common/CIMReference.h> | #include <Pegasus/Common/CIMReference.h> |
|
#include <Pegasus/Common/CIMPropertyList.h> |
|
#include <Pegasus/Common/CIMNamedInstance.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
class CIMConstClass; | class CIMConstClass; |
class CIMConstInstance; | class CIMConstInstance; |
| |
|
// REVIEW: Restructure parser so that multiple nested allocations are not |
|
// REVIEW: required to build a message. |
|
|
class PEGASUS_COMMON_LINKAGE XmlWriter | class PEGASUS_COMMON_LINKAGE XmlWriter |
{ | { |
public: | public: |
|
|
const char* cimOperation, | const char* cimOperation, |
const char* cimMethod, | const char* cimMethod, |
const String& cimObject, | const String& cimObject, |
|
const String& authenticationHeader, |
const Array<Sint8>& content); | const Array<Sint8>& content); |
| |
static Array<Sint8> formatMethodResponseHeader( | static Array<Sint8> formatMethodResponseHeader( |
const Array<Sint8>& content); | const Array<Sint8>& content); |
| |
static Array<Sint8> formatMessageElement( | static Array<Sint8> formatMessageElement( |
Uint32 messageId, |
const String& messageId, |
const Array<Sint8>& body); | const Array<Sint8>& body); |
| |
static Array<Sint8> formatSimpleReqElement( | static Array<Sint8> formatSimpleReqElement( |
|
|
const Array<Sint8>& body); | const Array<Sint8>& body); |
| |
static Array<Sint8> formatErrorElement( | static Array<Sint8> formatErrorElement( |
CIMException::Code code, |
CIMStatusCode code, |
const char* description); | const char* description); |
| |
static Array<Sint8>& appendBooleanParameter( | static Array<Sint8>& appendBooleanParameter( |
|
|
const char* parameterName, | const char* parameterName, |
Boolean flag); | Boolean flag); |
| |
|
static Array<Sint8>& appendStringIParameter( |
|
Array<Sint8>& out, |
|
const char* parameterName, |
|
const String& str); |
|
|
static Array<Sint8>& appendClassNameParameter( | static Array<Sint8>& appendClassNameParameter( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* parameterName, | const char* parameterName, |
|
|
const char* parameterName, | const char* parameterName, |
const CIMConstInstance& instance); | const CIMConstInstance& instance); |
| |
|
static Array<Sint8>& appendNamedInstanceParameter( |
|
Array<Sint8>& out, |
|
const char* parameterName, |
|
const CIMNamedInstance& namedInstance); |
|
|
static Array<Sint8>& appendQualifierDeclarationParameter( | static Array<Sint8>& appendQualifierDeclarationParameter( |
Array<Sint8>& out, | Array<Sint8>& out, |
const char* parameterName, | const char* parameterName, |
|
|
Array<Sint8>& out, | Array<Sint8>& out, |
const String& propertyName); | const String& propertyName); |
| |
|
static Array<Sint8>& appendPropertyValueParameter( |
|
Array<Sint8>& out, |
|
const char* parameterName, |
|
const CIMValue& value); |
|
|
|
static Array<Sint8>& appendPropertyListParameter( |
|
Array<Sint8>& out, |
|
const CIMPropertyList& propertyList); |
|
|
|
static Array<Sint8>& appendObjectNameParameter( |
|
Array<Sint8>& out, |
|
const char* name, |
|
const CIMReference& objectName); |
|
|
static void indentedPrint( | static void indentedPrint( |
std::ostream& os, |
PEGASUS_STD(ostream)& os, |
const char* text, | const char* text, |
Uint32 indentChars = 2); | Uint32 indentChars = 2); |
| |
static Array<Sint8> formatSimpleReqMessage( |
static Array<Sint8> formatSimpleIMethodReqMessage( |
const char* host, | const char* host, |
const String& nameSpace, | const String& nameSpace, |
const char* iMethodName, | const char* iMethodName, |
|
const String& messageId, |
|
const String& authenticationHeader, |
const Array<Sint8>& body); | const Array<Sint8>& body); |
| |
static Array<Sint8> formatSimpleRspMessage( | static Array<Sint8> formatSimpleRspMessage( |
const char* iMethodName, | const char* iMethodName, |
|
const String& messageId, |
|
const Array<Sint8>& body); |
|
|
|
static String getNextMessageId(); |
|
|
|
static Array<Sint8> formatSimpleIndicationReqMessage( |
|
const char* host, |
|
const char* iMethodName, |
|
const String& messageId, |
|
const String& authenticationHeader, |
|
const Array<Sint8>& body); |
|
|
|
static Array<Sint8> formatEMethodCallElement( |
|
const char* name, |
|
const Array<Sint8>& iParamValues); |
|
|
|
static Array<Sint8> formatMPostIndicationHeader( |
|
const char* host, |
|
const char* cimOperation, |
|
const char* cimMethod, |
|
const String& authenticationHeader, |
|
const Array<Sint8>& content); |
|
|
|
static Array<Sint8> formatSimpleExportReqElement( |
|
const Array<Sint8>& body); |
|
|
|
static Array<Sint8> formatSimpleExportRspElement( |
|
const Array<Sint8>& body); |
|
|
|
static Array<Sint8> formatSimpleIndicationRspMessage( |
|
const char* iMethodName, |
|
const String& messageId, |
|
const Array<Sint8>& body); |
|
|
|
static Array<Sint8> formatEMethodResponseElement( |
|
const char* name, |
|
const Array<Sint8>& iParamValues); |
|
|
|
static Array<Sint8> formatEMethodResponseHeader( |
|
const Array<Sint8>& content); |
|
|
|
static Array<Sint8> formatSimpleMethodReqMessage( |
|
const char* host, |
|
const String& nameSpace, |
|
const char* iMethodName, |
|
const String& messageId, |
|
const String& authenticationHeader, |
|
const Array<Sint8>& body); |
|
|
|
static Array<Sint8> formatMethodCallElement( |
|
const char* name, |
|
const String& nameSpace, |
|
const Array<Sint8>& iParamValues); |
|
|
|
static Array<Sint8> formatSimpleMethodRspMessage( |
|
const char* iMethodName, |
|
const String& messageId, |
|
const Array<Sint8>& body); |
|
|
|
static Array<Sint8> formatMethodResponseElement( |
|
const char* name, |
|
const Array<Sint8>& iParamValues); |
|
|
|
static Array<Sint8> formatReturnValueElement( |
const Array<Sint8>& body); | const Array<Sint8>& body); |
| |
static Uint32 getNextMessageId(); |
static Array<Sint8> formatUnauthorizedResponseHeader( |
|
const String& content); |
| |
private: | private: |
| |
XmlWriter() { } | XmlWriter() { } |
}; | }; |
| |
inline Array<Sint8>& operator<<(Array<Sint8>& out, const char* x) |
PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<( |
{ |
Array<Sint8>& out, |
XmlWriter::append(out, x); |
const char* x); |
return out; |
|
} |
|
| |
inline Array<Sint8>& operator<<(Array<Sint8>& out, char x) |
PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(Array<Sint8>& out, char x); |
{ |
|
XmlWriter::append(out, x); |
|
return out; |
|
} |
|
| |
inline Array<Sint8>& operator<<(Array<Sint8>& out, Char16 x) |
PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<(Array<Sint8>& out, Char16 x); |
{ |
|
XmlWriter::append(out, x); |
|
return out; |
|
} |
|
| |
inline Array<Sint8>& operator<<(Array<Sint8>& out, const String& x) |
PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<( |
{ |
Array<Sint8>& out, |
XmlWriter::append(out, x); |
const String& x); |
return out; |
|
} |
|
| |
inline Array<Sint8>& operator<<(Array<Sint8>& out, const Indentor& x) |
PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<( |
{ |
Array<Sint8>& out, |
XmlWriter::append(out, x); |
const Indentor& x); |
return out; |
|
} |
|
| |
inline Array<Sint8>& operator<<(Array<Sint8>& out, const Array<Sint8>& x) |
PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<( |
{ |
Array<Sint8>& out, |
out.appendArray(x); |
const Array<Sint8>& x); |
return out; |
|
} |
|
| |
inline Array<Sint8>& operator<<(Array<Sint8>& out, Uint32 x) |
PEGASUS_COMMON_LINKAGE Array<Sint8>& operator<<( |
{ |
Array<Sint8>& out, |
XmlWriter::append(out, x); |
Uint32 x); |
return out; |
|
} |
|
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |