epoc32/include/xml/dom/xmlengserializer.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     2
// All rights reserved.
williamr@4
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@4
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     7
//
williamr@4
     8
// Initial Contributors:
williamr@4
     9
// Nokia Corporation - initial contribution.
williamr@4
    10
//
williamr@4
    11
// Contributors:
williamr@4
    12
//
williamr@4
    13
// Description:
williamr@4
    14
// Implementation of serializer
williamr@4
    15
//
williamr@4
    16
williamr@4
    17
williamr@4
    18
williamr@4
    19
/**
williamr@4
    20
 @file
williamr@4
    21
 @publishedAll
williamr@4
    22
 @released
williamr@4
    23
*/
williamr@4
    24
#ifndef XMLENGSERIALIZER_H
williamr@4
    25
#define XMLENGSERIALIZER_H
williamr@4
    26
williamr@4
    27
#include <e32base.h>
williamr@4
    28
#include <xml/dom/xmlengserializationoptions.h>
williamr@4
    29
#include <xml/dom/xmlengnode.h>
williamr@4
    30
williamr@4
    31
class MXmlEngOutputStream;
williamr@4
    32
class RFs;
williamr@4
    33
williamr@4
    34
/** Controls the format of serialization */
williamr@4
    35
enum TXmlEngSerializerType
williamr@4
    36
	{
williamr@4
    37
	/** Default serialization (XML) */
williamr@4
    38
	ESerializerDefault,
williamr@4
    39
	/** Serialization to MIME Multipart containing XOP */
williamr@4
    40
	ESerializerXOP,
williamr@4
    41
	/** Serialization to XOP Infoset */
williamr@4
    42
	ESerializerXOPInfoset,
williamr@4
    43
	/** Serialization to GZip */
williamr@4
    44
	ESerializerGZip
williamr@4
    45
	};
williamr@4
    46
williamr@4
    47
/** Controls the serialization format */
williamr@4
    48
enum TXmlEngSerializationOutput
williamr@4
    49
	{
williamr@4
    50
	ESerializeToFile,
williamr@4
    51
	ESerializeToBuffer,
williamr@4
    52
	ESerializeToStream
williamr@4
    53
	};
williamr@4
    54
williamr@4
    55
/**
williamr@4
    56
Provides the serializer interface and provides common functionality to all
williamr@4
    57
serializers.  Implements default serialization (plain XML).  Derived classes
williamr@4
    58
implement serialization to other formats.
williamr@4
    59
williamr@4
    60
@see TXmlEngSerializerType
williamr@4
    61
*/
williamr@4
    62
