master
a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models
Loading...
Searching...
No Matches
JustSingleValue.hpp
Go to the documentation of this file.
1
/*
2
* JustSingleValue.hpp
3
*
4
* Created on: Feb 8, 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
#ifndef JUSTSINGLEVALUE_HPP_
15
#define JUSTSINGLEVALUE_HPP_
16
17
#include "
InterpreterTemplate.hpp
"
18
19
namespace
LHPC
20
{
21
namespace
SLHA
22
{
23
namespace
InterpreterClass
24
{
25
// this template class interprets SLHA blocks that have a single
26
// ValueClass value.
27
template
<
class
ValueClass >
28
class
JustSingleValue
:
public
InterpreterTemplate
< ValueClass >
29
{
30
public
:
31
JustSingleValue
();
32
virtual
33
~JustSingleValue
();
34
35
ValueClass&
36
operator()
();
37
// this returns the stored ValueType.
38
ValueClass
const
&
39
operator()
()
const
;
40
// const version of above.
41
bool
42
hasEntry
()
const
;
43
// this returns true if there is an entry.
44
virtual
std::string
const
&
45
getAsString
();
46
// see base version's description.
47
virtual
void
48
clearEntries
();
49
// derived classes should clear their interpreted values.
50
51
52
protected
:
53
ValueClass
storedValue
;
54
bool
entryRecorded
;
55
56
virtual
void
57
interpretCurrentStringBlock
();
58
};
59
60
61
62
template
<
class
ValueClass >
63
inline
64
JustSingleValue< ValueClass >::JustSingleValue
() :
65
InterpreterTemplate
< ValueClass >(),
66
storedValue(),
67
entryRecorded( false )
68
{
69
// just an initialization list.
70
}
71
72
template
<
class
ValueClass >
73
inline
74
JustSingleValue< ValueClass >::~JustSingleValue
()
75
{
76
// does nothing.
77
}
78
79
80
template
<
class
ValueClass >
81
inline
ValueClass&
82
JustSingleValue< ValueClass >::operator()
()
83
// this returns the stored ValueType.
84
{
85
return
storedValue;
86
}
87
88
template
<
class
ValueClass >
89
inline
ValueClass
const
&
90
JustSingleValue< ValueClass >::operator()
() const
91
// const version of above.
92
{
93
return
storedValue;
94
}
95
96
template
<
class
ValueClass >
97
inline
bool
98
JustSingleValue< ValueClass >::hasEntry
() const
99
// this returns true if there is an entry.
100
{
101
return
entryRecorded;
102
}
103
104
template
<
class
ValueClass >
105
inline
std::string
const
&
106
JustSingleValue< ValueClass >::getAsString
()
107
// see base version's description.
108
{
109
if
( hasEntry() )
110
{
111
this->stringInterpretation.assign(
" "
);
112
// 6 spaces.
113
this->stringInterpretation.append( this->valueToPrintingString(
114
storedValue ) );
115
this->stringInterpretation.append(
"\n"
);
116
}
117
else
118
{
119
this->stringInterpretation.clear();
120
}
121
return
this->stringInterpretation;
122
}
123
124
template
<
class
ValueClass >
125
inline
void
126
JustSingleValue< ValueClass >::clearEntries
()
127
// this ensures that the entry at soughtIndex exists, filling out with
128
// copies of defaultUnsetValue, & returns it.
129
{
130
entryRecorded =
false
;
131
storedValue = this->defaultUnsetValue;
132
}
133
134
template
<
class
ValueClass >
135
inline
void
136
JustSingleValue< ValueClass >::interpretCurrentStringBlock
()
137
{
138
entryRecorded =
false
;
139
// first it is assumed that this update is on an empty block.
140
for
(
int
whichLine( 1 );
141
( !entryRecorded
142
&&
143
( this->currentStringBlock->getNumberOfBodyLines()
144
>= whichLine ) );
145
++whichLine )
146
// each line after the header (if any) is looked at.
147
{
148
this->currentWord.assign(
BOL::StringParser::trimFromFrontAndBack
(
149
(*(this->currentStringBlock))[ whichLine ].first,
150
" \t\r\n"
) );
151
if
( !(this->currentWord.empty()) )
152
// if there is a non-empty line...
153
{
154
storedValue = this->stringToValue( this->currentWord );
155
entryRecorded =
true
;
156
}
157
}
158
}
159
160
}
161
162
}
163
164
}
165
166
#endif
/* JUSTSINGLEVALUE_HPP_ */
InterpreterTemplate.hpp
BOL::StringParser::trimFromFrontAndBack
static std::string trimFromFrontAndBack(std::string const &stringToTrim, std::string const &charsToTrim=whitespaceAndNewlineChars)
Definition
StringParser.hpp:502
LHPC::SLHA::InterpreterClass::InterpreterTemplate
Definition
InterpreterTemplate.hpp:31
LHPC::SLHA::InterpreterClass::JustSingleValue
Definition
JustSingleValue.hpp:29
LHPC::SLHA::InterpreterClass::JustSingleValue::hasEntry
bool hasEntry() const
Definition
JustSingleValue.hpp:98
LHPC::SLHA::InterpreterClass::JustSingleValue::clearEntries
virtual void clearEntries()
Definition
JustSingleValue.hpp:126
LHPC::SLHA::InterpreterClass::JustSingleValue::entryRecorded
bool entryRecorded
Definition
JustSingleValue.hpp:54
LHPC::SLHA::InterpreterClass::JustSingleValue::~JustSingleValue
virtual ~JustSingleValue()
Definition
JustSingleValue.hpp:74
LHPC::SLHA::InterpreterClass::JustSingleValue::storedValue
ValueClass storedValue
Definition
JustSingleValue.hpp:53
LHPC::SLHA::InterpreterClass::JustSingleValue::operator()
ValueClass & operator()()
Definition
JustSingleValue.hpp:82
LHPC::SLHA::InterpreterClass::JustSingleValue::getAsString
virtual std::string const & getAsString()
Definition
JustSingleValue.hpp:106
LHPC::SLHA::InterpreterClass::JustSingleValue::interpretCurrentStringBlock
virtual void interpretCurrentStringBlock()
Definition
JustSingleValue.hpp:136
LHPC::SLHA::InterpreterClass::JustSingleValue::JustSingleValue
JustSingleValue()
Definition
JustSingleValue.hpp:64
LHPC
Definition
FourMomentum.hpp:24
LHPC
include
SLHA
BlockClasses
InterpreterClasses
JustSingleValue.hpp
Generated on Tue Aug 4 2026 for $\texttt{HEPfit}$ using
1.9.8