00001 /* 00002 * ============================================================================== 00003 * Name : SenXmlUtils.h 00004 * Part of : Web Services Xml 00005 * Interface : 00006 * Description : This class offers a set of utility functions for XML data 00007 * Version : 00008 * 00009 * Copyright © 2002-2005 Nokia. All rights reserved. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia. All rights are reserved. Copying, including 00013 * reproducing, storing, adapting or translating, any 00014 * or all of this material requires the prior written consent of 00015 * Nokia. This material also contains confidential 00016 * information which may not be disclosed to others without the 00017 * prior written consent of Nokia. 00018 * ============================================================================== 00019 */ 00020 00021 #ifndef SEN_XML_UTILS_H 00022 #define SEN_XML_UTILS_H 00023 00024 // INCLUDES 00025 #include <e32base.h> 00026 #include <xml/Attribute.h> 00027 00028 using namespace Xml; 00029 00030 // CONSTANTS 00031 namespace 00032 { 00033 const TInt KMaxEscapedLength = 8; 00034 00035 // Five basic entities as descriptors 00036 _LIT8(KEscapedApos, "'"); 00037 _LIT8(KEscapedDblQuot, """); 00038 _LIT8(KEscapedGt, ">"); 00039 _LIT8(KEscapedLt, "<"); 00040 _LIT8(KEscapedAmp, "&"); 00041 00042 // XML-escaping chars as descriptors 00043 _LIT8(KAmpersandDesC8, "&"); 00044 _LIT8(KAposDesC8, "\'"); 00045 _LIT8(KDblQuotDesC8, "\""); 00046 _LIT8(KGtDesC8, ">"); 00047 _LIT8(KLtDesC8, "<"); 00048 } 00049 00050 // CLASS DECLARATION 00051 00063 class SenXmlUtils 00064 { 00065 public: // New functions 00066 00073 IMPORT_C static HBufC8* ToUtf8LC(const TDesC16& aUnicodeString); 00074 00081 IMPORT_C static HBufC16* ToUnicodeLC(const TDesC8& aUtf8String); 00082 00091 IMPORT_C static TBool StartsWith(const TDesC8& aDes, 00092 const TDesC8& aPrefix); 00093 00102 IMPORT_C static TBool EndsWith(const TDesC8& aDes, const TDesC8& aPostfix); 00103 00112 IMPORT_C static TPtrC8 AttrValue( const RAttributeArray& aAttributes, 00113 const TDesC8& aAttrName); 00114 00124 IMPORT_C static HBufC8* AllocAttrValueL(const RAttributeArray& apAttrs, 00125 const TDesC8& aAttrName); 00126 00137 IMPORT_C static void BuildQNameL( const TDesC8& aPrefix, 00138 const TDesC8& aLocalName, 00139 HBufC8*& aQName); 00140 00157 IMPORT_C static TBool EncodeHttpCharactersL(const TDesC8& aOriginal, 00158 HBufC8*& aEncoded); 00159 00169 IMPORT_C static void LeaveOnXmlEscapesL(const TDesC8& aCandidate); 00170 00182 static void LeaveOnInvalidElementNameL(const TDesC8& aCandidate); 00183 00198 IMPORT_C static HBufC8* EncodeHttpCharactersLC(const TDesC8& aOriginal); 00199 00212 IMPORT_C static TBool DecodeHttpCharactersL(const TDesC8& aOriginal, 00213 HBufC8*& aDecoded); 00214 00224 IMPORT_C static HBufC8* DecodeHttpCharactersLC(const TDesC8& aOriginal); 00225 00233 IMPORT_C static TPtrC8 NsPrefix(const TDesC8& aQName); 00234 00242 IMPORT_C static TPtrC8 LocalName(const TDesC8& aQName); 00243 00244 private: 00245 00249 SenXmlUtils() { } 00250 00254 SenXmlUtils( const SenXmlUtils& ); 00255 00259 SenXmlUtils& operator=( const SenXmlUtils& ); 00260 00261 // New functions 00262 00263 static TBool ReplaceAll( TPtr8 aDestination, 00264 const TDesC8& aFrom, 00265 const TDesC8& aTo ); 00266 }; 00267 00268 // SEN_XML_UTILS_H 00269 #endif 00270 00271 // End of File 00272