6 #ifndef HEPMC3_ATTRIBUTE_H 7 #define HEPMC3_ATTRIBUTE_H 29 #include "HepMC3/GenParticle_fwd.h" 30 #include "HepMC3/GenVertex_fwd.h" 77 virtual bool from_string(
const std::string & att) = 0;
95 virtual bool to_string(std::string &att)
const = 0;
168 m_val = atoi( att.c_str() );
174 att = std::to_string(
m_val);
209 m_val = atol( att.c_str() );
215 att = std::to_string(
m_val);
252 m_val = atof( att.c_str() );
258 std::ostringstream oss;
259 oss << std::setprecision(std::numeric_limits<double>::digits10)
297 m_val = float(atof( att.c_str() ));
303 std::ostringstream oss;
304 oss << std::setprecision(std::numeric_limits<float>::digits10)
400 att = std::to_string(
m_val);
435 m_val = atoll( att.c_str() );
441 att = std::to_string(
m_val);
478 m_val = strtold( att.c_str(),NULL);
484 std::ostringstream oss;
485 oss << std::setprecision(std::numeric_limits<long double>::digits10)
525 m_val = strtoul(att.c_str(), NULL, 0);
531 att = std::to_string(
m_val);
568 m_val = strtoul(att.c_str(), NULL, 0);
574 att = std::to_string(
m_val);
610 m_val = strtoull(att.c_str(), NULL, 0);
616 att = std::to_string(
m_val);
650 if (att.size()!=1)
return false;
651 if (att==std::string(
"1")) {
m_val =
true;
return true;}
652 if (att==std::string(
"0")) {
m_val =
false;
return true;}
658 att = std::to_string(
m_val);
695 std::stringstream datastream(att);
696 while (datastream >> datafoo)
m_val.push_back(datafoo);
703 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
740 std::stringstream datastream(att);
741 while (datastream >> datafoo)
m_val.push_back(datafoo);
748 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
786 std::stringstream datastream(att);
787 while (datastream >> datafoo)
m_val.push_back(datafoo);
794 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
799 std::vector<long double>
value()
const {
833 std::stringstream datastream(att);
834 while (datastream >> datafoo)
m_val.push_back(datafoo);
841 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
846 std::vector<long long>
value()
const {
876 unsigned int datafoo;
878 std::stringstream datastream(att);
879 while (datastream >> datafoo)
m_val.push_back(datafoo);
886 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
891 std::vector<unsigned int>
value()
const {
921 unsigned long datafoo;
923 std::stringstream datastream(att);
924 while (datastream >> datafoo)
m_val.push_back(datafoo);
931 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
936 std::vector<unsigned long>
value()
const {
967 unsigned long long datafoo;
969 std::stringstream datastream(att);
970 while (datastream >> datafoo)
m_val.push_back(datafoo);
977 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
982 std::vector<unsigned long long>
value()
const {
987 void set_value(
const std::vector<unsigned long long>& i) {
992 std::vector<unsigned long long>
m_val;
1014 std::stringstream datastream(att);
1015 while (datastream >> datafoo)
m_val.push_back(datafoo);
1022 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
1059 std::stringstream datastream(att);
1060 while (datastream >> datafoo)
m_val.push_back(datafoo);
1067 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
1104 std::stringstream datastream(att);
1105 while (datastream >> datafoo)
m_val.push_back(datafoo);
1112 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
1148 size_t posb = att.find_first_not_of(
' ');
1150 size_t pose = att.find_first_of(
' ', posb);
1151 m_val.push_back(att.substr(posb, pose - posb));
1152 posb = att.find_first_not_of(
' ', pose);
1153 }
while (posb != std::string::npos);
1160 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=a;}
1165 std::vector<std::string>
value()
const {
VectorULongLongAttribute(std::vector< unsigned long long > val)
Constructor initializing attribute value.
LongAttribute(long val)
Constructor initializing attribute value.
std::vector< long long > value() const
get the value associated to this Attribute.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
void set_value(const double &d)
set the value associated to this Attribute.
virtual bool to_string(std::string &att) const =0
Fill string from class content.
VectorLongIntAttribute(std::vector< long int > val)
Constructor initializing attribute value.
VectorIntAttribute(std::vector< int > val)
Constructor initializing attribute value.
Attribute that holds an unsigned long long.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
unsigned int value() const
get the value associated to this Attribute.
void set_value(const std::vector< char > &i)
set the value associated to this Attribute.
LongAttribute()
Default constructor.
VectorFloatAttribute()
Default constructor.
UIntAttribute()
Default constructor.
std::vector< std::string > value() const
get the value associated to this Attribute.
ULongLongAttribute(unsigned long long val)
Constructor initializing attribute value.
std::vector< double > m_val
Attribute value.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
VectorStringAttribute(std::vector< std::string > val)
Constructor initializing attribute value.
const std::string & unparsed_string() const
Get unparsed string.
VectorLongDoubleAttribute(std::vector< long double > val)
Constructor initializing attribute value.
FloatAttribute(float val)
Constructor initializing attribute value.
void set_value(const bool &i)
set the value associated to this Attribute.
void set_value(const std::vector< long int > &i)
set the value associated to this Attribute.
void set_unparsed_string(const std::string &st)
Set unparsed string.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
Attribute that holds a vector of FPs of type double.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
std::vector< std::string > m_val
Attribute value.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
BoolAttribute()
Default constructor.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Attribute that holds a vector of unsigned long longegers of type unsigned long long.
Attribute that holds an unsigned int.
Attribute that holds a vector of charegers of type char.
Attribute(const std::string &st)
Protected constructor that allows to set string.
void set_value(const std::vector< double > &i)
set the value associated to this Attribute.
std::vector< double > value() const
get the value associated to this Attribute.
VectorUIntAttribute(std::vector< unsigned int > val)
Constructor initializing attribute value.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
GenParticlePtr particle()
Attribute that holds a real number as a float.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Stores vertex-related information.
LongLongAttribute(long long val)
Constructor initializing attribute value.
VectorLongIntAttribute()
Default constructor.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
LongDoubleAttribute(long double val)
Constructor initializing attribute value.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
ULongAttribute()
Default constructor.
Attribute that holds a vector of FPs of type string.
unsigned int m_val
Attribute value.
long m_val
Attribute value.
void set_value(const std::vector< unsigned int > &i)
set the value associated to this Attribute.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Stores run-related information.
long value() const
get the value associated to this Attribute.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
void set_value(const char &i)
set the value associated to this Attribute.
VectorCharAttribute()
Default constructor.
VectorLongLongAttribute(std::vector< long long > val)
Constructor initializing attribute value.
ConstGenVertexPtr vertex() const
Attribute that holds a vector of integers of type int.
bool m_val
Attribute value.
virtual bool init()
Optionally initialize the attribute after from_string.
Stores particle-related information.
void set_value(const int &i)
set the value associated to this Attribute.
Attribute that holds a string.
void set_value(const unsigned int &i)
set the value associated to this Attribute.
LongLongAttribute()
Default constructor.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
VectorDoubleAttribute()
Default constructor.
std::string value() const
get the value associated to this Attribute.
int value() const
get the value associated to this Attribute.
void set_value(const unsigned long &i)
set the value associated to this Attribute.
GenParticlePtr m_particle
controlling GenEvent object.
int m_val
Attribute value.
VectorDoubleAttribute(std::vector< double > val)
Constructor initializing attribute value.
float m_val
Attribute value.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
VectorIntAttribute()
Default constructor.
long long m_val
Attribute value.
Attribute that holds a vector of unsigned integers of type unsigned int.
ConstGenParticlePtr particle() const
Attribute that holds an Chareger implemented as an int.
Attribute that holds a vector of unsigned longegers of type unsigned long.
Attribute that holds an unsigned long.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
virtual bool from_string(const std::string &att)=0
Fill class content from string.
Attribute that holds a vector of long doubleegers of type long double.
std::vector< unsigned long > m_val
Attribute value.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
double m_val
Attribute value.
VectorULongAttribute()
Default constructor.
void set_value(const std::vector< int > &i)
set the value associated to this Attribute.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
Stores event-related information.
bool value() const
get the value associated to this Attribute.
DoubleAttribute()
Default constructor.
void set_value(const std::vector< std::string > &i)
set the value associated to this Attribute.
Attribute that holds a real number as a double.
char m_val
Attribute value.
long double value() const
get the value associated to this Attribute.
void set_value(const std::vector< unsigned long long > &i)
set the value associated to this Attribute.
unsigned long long m_val
Attribute value.
void set_value(const std::vector< long long > &i)
set the value associated to this Attribute.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
std::vector< long double > value() const
get the value associated to this Attribute.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
UIntAttribute(unsigned int val)
Constructor initializing attribute value.
CharAttribute(char val)
Constructor initializing attribute value.
const GenEvent * event() const
std::string m_string
Raw (unparsed) string.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
ULongLongAttribute()
Default constructor.
void set_value(const float &f)
set the value associated to this Attribute.
StringAttribute(const std::string &st)
String-based constructor.
std::vector< unsigned int > m_val
Attribute value.
void set_value(const unsigned long long &i)
set the value associated to this Attribute.
void set_value(const std::vector< long double > &i)
set the value associated to this Attribute.
std::vector< float > m_val
Attribute value.
long double m_val
Attribute value.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Attribute that holds a real number as a double.
Attribute that holds a vector of long longegers of type long long.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
unsigned long long value() const
get the value associated to this Attribute.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
virtual bool init(const GenRunInfo &)
Optionally initialize the attribute after from_string.
void set_value(const long &l)
set the value associated to this Attribute.
char value() const
get the value associated to this Attribute.
std::vector< char > value() const
get the value associated to this Attribute.
std::vector< char > m_val
Attribute value.
VectorStringAttribute()
Default constructor.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
std::vector< unsigned long long > value() const
get the value associated to this Attribute.
VectorUIntAttribute()
Default constructor.
VectorLongLongAttribute()
Default constructor.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
void set_value(const std::vector< unsigned long > &i)
set the value associated to this Attribute.
std::vector< float > value() const
get the value associated to this Attribute.
long long value() const
get the value associated to this Attribute.
IntAttribute(int val)
Constructor initializing attribute value.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
std::vector< long int > m_val
Attribute value.
GenVertexPtr m_vertex
Vertex to which assigned.
void set_is_parsed(bool flag)
Set is_parsed flag.
VectorLongDoubleAttribute()
Default constructor.
void set_value(const std::vector< float > &i)
set the value associated to this Attribute.
unsigned long value() const
get the value associated to this Attribute.
IntAttribute()
Default constructor.
BoolAttribute(bool val)
Constructor initializing attribute value.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Attribute that holds a vector of integers of type int.
std::vector< int > m_val
Attribute value.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
virtual ~Attribute()
Virtual destructor.
float value() const
get the value associated to this Attribute.
FloatAttribute()
Default constructor.
Attribute that holds an Integer implemented as an int.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
void set_value(const std::string &s)
set the value associated to this Attribute.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
std::vector< unsigned long long > m_val
Attribute value.
std::vector< unsigned long > value() const
get the value associated to this Attribute.
std::vector< long int > value() const
get the value associated to this Attribute.
ULongAttribute(unsigned long val)
Constructor initializing attribute value.
bool is_parsed() const
Check if this attribute is parsed.
double value() const
get the value associated to this Attribute.
VectorULongLongAttribute()
Default constructor.
std::vector< long long > m_val
Attribute value.
VectorFloatAttribute(std::vector< float > val)
Constructor initializing attribute value.
DoubleAttribute(double val)
Constructor initializing attribute value.
Attribute that holds an Integer implemented as an int.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Attribute that holds a vector of floategers of type float.
std::vector< int > value() const
get the value associated to this Attribute.
std::vector< unsigned int > value() const
get the value associated to this Attribute.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
bool m_is_parsed
Is this attribute parsed?
void set_value(const long double &d)
set the value associated to this Attribute.
VectorULongAttribute(std::vector< unsigned long > val)
Constructor initializing attribute value.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
void set_value(const long long &l)
set the value associated to this Attribute.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Attribute that holds an Integer implemented as an int.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
Attribute that holds an Booleger implemented as an int.
LongDoubleAttribute()
Default constructor.
CharAttribute()
Default constructor.
std::vector< long double > m_val
Attribute value.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
VectorCharAttribute(std::vector< char > val)
Constructor initializing attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
StringAttribute()
Default constructor - empty string.
Attribute()
Default constructor.
unsigned long m_val
Attribute value.