SenXmlUtils.h

Go to the documentation of this file.
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 
00022 #ifndef SEN_XML_UTILS_H
00023 #define SEN_XML_UTILS_H
00024 
00025 //  INCLUDES
00026 #include <e32base.h>
00027 #include <stringpool.h>
00028 
00029 
00030 namespace Xml
00031     {
00032     // FORWARD DECLARES
00033     class RAttribute;
00034 
00035     // TYPE DEFINITIONS
00036     typedef RArray<RAttribute> RAttributeArray;
00037     }
00038 
00039 using namespace Xml;
00040 
00041 class CSenElement;
00042 class CSenBaseAttribute;
00043 
00044 
00045 // CONSTANTS
00046 namespace
00047     {
00048     const TInt KMaxEscapedLength = 8;
00049 
00050 /*
00051     // Moved to SenXmlConstants.hß
00052 
00053     // Five basic entities as descriptors
00054     _LIT8(KSenEscapedApos,     "&apos;");
00055     _LIT8(KSenEscapedDblQuot,  "&quot;");
00056     _LIT8(KSenEscapedGt,       "&gt;");
00057     _LIT8(KSenEscapedLt,       "&lt;");
00058     _LIT8(KSenEscapedAmp,      "&amp;");
00059 
00060     // XML-escaping chars as descriptors
00061     _LIT8(KSenAmpersandDesC8,  "&");
00062     _LIT8(KSenAposDesC8,       "\'");
00063     _LIT8(KSenDblQuotDesC8,    "\"");
00064     _LIT8(KSenGtDesC8,         ">");
00065     _LIT8(KSenLtDesC8,         "<");
00066 */    
00067     }
00068     
00069 // CLASS DECLARATION
00070 
00082 class SenXmlUtils
00083     {
00084     public: // New functions
00091         IMPORT_C static HBufC8* ToUtf8LC(const TDesC16& aUnicodeString);
00092 
00099         IMPORT_C static HBufC16* ToUnicodeLC(const TDesC8& aUtf8String);
00100 
00109         IMPORT_C static TBool StartsWith(const TDesC8& aDes,
00110                                          const TDesC8& aPrefix);
00111 
00120         IMPORT_C static TBool EndsWith(const TDesC8& aDes, const TDesC8& aPostfix);
00121 
00130         IMPORT_C static TPtrC8  AttrValue(  const RAttributeArray& aAttributes,
00131                                             const TDesC8& aAttrName);
00132 
00142         IMPORT_C static HBufC8* AllocAttrValueL(const RAttributeArray& apAttrs,
00143                                                 const TDesC8& aAttrName);
00144 
00155         IMPORT_C static void BuildQNameL(   const TDesC8& aPrefix, 
00156                                             const TDesC8& aLocalName,
00157                                             HBufC8*& aQName);
00158 
00175         IMPORT_C static TBool EncodeHttpCharactersL(const TDesC8& aOriginal,
00176                                                     HBufC8*& aEncoded);
00186         IMPORT_C static void LeaveOnXmlEscapesL(const TDesC8& aCandidate); 
00187  
00199         static void LeaveOnInvalidElementNameL(const TDesC8& aCandidate);
00200         
00215         IMPORT_C static HBufC8* EncodeHttpCharactersLC(const TDesC8& aOriginal);
00216 
00229         IMPORT_C static TBool DecodeHttpCharactersL(const TDesC8& aOriginal,
00230                                                 HBufC8*& aDecoded);
00231         
00241         IMPORT_C static HBufC8* DecodeHttpCharactersLC(const TDesC8& aOriginal);
00242 
00250         IMPORT_C static TPtrC8 NsPrefix(const TDesC8& aQName);
00251 
00259         IMPORT_C static TPtrC8 LocalName(const TDesC8& aQName);
00260 
00269         IMPORT_C static CSenBaseAttribute* RemoveAttributeL(CSenElement& aElement,
00270                                                             const TDesC8& aAttrName);
00271 
00280         IMPORT_C static CSenBaseAttribute* RemoveAttributeL(CSenElement& aElement,
00281                                                             CSenBaseAttribute* apAttribute);
00282 
00295         IMPORT_C static const TDesC8& AddAttributeL(CSenElement& aElement,
00296                                                     const TDesC8& aQName,
00297                                                     const TDesC8& aLocalName,
00298                                                     const TDesC8& aValue);
00299 
00311         IMPORT_C static const TDesC8& AddAttributeL(CSenElement& aElement,
00312                                                     const TDesC8& aAttrName,
00313                                                     const TDesC8& aValue);
00320         IMPORT_C static const TDesC8& AddAttributeL(CSenElement& aElement,
00321                                                     CSenBaseAttribute* apAttribute);
00322         
00323     private:
00324         
00328         SenXmlUtils() { }
00329 
00333         SenXmlUtils( const SenXmlUtils& );
00334         
00338         SenXmlUtils& operator=( const SenXmlUtils& );
00339 
00343         static TBool ReplaceAll( TPtr8 aDestination, 
00344                                  const TDesC8& aFrom,
00345                                  const TDesC8& aTo );        
00346 
00350         static CSenBaseAttribute* FindAttrL( CSenElement& aElement,
00351                                              const TDesC8& aName );
00352     };
00353 
00354 #endif // SEN_XML_UTILS_H
00355 
00356 // End of File
00357 

Copyright © Nokia Corporation 2001-2007
Back to top