6 #ifndef HEPMC_ATTRIBUTE_H 7 #define HEPMC_ATTRIBUTE_H 27 #include "HepMC/Common.h" 87 virtual bool to_string(
string &att)
const = 0;
131 #ifdef HEPMC_HAS_CXX11 132 m_val = std::stoi(att);
134 m_val = atoi( att.c_str() );
141 #ifdef HEPMC_HAS_CXX11 142 att = std::to_string(
m_val);
145 sprintf(buf,
"%23i",
m_val);
182 #ifdef HEPMC_HAS_CXX11 183 m_val = std::stoi(att);
185 m_val = atoi( att.c_str() );
192 #ifdef HEPMC_HAS_CXX11 193 att = std::to_string(
m_val);
196 sprintf(buf,
"%23li",
m_val);
235 #ifdef HEPMC_HAS_CXX11 236 m_val = std::stod(att);
238 m_val = atof( att.c_str() );
245 std::ostringstream oss;
246 oss << std::setprecision(std::numeric_limits<double>::digits10)
284 #ifdef HEPMC_HAS_CXX11 285 m_val = std::stof(att);
287 m_val = float(atof( att.c_str() ));
294 std::ostringstream oss;
295 oss << std::setprecision(std::numeric_limits<float>::digits10)
const string & unparsed_string() const
Get unparsed string.
bool m_is_parsed
Is this attribute parsed?
bool from_string(const string &att)
Implementation of Attribute::from_string.
virtual bool init(const GenEvent &)
Optionally initialize the attribute after from_string.
void set_value(long l)
set the value associated to this Attribute.
FloatAttribute()
Default constructor.
bool from_string(const string &att)
Implementation of Attribute::from_string.
Attribute that holds a real number as a double.
Attribute that holds an Integer implemented as an int.
float m_val
Attribute value.
StringAttribute(const string &st)
String-based constructor.
string m_string
Raw (unparsed) string.
Stores run-related information.
bool from_string(const string &att)
Implementation of Attribute::from_string.
double m_val
Attribute value.
LongAttribute(long val)
Constructor initializing attribute value.
long value() const
get the value associated to this Attribute.
void set_value(double d)
set the value associated to this Attribute.
Attribute that holds a real number as a float.
virtual ~Attribute()
Virtual destructor.
void set_unparsed_string(const string &st)
Set unparsed string.
Stores event-related information.
virtual bool to_string(string &att) const =0
Fill string from class content.
bool from_string(const string &att)
Implementation of Attribute::from_string.
virtual bool init(const GenRunInfo &)
Optionally initialize the attribute after from_string.
void set_value(float f)
set the value associated to this Attribute.
float value() const
get the value associated to this Attribute.
bool to_string(string &att) const
Implementation of Attribute::to_string.
IntAttribute(int val)
Constructor initializing attribute value.
StringAttribute()
Default constructor - empty string.
Attribute(const string &st)
Protected constructor that allows to set string.
bool to_string(string &att) const
Implementation of Attribute::to_string.
void set_value(string s)
set the value associated to this Attribute.
void set_value(int i)
set the value associated to this Attribute.
bool to_string(string &att) const
Implementation of Attribute::to_string.
LongAttribute()
Default constructor.
DoubleAttribute(double val)
Constructor initializing attribute value.
Attribute()
Default constructor.
DoubleAttribute()
Default constructor.
FloatAttribute(float val)
Constructor initializing attribute value.
double value() const
get the value associated to this Attribute.
bool from_string(const string &att)
Implementation of Attribute::from_string.
IntAttribute()
Default constructor.
virtual bool from_string(const string &att)=0
Fill class content from string.
int value() const
get the value associated to this Attribute.
long m_val
Attribute value.
bool to_string(string &att) const
Implementation of Attribute::to_string.
Base class for all attributes.
Definition of template class SmartPointer.
int m_val
Attribute value.
void set_is_parsed(bool flag)
Set is_parsed flag.
bool to_string(string &att) const
Implementation of Attribute::to_string.
Attribute that holds a string.
bool is_parsed()
Check if this attribute is parsed.
string value() const
get the value associated to this Attribute.