thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
CFileLineReader.h
1// -*- C++ -*-
2//
3// CFileLineReader.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 1999-2019 Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef THEPEG_CFileLineReader_H
10#define THEPEG_CFileLineReader_H
11//
12// This is the declaration of the CFileLineReader class.
13//
14
16#include "CFileLineReader.fh"
17#include "CFile.h"
18#include <cstdio>
19#include <string>
20
21namespace ThePEG {
22
43
44public:
45
52
61 CFileLineReader(string filename, int len = defsize);
62
68
78 void open(string filename);
79
83 void close();
85
89 bool readline();
90
96 void resetline();
97
101 string getline() const;
102
106 CFile cFile() const;
107
111 operator void *();
112
116 bool operator!();
117
123 bool skip(char c);
124
128 bool find(string str) const;
129
135 char getc();
136
141
146
150 CFileLineReader & operator>>(unsigned long & l);
151
155 CFileLineReader & operator>>(unsigned int & i);
156
161
166
170 CFileLineReader & operator>>(std::string & s);
172
173private:
174
179
184
188 char * buff;
189
193 char * pos;
194
198 bool bad;
199
203 static const int defsize = 1024;
204
205private:
206
211
217
218};
219
220}
221
222#endif /* THEPEG_CFileLineReader_H */
This is the main config header file for ThePEG.
CFileLineReader is a wrapper around a standard C FILE stream.
CFileLineReader()
The default constructor.
char getc()
Return the next character of the line-buffer.
CFileLineReader & operator>>(int &i)
Read an int from the line buffer.
int bufflen
The length of the line buffer.
void close()
If the file was opened from within this object, close it.
CFileLineReader & operator>>(unsigned long &l)
Read an unsigned long from the line buffer.
char * buff
The line buffer.
bool find(string str) const
Check if a given string is present in the current line buffer.
CFileLineReader & operator>>(double &d)
Read a double from the line buffer.
CFileLineReader(const CFileLineReader &)
The copy constructor is private and not implemented.
CFileLineReader & operator>>(unsigned int &i)
Read an unsigned int from the line buffer.
bool readline()
Read a line from the underlying c-file into the line buffer.
CFileLineReader & operator>>(float &f)
Read a float from the line buffer.
CFile cFile() const
Return the underlying c-file.
bool skip(char c)
Scan forward up and until the first occurrence of the given character.
CFileLineReader & operator>>(long &l)
Read a long from the line buffer.
static const int defsize
The default size of the buffer.
char * pos
The current position in the line buffer.
CFileLineReader(string filename, int len=defsize)
Constructor taking a filename as argument.
bool bad
The current state is bad if a read has failed.
CFileLineReader & operator=(const CFileLineReader &)=delete
The assignment operator is private and must never be called.
bool operator!()
Return true if a previous read failed.
string getline() const
Return a string containing what is left of the line buffer.
void resetline()
Undo reading from the current line, ie.
void open(string filename)
Initialize with a filename.
CFileLineReader & operator>>(std::string &s)
Read a (whitespace delimited) string from the line buffer.
~CFileLineReader()
The destructor.
CFile file
The c-file to be read from.
Here is the documentation of the CFile class.
Definition: CFile.h:15
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28