class CXmlEngSerializer: public CBase
williamr@4
    63
    {
williamr@4
    64
	friend class CXmlEngSerializerXOP;
williamr@4
    65
	friend class CXmlEngSerializerGZIP;
williamr@4
    66
williamr@4
    67
public:
williamr@4
    68
    /**
williamr@4
    69
	Creates a serializer of the given type.  Returns an instance of this
williamr@4
    70
	class or a derived class.
williamr@4
    71
williamr@4
    72
    @param aType Serializer type    
williamr@4
    73
    @return The serializer
williamr@4
    74
	@leave - One of the system-wide error codes
williamr@4
    75
    */
williamr@4
    76
    IMPORT_C static CXmlEngSerializer* NewL(TXmlEngSerializerType aType = ESerializerDefault);
williamr@4
    77
   
williamr@4
    78
	/**
williamr@4
    79
	Sets the output type to file and saves the file name for later
williamr@4
    80
	serialization.
williamr@4
    81
	@param aFileName The file name of the file to serialize
williamr@4
    82
	@leave - One of the system-wide error codes
williamr@4
    83
    */
williamr@4
    84
    IMPORT_C void SetOutputL(const TDesC& aFileName);
williamr@4
    85
williamr@4
    86
	/**
williamr@4
    87
	Sets the output type to buffer and saves the buffer for later serialization.
williamr@4
    88
	@param aBuffer The buffer to serialize
williamr@4
    89
    */
williamr@4
    90
    IMPORT_C void SetOutput(RBuf8& aBuffer);
williamr@4
    91
williamr@4
    92
	/**
williamr@4
    93
	Sets the output type to stream and saves the stream for later serialization.
williamr@4
    94
	@param aBuffer The stream to serialize
williamr@4
    95
    */
williamr@4
    96
    IMPORT_C void SetOutput(MXmlEngOutputStream& aStream);
williamr@4
    97
williamr@4
    98
    /**
williamr@4
    99
    Sets the serialization options
williamr@4
   100
	@param aOptions The serialization options to set.  Ownership is not
williamr@4
   101
	transferred and aOptions must stay in scope for the lifetime of the
williamr@4
   102
	serializer.
williamr@4
   103
    */
williamr@4
   104
    IMPORT_C void SetSerializationOptions(TXmlEngSerializationOptions& aOptions);	
williamr@4
   105
williamr@4
   106
	/**
williamr@4
   107
	Serializes a DOM tree to the buffer, file or stream set previously with
williamr@4
   108
	SetOutputL() or SetOutput().
williamr@4
   109
williamr@4
   110
    @param aRoot The root node of the DOM tree to be serialized
williamr@4
   111
    @return The number of bytes written
williamr@4
   112
	@leave KXmlEngErrNoParameters No previous call to SetOutputL() or SetOutput().
williamr@4
   113
	@leave KErrNotSupported Unsupported serialization type
williamr@4
   114
	@leave KXmlEngErrWrongEncoding Encoding not understood
williamr@4
   115
	@leave KXmlEngErrWrongUseofAPI Document of root node is NULL
williamr@4
   116
    @leave KXmlEngErrNegativeOutputSize The data to be serialized has a negative size
williamr@4
   117
    @leave - One of the system-wide error codes
williamr@4
   118
    */
williamr@4
   119
    IMPORT_C virtual TInt SerializeL(const TXmlEngNode aRoot = TXmlEngNode());
williamr@4
   120
williamr@4
   121
    /**
williamr@4
   122
	Serializes a DOM tree to file.  Any filename previously set with
williamr@4
   123
	SetOutputL(const TDesC&) is ignored.
williamr@4
   124
    
williamr@4
   125
    @param aFileName The file name to serialize to
williamr@4
   126
    @param aRoot The root node of the DOM tree to be serialized     
williamr@4
   127
    @param aOptions The serialization options	 	 
williamr@4
   128
    @return The number of bytes written
williamr@4
   129
	@leave KXmlEngErrWrongEncoding Encoding not understood
williamr@4
   130
	@leave KXmlEngErrWrongUseofAPI Document of root node is NULL
williamr@4
   131
    @leave KXmlEngErrNegativeOutputSize The data to be serialized has a negative size
williamr@4
   132
	@leave - One of the system-wide error codes
williamr@4
   133
    */
williamr@4
   134
    IMPORT_C virtual TInt SerializeL(const TDesC& aFileName, 
williamr@4
   135
			    const TXmlEngNode aRoot = TXmlEngNode(),
williamr@4
   136
			    const TXmlEngSerializationOptions& aOptions = TXmlEngSerializationOptions());
williamr@4
   137
                                        									  		
williamr@4
   138
    /**
williamr@4
   139
    Serializes a DOM tree to file.  Any filename previously set with
williamr@4
   140
	SetOutputL(const TDesC&) is ignored. 
williamr@4
   141
williamr@4
   142
    @param aRFs File Server session
williamr@4
   143
    @param aFileName The file name to serialize to
williamr@4
   144
    @param aRoot The root node of the DOM tree to be serialized     
williamr@4
   145
    @param aOptions The serialization options	 	 
williamr@4
   146
    @return The number of bytes written
williamr@4
   147
	@leave KXmlEngErrWrongEncoding Encoding not understood
williamr@4
   148
	@leave KXmlEngErrWrongUseofAPI Document of root node is NULL
williamr@4
   149
    @leave KXmlEngErrNegativeOutputSize The data to be serialized has a negative size
williamr@4
   150
	@leave - One of the system-wide error codes
williamr@4
   151
    */
williamr@4
   152
    IMPORT_C virtual TInt SerializeL(RFs& aRFs, 
williamr@4
   153
			const TDesC& aFileName, 
williamr@4
   154
			const TXmlEngNode aRoot = TXmlEngNode(),
williamr@4
   155
			const TXmlEngSerializationOptions& aOptions = TXmlEngSerializationOptions());
williamr@4
   156
				
williamr@4
   157
    /**
williamr@4
   158
	Serializes a DOM tree to buffer.  Any buffer previously set with
williamr@4
   159
	SetOutputL(RBuf8&) is ignored.  Any existing data in aBuffer is destroyed.
williamr@4
   160
	This function allocates memory for the buffer and the caller must close the
williamr@4
   161
	buffer when finished.
williamr@4
   162
     
williamr@4
   163
    @param aBuffer The buffer to serialize to
williamr@4
   164
    @param aRoot The root node of DOM tree
williamr@4
   165
    @param aOptions The serialization options
williamr@4
   166
    @return The number of bytes written
williamr@4
   167
	@leave KXmlEngErrWrongEncoding Encoding not understood
williamr@4
   168
	@leave KXmlEngErrWrongUseofAPI Document of root node is NULL
williamr@4
   169
    @leave KXmlEngErrNegativeOutputSize The data to be serialized has a negative size
williamr@4
   170
	@leave - One of the system-wide error codes
williamr@4
   171
    */
williamr@4
   172
    IMPORT_C virtual TInt SerializeL(RBuf8& aBuffer, 
williamr@4
   173
                            const TXmlEngNode aRoot = TXmlEngNode(),
williamr@4
   174
                            const TXmlEngSerializationOptions& 
williamr@4
   175
                            aOptions = TXmlEngSerializationOptions());
williamr@4
   176
                            
williamr@4
   177
    /** Destructor */
williamr@4
   178
    virtual ~CXmlEngSerializer();
williamr@4
   179
williamr@4
   180
private:
williamr@4
   181
    /** Default constructor */
williamr@4
   182
    CXmlEngSerializer();
williamr@4
   183
    
williamr@4
   184
   /** Second phase constructor. */
williamr@4
   185
    void ConstructL();
williamr@4
   186
    
williamr@4
   187
private:
williamr@4
   188
	HBufC*                           iOutFileName;
williamr@4
   189
	RBuf8*                           iBuffer;
williamr@4
   190
	MXmlEngOutputStream*		     iOutputStream;
williamr@4
   191
	TXmlEngSerializationOptions*     iSerializationOptions;
williamr@4
   192
	TXmlEngSerializationOutput       iSerializationOutput;
williamr@4
   193
    };
williamr@4
   194
williamr@4
   195
#endif /* XMLENGSERIALIZER_H */
williamr@4
   196