VR-Exchange 2.1 API Documentation
disBroker/csvFileRdr.h
Go to the documentation of this file.
1 /*********************************************************************
2  ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: csvFileRdr.h,v $ $Revision: 1.1 $ $State: Exp $
7 ** Created:8/22/02 MEM, Updated: 8/30/02
8 *********************************************************************/
9 
10 #ifndef DtCsvFileReader_H_
11 #define DtCsvFileReader_H_
12 
13 #include <fstream>
14 
15 #include <vl/hostStructs.h>
16 #include <vlutil/vlFilename.h>
17 
18 
19 // trainerutil
20 // need creator fcn typedef
21 #include "csvFileEntry.h"
22 
23 class DtCsvFileReader;
24 
25 // class DtCsvFileReader:
26 // Reads in and parses a csv file. Children classes will hold the parsed entries in sorted lists or
27 // hash lists.
28 
29 // to use:
30 // a. construct
31 // b. open a stream.
32 // c. read and parse lines
33 // d. close
34 // e. destruct
35 
36 typedef DtCsvFileReader* (*DtCsvFileReaderCreatorFcn)();
37 
39 {
40 public:
41 
42  // default constructor
44 
45  // Full-featured constructor
46  DtCsvFileReader(const DtString & fileName);
47 
48 private:
49 
50  // copy constructor
51  DtCsvFileReader(const DtCsvFileReader& orig);
52 
53  // assignment operator
54  DtCsvFileReader& operator=(const DtCsvFileReader& orig);
55 
56 public:
57  // destructor
58  virtual ~DtCsvFileReader();
59 
60  // virtual bool openStream(const DtString & fileName);
61  virtual bool openStream();
62  virtual bool openStream(const DtString & fileName);
63  virtual void closeStream();
64 
65  // status
66  virtual bool isEOF() const;
67  virtual bool isOpen();
68 
69  // name
70  virtual void setFilename(const DtString& name);
71  virtual const DtString& filename() const;
72 
73  // Fills up line with a row from the table
74 
75  virtual bool readLine( DtString& line );
76 
77  // Used to read and parse the rest of the table.
78  // Derived Readers should create a derived DtCsvFileEntry
79  // and pass that into parseLine.
80  // The default simply reads a line and returns a generic
81  // DtCsvFileEntry, containing a list of token strings.
82  virtual DtCsvFileEntry* readAndParseNextLine(
83  DtCsvFileEntryCreatorFcn pEntryCreatorFcn);
84 
85  // Parses the line and stores data in the entry
86  virtual void parseLine(DtCsvFileEntry* pEntry,DtString& line );
87 
88 // static creator fcns
89 public:
90  static DtCsvFileReader* creator();
91 
92 
93 
94 protected:
95 
96  DtFilename myFilename;
97  std::ifstream myInfile;
98 
99 };
100 
101 #endif

Document ID: Generated on Tue Aug 7 22:07:13 EDT 2012 from SVN revision 117874
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)