pkiutilities/ocsp/test/t_output.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __T_OUTPUT_H__
       
    20 #define __T_OUTPUT_H__
       
    21 
       
    22 #include <f32file.h>
       
    23 #include <e32base.h>
       
    24 #include <e32std.h>
       
    25 #include <e32cons.h>
       
    26 
       
    27 /**
       
    28  * Astract base class for classes that provide logging of test output.
       
    29  *
       
    30  * 
       
    31  */
       
    32 class Output : public CBase
       
    33 	{
       
    34 public:
       
    35 	// Public interface
       
    36 	IMPORT_C void writeString(const TDesC& aString);
       
    37 	IMPORT_C void writeString(const TDesC8& aString);
       
    38 	IMPORT_C void write(TRefByValue<const TDesC16> aFmt, ...);
       
    39 	IMPORT_C void writeSpaces(TInt aSpaces); 
       
    40 	IMPORT_C void writeNewLine(); 
       
    41 	IMPORT_C void writeNum(TInt aNum); 
       
    42 	IMPORT_C void writeHex(TInt aHex);
       
    43 	IMPORT_C void writeError(TInt aError);
       
    44 	IMPORT_C void writeOctetString(const TDesC8& aString);
       
    45 	IMPORT_C void writeOctetStringL(const TDesC8& aString);
       
    46 	IMPORT_C void writeBoolL(TBool aBool);
       
    47 	IMPORT_C void writeCapabilityL(TCapability aCap);
       
    48 	IMPORT_C void writeCapabilitySetL(const TCapabilitySet& aCap);
       
    49 	IMPORT_C void writeSecurityPolicyL(const TSecurityPolicy& aPolicy);
       
    50 
       
    51 protected:
       
    52 	// Implemented by subclasses
       
    53 	virtual void DoWriteL(const TDesC& aString) = 0;
       
    54 
       
    55 private:
       
    56 	void FixNewlinesAndWriteL(const TDesC& aString);
       
    57 	};
       
    58 
       
    59 /**
       
    60  * Implementation of Output that throws away its output.
       
    61  */
       
    62 class NullOutput : public Output
       
    63 	{
       
    64 public:
       
    65 	IMPORT_C NullOutput();
       
    66 	virtual void DoWriteL(const TDesC& aString);
       
    67 	};
       
    68 
       
    69 /**
       
    70  * Implementation of Output that writes its output to a file.
       
    71  * 
       
    72  * There used to be a comment here "Writes narrow on WINS, wide on target".
       
    73  * This was not true because the implementation always wrote strings in 8 bits
       
    74  * regardless - resulting in log files containing a mixture of 8 and 16 bit
       
    75  * data.  Now this always writes as 8 bit - if this is a problem it can be
       
    76  * changed easily enough.
       
    77  */
       
    78 class FileOutput : public Output
       
    79 	{
       
    80 public:
       
    81 	IMPORT_C FileOutput(RFile& aFile);
       
    82 	virtual void DoWriteL(const TDesC& aString); 
       
    83 private:
       
    84 	RFile iFile;
       
    85 	};
       
    86 
       
    87 /**
       
    88  * Implementation of Output that prints the output to a console.
       
    89  */
       
    90 class ConsoleOutput : public Output
       
    91 	{
       
    92 public:
       
    93 	IMPORT_C ConsoleOutput(CConsoleBase& aConsole);
       
    94 	virtual void DoWriteL(const TDesC& aString); 
       
    95 private:
       
    96 	CConsoleBase& iConsole;
       
    97 	};
       
    98 
       
    99 /**
       
   100  * Implementation of Output that writes to multiple other Output objects (a bit
       
   101  * like the unix tee command).  Use to log output to console and to file.
       
   102  */
       
   103 
       
   104 class COutputTee : public Output
       
   105 	{
       
   106 public:
       
   107 	COutputTee();
       
   108 	~COutputTee();
       
   109 	/// Add a new child object - takes ownership
       
   110 	void AddChildL(Output* aChild);
       
   111 	virtual void DoWriteL(const TDesC& aString); 
       
   112 private:
       
   113 	RPointerArray<Output> iChildren;
       
   114 	};
       
   115 
       
   116 #endif