thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Utilities
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
15
#include "
ThePEG/Config/ThePEG.h
"
16
#include "CFileLineReader.fh"
17
#include "CFile.h"
18
#include <cstdio>
19
#include <string>
20
21
namespace
ThePEG
{
22
42
class
CFileLineReader
{
43
44
public
:
45
51
CFileLineReader
();
52
61
CFileLineReader
(
string
filename,
int
len =
defsize
);
62
66
~CFileLineReader
();
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
140
CFileLineReader
&
operator>>
(
long
& l);
141
145
CFileLineReader
&
operator>>
(
int
& i);
146
150
CFileLineReader
&
operator>>
(
unsigned
long
& l);
151
155
CFileLineReader
&
operator>>
(
unsigned
int
& i);
156
160
CFileLineReader
&
operator>>
(
double
& d);
161
165
CFileLineReader
&
operator>>
(
float
& f);
166
170
CFileLineReader
&
operator>>
(std::string & s);
172
173
private
:
174
178
CFile
file
;
179
183
int
bufflen
;
184
188
char
*
buff
;
189
193
char
*
pos
;
194
198
bool
bad
;
199
203
static
const
int
defsize
= 1024;
204
205
private
:
206
210
CFileLineReader
(
const
CFileLineReader
&);
211
216
CFileLineReader
&
operator=
(
const
CFileLineReader
&) =
delete
;
217
218
};
219
220
}
221
222
#endif
/* THEPEG_CFileLineReader_H */
ThePEG.h
This is the main config header file for ThePEG.
ThePEG::CFileLineReader
CFileLineReader is a wrapper around a standard C FILE stream.
Definition:
CFileLineReader.h:42
ThePEG::CFileLineReader::CFileLineReader
CFileLineReader()
The default constructor.
ThePEG::CFileLineReader::getc
char getc()
Return the next character of the line-buffer.
ThePEG::CFileLineReader::operator>>
CFileLineReader & operator>>(int &i)
Read an int from the line buffer.
ThePEG::CFileLineReader::bufflen
int bufflen
The length of the line buffer.
Definition:
CFileLineReader.h:183
ThePEG::CFileLineReader::close
void close()
If the file was opened from within this object, close it.
ThePEG::CFileLineReader::operator>>
CFileLineReader & operator>>(unsigned long &l)
Read an unsigned long from the line buffer.
ThePEG::CFileLineReader::buff
char * buff
The line buffer.
Definition:
CFileLineReader.h:188
ThePEG::CFileLineReader::find
bool find(string str) const
Check if a given string is present in the current line buffer.
ThePEG::CFileLineReader::operator>>
CFileLineReader & operator>>(double &d)
Read a double from the line buffer.
ThePEG::CFileLineReader::CFileLineReader
CFileLineReader(const CFileLineReader &)
The copy constructor is private and not implemented.
ThePEG::CFileLineReader::operator>>
CFileLineReader & operator>>(unsigned int &i)
Read an unsigned int from the line buffer.
ThePEG::CFileLineReader::readline
bool readline()
Read a line from the underlying c-file into the line buffer.
ThePEG::CFileLineReader::operator>>
CFileLineReader & operator>>(float &f)
Read a float from the line buffer.
ThePEG::CFileLineReader::cFile
CFile cFile() const
Return the underlying c-file.
ThePEG::CFileLineReader::skip
bool skip(char c)
Scan forward up and until the first occurrence of the given character.
ThePEG::CFileLineReader::operator>>
CFileLineReader & operator>>(long &l)
Read a long from the line buffer.
ThePEG::CFileLineReader::defsize
static const int defsize
The default size of the buffer.
Definition:
CFileLineReader.h:203
ThePEG::CFileLineReader::pos
char * pos
The current position in the line buffer.
Definition:
CFileLineReader.h:193
ThePEG::CFileLineReader::CFileLineReader
CFileLineReader(string filename, int len=defsize)
Constructor taking a filename as argument.
ThePEG::CFileLineReader::bad
bool bad
The current state is bad if a read has failed.
Definition:
CFileLineReader.h:198
ThePEG::CFileLineReader::operator=
CFileLineReader & operator=(const CFileLineReader &)=delete
The assignment operator is private and must never be called.
ThePEG::CFileLineReader::operator!
bool operator!()
Return true if a previous read failed.
ThePEG::CFileLineReader::getline
string getline() const
Return a string containing what is left of the line buffer.
ThePEG::CFileLineReader::resetline
void resetline()
Undo reading from the current line, ie.
ThePEG::CFileLineReader::open
void open(string filename)
Initialize with a filename.
ThePEG::CFileLineReader::operator>>
CFileLineReader & operator>>(std::string &s)
Read a (whitespace delimited) string from the line buffer.
ThePEG::CFileLineReader::~CFileLineReader
~CFileLineReader()
The destructor.
ThePEG::CFileLineReader::file
CFile file
The c-file to be read from.
Definition:
CFileLineReader.h:178
ThePEG::CFile
Here is the documentation of the CFile class.
Definition:
CFile.h:15
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6