a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
LHPC::LhcoParser Class Reference

#include <LhcoParser.hpp>

Detailed Description

Definition at line 24 of file LhcoParser.hpp.

Public Member Functions

LHCO::LhcoEvent const & getEvent () const
 
 LhcoParser (std::string const eventFileName="", bool const isVerbose=true)
 
bool openFile (std::string const &eventFileName)
 
bool readNextEvent ()
 
 ~LhcoParser ()
 

Protected Member Functions

bool lookForFirstEvent ()
 

Protected Attributes

LHCO::LhcoEvent currentEvent
 
std::string currentLine
 
bool fileIsOpenAndNotYetAtEndOfFile
 
BOL::CommentedTextParser fileParser
 
bool isVerbose
 
int lineNumber
 

Constructor & Destructor Documentation

◆ LhcoParser()

LHPC::LhcoParser::LhcoParser ( std::string const  eventFileName = "",
bool const  isVerbose = true 
)

Definition at line 18 of file LhcoParser.cpp.

19 :
21 fileParser( "#",
22 this->isVerbose ),
23 currentEvent( this->isVerbose ),
25 currentLine( "" ),
26 lineNumber( -1 )
27 {
28 if( !(eventFileName.empty()) )
29 {
30 openFile( eventFileName );
31 }
32 }
BOL::CommentedTextParser fileParser
Definition: LhcoParser.hpp:46
std::string currentLine
Definition: LhcoParser.hpp:49
bool openFile(std::string const &eventFileName)
Definition: LhcoParser.hpp:65
bool fileIsOpenAndNotYetAtEndOfFile
Definition: LhcoParser.hpp:48
LHCO::LhcoEvent currentEvent
Definition: LhcoParser.hpp:47

◆ ~LhcoParser()

LHPC::LhcoParser::~LhcoParser ( )

Definition at line 34 of file LhcoParser.cpp.

35 {
36 // does nothing.
37 }

Member Function Documentation

◆ getEvent()

LHCO::LhcoEvent const & LHPC::LhcoParser::getEvent ( ) const
inline

Definition at line 83 of file LhcoParser.hpp.

85 {
86 return currentEvent;
87 }

◆ lookForFirstEvent()

bool LHPC::LhcoParser::lookForFirstEvent ( )
inlineprotected

Definition at line 90 of file LhcoParser.hpp.

95 {
97 {
98 bool notYetFoundFirstLineOfAnEvent( true );
100 &&
101 notYetFoundFirstLineOfAnEvent )
102 {
106 {
107 notYetFoundFirstLineOfAnEvent
109 // stringToDouble(...) takes the 1st number found in the string.
110 }
111 }
112 // this loop ends as soon as a line starting with 0 was found, or if the
113 // end of the file was reached.
114 }
116 }
bool readJustNextValidLine(std::string &stringToFill)
static double stringToDouble(std::string const &stringToInterpret)

◆ openFile()

bool LHPC::LhcoParser::openFile ( std::string const &  eventFileName)
inline

Definition at line 65 of file LhcoParser.hpp.

69 {
72 {
75 {
77 }
78 }
80 }
bool openFile(std::string const &fileName)
int recordLine(std::string const &lineAsString)
Definition: LhcoEvent.cpp:82
bool lookForFirstEvent()
Definition: LhcoParser.hpp:90

◆ readNextEvent()

bool LHPC::LhcoParser::readNextEvent ( )

Definition at line 41 of file LhcoParser.cpp.

44 {
46 {
48 lineNumber = -1;
49 // this is so that the following while loop doesn't terminate until the
50 // *next* "line 0", which indicates the start of the next event.
52 &&
53 ( 0 != lineNumber ) )
54 {
58 {
60 if( ( 0 > lineNumber )
61 &&
62 isVerbose )
63 {
64 std::cout
65 << std::endl
66 << "LHPC::warning! LHCO parser ignoring invalid line \""
67 << currentLine << "\"";
68 std::cout << std::endl;
69 }
70 }
71 }
72 // at this point, either a new "line 0" has been found, priming the next
73 // event, or the last line of the file has been read. if the file has
74 // been read to the end, it is closed:
76 {
78 }
79 return true;
80 }
81 else
82 {
83 return false;
84 }
85 }
CommentedTextParser & closeFile()

Member Data Documentation

◆ currentEvent

LHCO::LhcoEvent LHPC::LhcoParser::currentEvent
protected

Definition at line 47 of file LhcoParser.hpp.

◆ currentLine

std::string LHPC::LhcoParser::currentLine
protected

Definition at line 49 of file LhcoParser.hpp.

◆ fileIsOpenAndNotYetAtEndOfFile

bool LHPC::LhcoParser::fileIsOpenAndNotYetAtEndOfFile
protected

Definition at line 48 of file LhcoParser.hpp.

◆ fileParser

BOL::CommentedTextParser LHPC::LhcoParser::fileParser
protected

Definition at line 46 of file LhcoParser.hpp.

◆ isVerbose

bool LHPC::LhcoParser::isVerbose
protected

Definition at line 45 of file LhcoParser.hpp.

◆ lineNumber

int LHPC::LhcoParser::lineNumber
protected

Definition at line 50 of file LhcoParser.hpp.


The documentation for this class was generated from the following files: