pkiutilities/PKCS12/CrBer/Inc/crdata.h
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2000, 2004 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:   This file contains the header of CCrData class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CR_DATA
       
    21 #define CR_DATA
       
    22 
       
    23 
       
    24 //  INCLUDES
       
    25 
       
    26 #include <e32base.h>    // CArrayFixFlat
       
    27 #include <f32file.h>    // RFile
       
    28 
       
    29 #include "crdefs.h"     // Defines
       
    30 
       
    31 //  CONSTANTS         
       
    32 
       
    33  _LIT8(KNewLine,"\r\n"); // New line for LineL method 
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 *  CCrData
       
    39 *  CCrData class handles file and stream I/O.
       
    40 *
       
    41 *  @lib crber.lib
       
    42 *  @since Series 60 3.0
       
    43 */
       
    44 NONSHARABLE_CLASS( CCrData ): public CBase
       
    45     {
       
    46     /////////////////////////////////////////////
       
    47     // Constructors and destructors.
       
    48     public:
       
    49         IMPORT_C CCrData();
       
    50         // aIsFile set CCrData object either file (True) or buffer (False)
       
    51         IMPORT_C CCrData(TBool aIsFile);            // EFalse for a buffer
       
    52         IMPORT_C ~CCrData();
       
    53         
       
    54         TAny ConstructL();
       
    55 
       
    56         IMPORT_C static CCrData* NewLC(TBool aIsFile = ETrue); 
       
    57         IMPORT_C static CCrData* NewL(TBool aIsfile = ETrue);
       
    58         
       
    59     public: // Functions.
       
    60 
       
    61         // Opens an existing file for reading or writing. If the file 
       
    62         // does not already exist, an error is returned.
       
    63         IMPORT_C TInt Open(RFs& aFs,const TDesC& aName,TUint aFileMode);
       
    64         IMPORT_C TInt Open(RFs& aFs,TUint aFileMode);
       
    65 
       
    66         // Replaces a file. If there is an existing file with the same
       
    67         // name, this function will overwrite it. If the file does not 
       
    68         // already exist, this function creates it.
       
    69         IMPORT_C TInt Replace(RFs& aFs,const TDesC& aName,TUint aFileMode);
       
    70 
       
    71         // Closes the file. Any open files are closed when the file server 
       
    72         // session is closed. Close() is guaranteed to return, and provides 
       
    73         // no indication of whether it completed successfully or not. When 
       
    74         // closing a file that you have written to, you should ensure that
       
    75         // data is committed to the file by invoking RFile::Flush() before 
       
    76         // closing. If Flush() completes successfully, Close() is essentially 
       
    77         // a no-operation.
       
    78         IMPORT_C void Close();
       
    79 
       
    80 
       
    81         // Reading transfers data from a file (or a buffer) to a descriptor.
       
    82         // Íf CCrData object is created to be a file function only call 
       
    83         // RFile::Read(.), but if CCrData is buffer, function makes same
       
    84         // things to buffer as RFile::Read make to file.
       
    85         // See EPOC documentation to get more information.
       
    86         IMPORT_C TInt Read(TDes8& aDes);
       
    87         IMPORT_C TInt Read(TDes8& aDes,TInt aLength);
       
    88         IMPORT_C TInt Read(TInt aPos,TDes8& aDes,TInt aLength);
       
    89 
       
    90         // Writing transfers data from a descriptor to a file or to a buffer.
       
    91         // If CCrData object is created to be a file function only call 
       
    92         // RFile::Write(.), but if CCrData is buffer, function makes same
       
    93         // things to buffer as RFile::Write make to file.
       
    94         // aLength must be more than zero or error is returned.
       
    95         // See EPOC documentation to get more information.
       
    96         IMPORT_C TInt Write(const TDesC8& aDes);
       
    97         IMPORT_C TInt Write(const TDesC8& aDes,TInt aLength);
       
    98 
       
    99         // Use this function to change the current buffer (or file) position.
       
   100         // It can also be used to retrieve the current buffer (or file)
       
   101         // position without changing it (ESeekCurrent, 0).
       
   102         // The buffer (or file) position is the position at which 
       
   103         // buffer (file) reads and writes take place.
       
   104         // The start of the buffer(file) is position zero.
       
   105         // If CCrData object is created to be a file function only call 
       
   106         // RFile::Seek(.), but if CCrData is buffer, function makes same
       
   107         // things to buffer as RFile::Seek make to file.
       
   108         // aPos must be positive or error is returned. 
       
   109         // See EPOC documentation to get more information (about Seek).
       
   110         IMPORT_C TInt Seek(TSeek aMode,TInt& aPos);
       
   111 
       
   112         IMPORT_C TInt Size(TInt& aSize);
       
   113 
       
   114         // LineL sets data from the current place, where iPointer is, till
       
   115         // next new line character to aLine. 
       
   116         // iPointer moves to the following item from the found new line 
       
   117         // character. If no new line character is found, aLine is the rest
       
   118         // of the data and iPointer is moved to the end of the iBuffer or 
       
   119         // the iFile.
       
   120 
       
   121         IMPORT_C TInt LineL(TDes8& aLine);
       
   122         IMPORT_C HBufC* Path();
       
   123         IMPORT_C TAny SetPathL(const TDesC& aPath);
       
   124         IMPORT_C TBool IsFile();
       
   125         IMPORT_C TInt Delete(TInt aPos,TInt aLength);
       
   126 
       
   127 		IMPORT_C TInt Zero(const TInt aPos, const TInt aLength);
       
   128 
       
   129 
       
   130     private: // Data
       
   131         // Variable set CCrData object either file(1) or buffer(0)
       
   132         TBool iIsFile;
       
   133         // Index to iBuffer
       
   134         TInt  iPointer;
       
   135         // Buffer for data
       
   136         HBufC8* iBuffer;
       
   137         // File for data
       
   138         RFile iFile;
       
   139         // path of file
       
   140         HBufC* iPath;
       
   141     };
       
   142 
       
   143 // CLASS DECLARATION
       
   144 
       
   145 /**
       
   146 *  CCrDataSet
       
   147 *  CCrDataSet class is used to handle multiple CCrData objects.
       
   148 *
       
   149 *  @lib crber.lib
       
   150 *  @since Series 60 3.0
       
   151 */
       
   152 class CCrDataSet : public CArrayPtrSeg<CCrData>
       
   153     {
       
   154     /////////////////////////////////////////////
       
   155     // Constructors and destructors.
       
   156     private:
       
   157         CCrDataSet(TInt aGranularity);
       
   158         
       
   159         TAny ConstructL();
       
   160         
       
   161     public:
       
   162         IMPORT_C static CCrDataSet* NewLC(TInt aGranularity); 
       
   163         IMPORT_C static CCrDataSet* NewL(TInt aGranularity);
       
   164 
       
   165         ~CCrDataSet();
       
   166 
       
   167     };
       
   168 
       
   169 #endif CR_DATA