File indexing completed on 2026-08-06 09:38:31
0001
0002 #ifndef THEPEG_CFile_H
0003 #define THEPEG_CFile_H
0004
0005
0006
0007
0008 #include "Exception.h"
0009
0010 namespace ThePEG {
0011
0012
0013
0014
0015 class CFile {
0016
0017 public:
0018
0019
0020
0021
0022 enum FileType {
0023 undefined, plain, pipe, gzip, bzip2
0024 };
0025
0026 public:
0027
0028
0029
0030
0031
0032
0033 CFile(): file(0), fileType(undefined) {}
0034
0035
0036
0037
0038 CFile(string filename, string mode)
0039 : file(0), fileType(undefined) {
0040 open(filename, mode);
0041 }
0042
0043
0044
0045
0046 ~CFile() {}
0047
0048
0049
0050
0051
0052 void open(string filename, string mode);
0053
0054
0055
0056
0057 void close();
0058
0059
0060
0061
0062 operator void * () const {
0063 return fileType != undefined? file: 0;
0064 }
0065
0066
0067
0068
0069 bool operator!() const {
0070 return !(operator void * ());
0071 }
0072
0073
0074
0075
0076 char * gets(char * s, int size);
0077
0078
0079
0080
0081 int puts(const char * s);
0082
0083
0084
0085
0086 int getc();
0087
0088
0089
0090
0091 int putc(int c);
0092
0093
0094
0095
0096 int ungetc(int c);
0097
0098
0099
0100
0101 size_t read(void *ptr, size_t size, size_t nmemb = 1);
0102
0103
0104
0105
0106 size_t write(const void *ptr, size_t size, size_t nmemb = 1);
0107
0108 private:
0109
0110
0111
0112
0113 void * file;
0114
0115
0116
0117
0118 FileType fileType;
0119
0120 public:
0121
0122
0123
0124 class FileError: public Exception {};
0125
0126
0127 };
0128
0129 }
0130
0131
0132 #endif