sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __TXTWRITER_H__ sl@0: #define __TXTWRITER_H__ sl@0: sl@0: #include sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: // MTextWriter interface sl@0: sl@0: /** sl@0: MTextWriter class is an interface, implemented by TParagraphTextWriter and sl@0: TLineTextWriter classes. It offers two functions: sl@0: 1) void WriteL(TText aChar) - to output a single character. sl@0: 2) void FlushL() - if the implementations have stored some of the incomming characters sl@0: for further processing, they will be immediately flushed to the output. sl@0: They are not supposed to be called directly. MTextWriter class, together with TSLBTransaltor, sl@0: MOutputChar, TParagraphTextWriter and TLineTextWriter classes builds a framework, used for sl@0: correct filtering of the 0x0D and 0x0A characters and translating them to line breaks or spaces, sl@0: depending of the text file organisation. sl@0: @internalComponent sl@0: */ sl@0: class MTextWriter sl@0: { sl@0: public: sl@0: virtual void WriteL(TText aChar) = 0; sl@0: virtual void FlushL() sl@0: { sl@0: } sl@0: }; sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: // MOutputChar interface sl@0: sl@0: /** sl@0: MOutputChar interface offers "void OutputCharL(TText aChar)" method, which gets as an input sl@0: character, which may be a line break or something else, but not 0x0D or 0x0A characters, which sl@0: were filtered earlier. sl@0: @internalComponent sl@0: */ sl@0: class MOutputChar sl@0: { sl@0: public: sl@0: virtual void OutputCharL(TText aChar) = 0; sl@0: }; sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: // TSLBTransaltor class sl@0: sl@0: /** sl@0: TSLBTransaltor class offers functionality for processing a stream of characters, filtering sl@0: 0x0D and 0x0A characters or (0x0D 0x0A) combination, and transating them to single line breaks. sl@0: It sends translated characters for a further processing using MTextWriter::WriteL() call. sl@0: The translation rules are: sl@0: - 0x0D - line break; sl@0: - 0x0A - line break; sl@0: - 0x0D 0x0A - line break; sl@0: @internalComponent sl@0: */ sl@0: class TSLBTransaltor sl@0: { sl@0: public: sl@0: inline TSLBTransaltor(MTextWriter& aTextWriter); sl@0: void ProcessL(TText aChar); sl@0: void FlushL(); sl@0: private: sl@0: MTextWriter& iTextWriter; sl@0: TText iPrevChar; sl@0: }; sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: // TParagraphTextWriter class sl@0: sl@0: /** sl@0: TParagraphTextWriter class is a concrete implementation of MTextWriter interface. sl@0: It is used to translate line breaks in the input sequence to paragraph delimiters. sl@0: Every line break from the input is replaced with paragraph delimiter in the output. sl@0: MOutputChar interface is used for the output. sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(TParagraphTextWriter) : public MTextWriter sl@0: { sl@0: public: sl@0: inline TParagraphTextWriter(MOutputChar& aOutputChar); sl@0: virtual void WriteL(TText aChar); sl@0: private: sl@0: MOutputChar& iOutputChar; sl@0: }; sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////////////////////////////////////////////////////////////////////////////// sl@0: // TLineTextWriter class sl@0: sl@0: /** sl@0: TLineTextWriter class is a concrete implementation of MTextWriter interface. sl@0: It is used to translate line breaks in the input sequence to paragraph delimiters or spaces. sl@0: The translation rules are: sl@0: - single line break - space; sl@0: - double line break - paragraph delimiter; sl@0: MOutputChar interface is used for the output. sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(TLineTextWriter) : public MTextWriter sl@0: { sl@0: public: sl@0: inline TLineTextWriter(MOutputChar& aOutputChar); sl@0: virtual void WriteL(TText aChar); sl@0: virtual void FlushL(); sl@0: private: sl@0: MOutputChar& iOutputChar; sl@0: TText iPrevChar; sl@0: }; sl@0: sl@0: sl@0: #include "TxtWriter.inl" sl@0: sl@0: #endif //__TXTWRITER_H__