a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
LhcoParser.cpp
Go to the documentation of this file.
1/*
2 * LhcoParser.cpp
3 *
4 * Created on: Jun 29, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 * Copyright 2012 Ben O'Leary
7 *
8 * This file is part of LesHouchesParserClasses, released under the
9 * GNU General Public License. Please see the accompanying
10 * README.LHPC_CPP.txt file for a full list of files, brief documentation
11 * on how to use these classes, and further details on the license.
12 */
13
14#include "LHCO.hpp"
15
16namespace LHPC
17{
18 LhcoParser::LhcoParser( std::string const eventFileName,
19 bool const isVerbose ) :
20 isVerbose( isVerbose ),
21 fileParser( "#",
22 this->isVerbose ),
23 currentEvent( this->isVerbose ),
24 fileIsOpenAndNotYetAtEndOfFile( false ),
25 currentLine( "" ),
26 lineNumber( -1 )
27 {
28 if( !(eventFileName.empty()) )
29 {
30 openFile( eventFileName );
31 }
32 }
33
35 {
36 // does nothing.
37 }
38
39
40 bool
42 // this reads in the next event in the event file, & returns true if
43 // successful.
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 }
86
87}
bool readJustNextValidLine(std::string &stringToFill)
CommentedTextParser & closeFile()
int recordLine(std::string const &lineAsString)
Definition: LhcoEvent.cpp:82
BOL::CommentedTextParser fileParser
Definition: LhcoParser.hpp:46
std::string currentLine
Definition: LhcoParser.hpp:49
bool readNextEvent()
Definition: LhcoParser.cpp:41
bool openFile(std::string const &eventFileName)
Definition: LhcoParser.hpp:65
bool fileIsOpenAndNotYetAtEndOfFile
Definition: LhcoParser.hpp:48
LHCO::LhcoEvent currentEvent
Definition: LhcoParser.hpp:47
LhcoParser(std::string const eventFileName="", bool const isVerbose=true)
Definition: LhcoParser.cpp:18