//%2006//////////////////////////////////////////////////////////////////////// // // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation, The Open Group. // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // EMC Corporation; VERITAS Software Corporation; The Open Group. // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; // EMC Corporation; Symantec Corporation; The Open Group. // // 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. // //============================================================================== // //%///////////////////////////////////////////////////////////////////////////// #ifndef Pegasus_XmlGenerator_h #define Pegasus_XmlGenerator_h #include #include #include #include #include #include #include #include #include #include PEGASUS_NAMESPACE_BEGIN class PEGASUS_COMMON_LINKAGE XmlGenerator { public: static void append(Buffer& out, char x) { out.append(x); } static void append(Buffer& out, const Char16& x); static void append(Buffer& out, Boolean x); static void append(Buffer& out, Uint32 x); static void append(Buffer& out, Sint32 x); static void append(Buffer& out, Uint64 x); static void append(Buffer& out, Sint64 x); static void append(Buffer& out, Real32 x); static void append(Buffer& out, Real64 x); static void append(Buffer& out, const char* str); static void append(Buffer& out, const String& str); static void appendSpecial(Buffer& out, const Char16& x); static void appendSpecial(Buffer& out, char x); static void appendSpecial(Buffer& out, const char* str); static void appendSpecial(Buffer& out, const String& str); static String encodeURICharacters(const Buffer& uriString); static String encodeURICharacters(const String& uriString); static void indentedPrint( PEGASUS_STD(ostream)& os, const char* text, Uint32 indentChars = 2); private: static void _appendChar(Buffer& out, const Char16& c); static void _appendSpecialChar7(Buffer& out, char c); static void _appendSpecialChar(Buffer& out, const Char16& c); static void _appendSpecialChar(PEGASUS_STD(ostream)& os, char c); static void _appendSurrogatePair( Buffer& out, Uint16 high, Uint16 low); static void _appendSpecial( PEGASUS_STD(ostream)& os, const char* str); #ifdef PEGASUS_OS_TYPE_WINDOWS static void _normalizeRealValueString(char *str); #endif static void _encodeURIChar(String& outString, Sint8 char8); static void _printAttributes( PEGASUS_STD(ostream)& os, const XmlAttribute* attributes, Uint32 attributeCount); static void _indent( PEGASUS_STD(ostream)& os, Uint32 level, Uint32 indentChars); XmlGenerator(); }; PEGASUS_COMMON_LINKAGE Buffer& operator<<( Buffer& out, const char* x); inline Buffer& operator<<(Buffer& out, char x) { out.append(x); return out; } inline Buffer& operator<<(Buffer& out, const char* s) { out.append(s, (Uint32)strlen(s)); return out; } PEGASUS_COMMON_LINKAGE Buffer& operator<<( Buffer& out, const AcceptLanguageList& al); PEGASUS_COMMON_LINKAGE Buffer& operator<<( Buffer& out, const ContentLanguageList& cl); PEGASUS_COMMON_LINKAGE Buffer& operator<<(Buffer& out, const Char16& x); PEGASUS_COMMON_LINKAGE Buffer& operator<<( Buffer& out, const String& x); PEGASUS_COMMON_LINKAGE Buffer& operator<<( Buffer& out, const Buffer& x); PEGASUS_COMMON_LINKAGE Buffer& operator<<( Buffer& out, Uint32 x); PEGASUS_COMMON_LINKAGE Buffer& operator<<( Buffer& out, const CIMName& name); // This is a shortcut macro for outputing content length. This // pads the output number to the max characters representing a Uint32 number // so that it can be overwritten easily with a transfer encoding line later // on in HTTPConnection if required. This is strictly for performance since // messages can be very large. This overwriting shortcut allows us to NOT have // to repackage a large message later. #define OUTPUT_CONTENTLENGTH(out, contentLength) \ { \ char contentLengthP[11]; \ int n = sprintf(contentLengthP,"%.10u", (unsigned int)contentLength); \ out << STRLIT("content-length: "); \ out.append(contentLengthP, n); \ out << STRLIT("\r\n"); \ } PEGASUS_NAMESPACE_END #endif /* Pegasus_XmlGenerator_h */