|
1 /* |
|
2 * Copyright (c) 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: Defines CATFileReader class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CATFILEREADER_H__ |
|
20 #define __CATFILEREADER_H__ |
|
21 |
|
22 #include "ATCommonDefines.h" |
|
23 |
|
24 /** |
|
25 * Provides a feature to read a file as single block into memory and parse it |
|
26 * from there line by line (iterating). This can fail or be very slow if file |
|
27 * size is bigger than available physical memory for process. |
|
28 * But is faster when file fits in free physical memory. |
|
29 */ |
|
30 class CATFileReader |
|
31 { |
|
32 public: |
|
33 /** |
|
34 * Constructor. |
|
35 */ |
|
36 CATFileReader(); |
|
37 /** |
|
38 * Destructor. |
|
39 */ |
|
40 ~CATFileReader(); |
|
41 #ifndef MODULE_TEST |
|
42 private: |
|
43 #endif |
|
44 /** |
|
45 * Prevent copy of this class. |
|
46 */ |
|
47 CATFileReader& operator =( const CATFileReader& /*other*/ ) { } |
|
48 CATFileReader( const CATFileReader& /*other*/ ) { } |
|
49 public: |
|
50 /** |
|
51 * Open/Read file. |
|
52 * @param cFile file to be read/opened. |
|
53 * @return true if succesful. |
|
54 */ |
|
55 bool Open( const char* cFile ); |
|
56 /** |
|
57 * Close file. |
|
58 * @return true if succesful. |
|
59 */ |
|
60 bool Close( void ); |
|
61 /** |
|
62 * Get line from file. |
|
63 * @sLine where line content is stored. |
|
64 * @return true if lines left. |
|
65 */ |
|
66 bool GetLine( string& sLine ); |
|
67 /** |
|
68 * Set the line delimiter. |
|
69 * @param cDelimiter char that ends the line. |
|
70 */ |
|
71 void SetDelimiter( char cDelimiter ); |
|
72 /** |
|
73 * Get current line delimiter. |
|
74 * @return char that ends the line. |
|
75 */ |
|
76 char GetDelimiter() const; |
|
77 #ifndef MODULE_TEST |
|
78 private: |
|
79 #endif |
|
80 // Stream where file content is stored. |
|
81 stringstream m_stream; |
|
82 // Line delimiting character used. |
|
83 char m_cDelimiter; |
|
84 }; |
|
85 #endif |
|
86 // EOF |