17 using namespace HEPREP;
25 std::string DefaultHepRepAttValue::labelStrings[LABELSTRINGS_LEN];
27 DefaultHepRepAttValue::DefaultHepRepAttValue(
string aName,
string aValue,
int aShowLabel)
34 , showLabelValue(aShowLabel)
45 , showLabelValue(aShowLabel)
56 , showLabelValue(aShowLabel)
67 , showLabelValue(aShowLabel)
77 , booleanValue(aValue)
78 , showLabelValue(aShowLabel)
90 , showLabelValue(aShowLabel)
98 void DefaultHepRepAttValue::init() {
99 labelStrings[0] =
"NAME";
100 labelStrings[1] =
"DESC";
101 labelStrings[2] =
"VALUE";
102 labelStrings[3] =
"EXTRA";
131 transform(s.begin(), s.end(), s.begin(), (
int(*)(
int)) tolower);
141 case HepRepConstants::TYPE_COLOR:
return(
"Color");
142 case HepRepConstants::TYPE_STRING:
return(
"String");
143 case HepRepConstants::TYPE_LONG:
return(
"long");
144 case HepRepConstants::TYPE_INT:
return(
"int");
145 case HepRepConstants::TYPE_DOUBLE:
return(
"double");
146 case HepRepConstants::TYPE_BOOLEAN:
return(
"boolean");
147 default:
return "Unknown type stored in HepRepAttDef";
152 return showLabelValue;
156 if (type != HepRepConstants::TYPE_STRING) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'string'" << endl;
161 if (type != HepRepConstants::TYPE_STRING) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'string'" << endl;
162 string s = stringValue;
163 transform(s.begin(), s.end(), s.begin(), (
int(*)(
int)) tolower);
168 if (type != HepRepConstants::TYPE_LONG) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'long'" << endl;
173 if (type != HepRepConstants::TYPE_INT) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'int'" << endl;
174 return (
int64)longValue;
178 if (type != HepRepConstants::TYPE_DOUBLE) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'double'" << endl;
183 if (type != HepRepConstants::TYPE_BOOLEAN) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'boolean'" << endl;
188 if (type != HepRepConstants::TYPE_COLOR) cerr <<
"Trying to access AttValue '" <<
getName() <<
"' as 'color'" << endl;
196 case HepRepConstants::TYPE_STRING:
return getString();
201 default:
return "Unknown typecode";
207 sprintf(buffer,
"%4.2f, %4.2f, %4.2f, %4.2f",
211 (c.size() > 3) ? c[3] : 1.0);
217 sprintf(buffer,
"%d", i);
230 sprintf(buffer,
"%g", d);
235 return b ?
"true" :
"false";
249 if (showLabel == HepRepConstants::SHOW_NONE) {
252 for (
int i=0; i<16; i++) {
253 if (((showLabel >> i) & 0x0001) == 0x0001) {
259 if (i < LABELSTRINGS_LEN) {
260 label.append(labelStrings[i]);
263 sprintf(hex,
"%0x", 1 << i);
DefaultHepRepAttValue(std::string name, std::string value, int showLabel)
HEPREP::HepRepAttValue * copy()
std::string getLowerCaseString()
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
#define CHEPREP_INT64_FORMAT
std::string getLowerCaseName()
std::vector< double > getColor()
std::string getTypeName()
std::string toShowLabel()
std::string getAsString()