thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
CFile.h
1// -*- C++ -*-
2#ifndef THEPEG_CFile_H
3#define THEPEG_CFile_H
4//
5// This is the declaration of the CFile class.
6//
7
8#include "Exception.h"
9
10namespace ThePEG {
11
15class CFile {
16
17public:
18
22 enum FileType {
23 undefined, plain, pipe, gzip, bzip2
24 };
25
26public:
27
33 CFile(): file(0), fileType(undefined) {}
34
38 CFile(string filename, string mode)
39 : file(0), fileType(undefined) {
40 open(filename, mode);
41 }
42
46 ~CFile() {}
48
52 void open(string filename, string mode);
53
57 void close();
58
62 operator void * () const {
63 return fileType != undefined? file: 0;
64 }
65
69 bool operator!() const {
70 return !(operator void * ());
71 }
72
76 char * gets(char * s, int size);
77
81 int puts(const char * s);
82
86 int getc();
87
91 int putc(int c);
92
96 int ungetc(int c);
97
101 size_t read(void *ptr, size_t size, size_t nmemb = 1);
102
106 size_t write(const void *ptr, size_t size, size_t nmemb = 1);
107
108private:
109
113 void * file;
114
119
120public:
121
124 class FileError: public Exception {};
127};
128
129}
130
131
132#endif /* THEPEG_CFile_H */
Here is the documentation of the CFile class.
Definition: CFile.h:15
~CFile()
The destructor.
Definition: CFile.h:46
bool operator!() const
Exist for file existance.
Definition: CFile.h:69
char * gets(char *s, int size)
Get characters.
FileType
Type of the file.
Definition: CFile.h:22
void * file
Pointer to the file.
Definition: CFile.h:113
int getc()
Get the current character.
int ungetc(int c)
Pushes the byte specified by c (converted to an unsigned char) back onto the stream.
size_t write(const void *ptr, size_t size, size_t nmemb=1)
Write.
CFile()
The default constructor.
Definition: CFile.h:33
int putc(int c)
Set the current character.
int puts(const char *s)
Set characters.
CFile(string filename, string mode)
Create a CFile given a file name and a mode.
Definition: CFile.h:38
FileType fileType
Type of the file.
Definition: CFile.h:118
void close()
Close the file.
size_t read(void *ptr, size_t size, size_t nmemb=1)
Read.
void open(string filename, string mode)
Open the file.
Exception is the base class for all exceptions to be used in ThePEG.
Definition: Exception.h:44
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28