Evita  0.16
evFile.h
Go to the documentation of this file.
1 /*
2  *
3  * EVITA: Efficient Visualization of Terascale Datasets
4  * Copyright (C) 2000-2016 Team Evita
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
19  * MA 02139, USA.
20  *
21  */
22 
23 
24 #ifndef __evFile_h
25 #define __evFile_h
26 
27 
28 #include "evVersion.h"
29 #include "evAddress.h"
30 #include "evVector.h"
31 
32 
33 #define EVFILE_INPUT 0
34 #define EVFILE_OUTPUT 1
35 
36 #define EVFILE_FULLBUFFERING 0
37 #define EVFILE_LINEBUFFERING 1
38 #define EVFILE_UNBUFFERED 2
39 
40 
41 typedef long evFilePosition;
42 
43 
44 class evFile : public evDataObject
45 {
46 public:
47  evFile(void);
48  virtual ~evFile(void);
49 
50  virtual const evString GetClassName(void) const
51  {
52  return(evString("evFile"));
53  }
54 
55  evString GetFilename(void);
57  int GetMode(void);
58  FILE *GetFilePointer(void);
59 
60  int IsOpen(void);
61 
62  int Open(const evString &filename, const char *mode);
63  virtual int Close(void);
64 
65  virtual int Flush(void);
66  virtual int SetBufferMode(const int mode);
67 
68  int GetPosition(evFilePosition &file_position);
69  int Seek(const evFilePosition file_position);
70 
71  int SkipWhiteSpace(void);
72 
73  int ReadChar(char &value);
74  int WriteChar(const char value);
75 
76  int ReadToken(const evString &token);
77  int ReadToken(const evString &token, int &token_value);
78  int ReadToken(const evString &token, evAddress &token_value);
79  int ReadToken(const evString &token, double &token_value);
80  int ReadToken(const evString &token, evVector &token_value);
81  int ReadToken(const evString &token, evString &token_value);
82  int ReadToken(const evString &token, evVersion &token_value);
83  int WriteToken(const evString &token);
84  int WriteToken(const evString &token, const int token_value);
85  int WriteToken(const evString &token, const evAddress &token_value);
86  int WriteToken(const evString &token, const double token_value);
87  int WriteToken(const evString &token, const evVector &token_value);
88  int WriteToken(const evString &token, const evString &token_value);
89  int WriteToken(const evString &token, const evVersion &token_value);
90 
91  int ReadHeader(evString &class_name);
92  int WriteHeader(const evString &class_name);
93 
94 protected:
95  FILE *FilePointer;
96  int Mode;
97 
98  int ReadTokenLabel(const evString &token);
99  int WriteTokenLabel(const evString &token);
100  int ReadTokenEndOfLine(void);
101  int WriteTokenEndOfLine(void);
102 
103 private:
106 
107 };
108 
109 
111 {
112  return(this->Filename);
113 }
114 
115 
117 {
118  return(this->FileVersion);
119 }
120 
121 
122 inline int evFile::GetMode(void)
123 {
124  return(this->Mode);
125 }
126 
127 
128 inline FILE *evFile::GetFilePointer(void)
129 {
130  return(this->FilePointer);
131 }
132 
133 
134 inline int evFile::IsOpen(void)
135 {
136  return(this->FilePointer != NULL);
137 }
138 
139 
140 #endif
int GetPosition(evFilePosition &file_position)
int Seek(const evFilePosition file_position)
Definition: evFile.h:44
evVersion GetFileVersion(void)
Definition: evFile.h:116
int SkipWhiteSpace(void)
int ReadHeader(evString &class_name)
long evFilePosition
Definition: evFile.h:41
virtual int SetBufferMode(const int mode)
int WriteHeader(const evString &class_name)
virtual int Flush(void)
int GetMode(void)
Definition: evFile.h:122
int ReadToken(const evString &token)
int WriteToken(const evString &token)
int ReadTokenEndOfLine(void)
int Open(const evString &filename, const char *mode)
virtual ~evFile(void)
Definition: evVector.h:36
virtual const evString GetClassName(void) const
Definition: evFile.h:50
Definition: evAddress.h:37
FILE * GetFilePointer(void)
Definition: evFile.h:128
Definition: evDataObject.h:31
Definition: evVersion.h:40
int WriteTokenEndOfLine(void)
int ReadChar(char &value)
virtual int Close(void)
evFile(void)
int ReadTokenLabel(const evString &token)
evVersion FileVersion
Definition: evFile.h:105
evString Filename
Definition: evFile.h:104
int WriteChar(const char value)
int Mode
Definition: evFile.h:96
int WriteTokenLabel(const evString &token)
Definition: evString.h:30
evString GetFilename(void)
Definition: evFile.h:110
FILE * FilePointer
Definition: evFile.h:95
int IsOpen(void)
Definition: evFile.h:134