xml/legacyminidomparser/XMLParser/INC/GMXMLEntityConverter.h
changeset 34 c7e9f1c97567
parent 25 417699dc19c9
child 36 172b09aa4eb6
equal deleted inserted replaced
25:417699dc19c9 34:c7e9f1c97567
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #ifndef __GMXMLENTITYCONVERTER_H__
       
    21 #define __GMXMLENTITYCONVERTER_H__
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <txtetext.h>
       
    25 
       
    26 
       
    27 class CMDXMLEntityConverter: public CBase
       
    28 /**
       
    29  * This class represents a generic entity converter for an XML parser or composer.
       
    30  * It is responsible for converting entity references to text and vice-versa.
       
    31  * @publishedPartner
       
    32  * @released
       
    33  */
       
    34 	{
       
    35 public:
       
    36 	/**
       
    37 	 * Constructor
       
    38 	 */
       
    39 	IMPORT_C CMDXMLEntityConverter();
       
    40 
       
    41 	/** Destructor. */
       
    42 	IMPORT_C virtual ~CMDXMLEntityConverter();
       
    43 
       
    44 	/**
       
    45 	 * Takes a block of text and converts any entity references found to the
       
    46 	 * appropriate text.  Because built-in and character entity references are
       
    47 	 * longer than the replacement text, this takes place in-situ.
       
    48 	 * @param aTextToConvert Text to be converted - replacement text goes
       
    49 	 * out in the same
       
    50 	 * @return Returns KErrNone if successful or no entity found
       
    51 	 * @return Returns KErrXMLBadEntity if malformed entity found
       
    52 	 */
       
    53 	TInt EntityToTextL(TDes& aTextToConvert);
       
    54 
       
    55 	/**
       
    56 	 * Outputs a block of text to a composer with offending characters replaced by
       
    57 	 * entity references.
       
    58 	 * @param aComposer the composer to be used for output
       
    59 	 * @param aTextToConvert The text to be converted.
       
    60 	 * @return Returns KErrNone if succcessful or a file write error
       
    61 	 * @leave can Leave due to OOM
       
    62 	 */
       
    63 	IMPORT_C virtual TInt OutputComposedTextL( CMDXMLComposer* aComposer, const TDesC& aTextToConvert );
       
    64 
       
    65 protected:
       
    66 	/**
       
    67 	 * DTD Specific entity to text converter
       
    68 	 * Takes a block of text and converts any entity references found to the
       
    69 	 * appropriate text.  We hope that this can happen in-situ.
       
    70 	 * @param aTextToConvert Text to be converted - replacement text goes
       
    71 	 * out in the same
       
    72 	 * @return Returns KErrNone if successful or no entity found
       
    73 	 * @return Returns KErrXMLBadEntity if malformed entity found
       
    74 	 */
       
    75 	virtual TInt DTDEntityToText(TDes& aTextToConvert);
       
    76 
       
    77 private:
       
    78 	/**
       
    79 	 * Replaces the built in entity reference with its replacement text.
       
    80 	 * @param aTextToConvert An entity reference to convert.  This should begin with &
       
    81 	 * and end with ;.
       
    82 	 * @return Returns KErrNone if successful
       
    83 	 * @return Returns KErrUnsupported if aTextToConvert contains no recognised entity references
       
    84 	 * @return Returns KErrOverflow or KErrGeneral if the character reference couldn't be parsed
       
    85 	 */
       
    86 	TInt ConvertEntityRefL(TDes& aTextToConvert);
       
    87 
       
    88 	};
       
    89 
       
    90 
       
    91 #endif