|
1 // Copyright (c) 2002-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 // $Header$ |
|
15 // CCmdFile class for reading lines from command files. Supports argument |
|
16 // strings. |
|
17 // |
|
18 // |
|
19 |
|
20 #ifndef __CCMDFILE_H__ |
|
21 #define __CCMDFILE_H__ |
|
22 |
|
23 //----------------------------------------------------------------------------- |
|
24 // Include Files |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <e32std.h> |
|
28 #include <e32hal.h> |
|
29 #include <s32file.h> |
|
30 #include <f32file.h> |
|
31 #include <fbs.h> |
|
32 |
|
33 //----------------------------------------------------------------------------- |
|
34 |
|
35 #include "TfrLex.h" |
|
36 |
|
37 //----------------------------------------------------------------------------- |
|
38 |
|
39 class CCmdFile : public CBase |
|
40 { |
|
41 |
|
42 public: // Constructors and destructors |
|
43 |
|
44 static CCmdFile* NewL (); |
|
45 static CCmdFile* NewLC(); |
|
46 ~CCmdFile(); |
|
47 |
|
48 private: // Constructors and destructors |
|
49 |
|
50 void ConstructL(); |
|
51 CCmdFile() {}; |
|
52 |
|
53 public: // New functions |
|
54 |
|
55 // Open file. Closes the old one. |
|
56 TInt Open(const TDesC& aFile); |
|
57 TInt Open(const TDesC& aPath, const TDesC& aFile); |
|
58 |
|
59 // Add more arguments, 0 or more from aArgs string. |
|
60 void AddArgsL(const TDesC& aArgs); |
|
61 |
|
62 // Get count and the i'th argument, legal i assumed. |
|
63 TInt Argc() const; |
|
64 TPtrC Argv(TInt aIndex) const; |
|
65 |
|
66 // Read line. KErrEof if no file. |
|
67 TInt Read(TDes& aDes); |
|
68 |
|
69 // Rewind file. |
|
70 TInt Rewind(); |
|
71 |
|
72 // Close file. |
|
73 void Close(); |
|
74 |
|
75 // Get file name. |
|
76 TPtrC FileName() const; |
|
77 |
|
78 // Get line number, nbr of lines read so far. |
|
79 TInt Line(); |
|
80 |
|
81 private: // Data |
|
82 |
|
83 // File name. |
|
84 TFileName iFileName; |
|
85 |
|
86 // Arguments. |
|
87 CArrayPtrSeg<HBufC>* iArgs; |
|
88 |
|
89 // For parse. |
|
90 TParse iParse; |
|
91 |
|
92 // Line number, number of lines read so far. |
|
93 TInt iLine; |
|
94 |
|
95 // Buffers. |
|
96 TPtrC iBuf; |
|
97 TLex iLex; |
|
98 |
|
99 }; |
|
100 |
|
101 //----------------------------------------------------------------------------- |
|
102 |
|
103 #endif // __CCMDFILE_H__ |
|
104 |
|
105 //----------------------------------------------------------------------------- |
|
106 // End of File |
|
107 //----------------------------------------------------------------------------- |