21#ifndef READCARDS_READCARDS_H
22#define READCARDS_READCARDS_H
37using std::ostringstream;
63 if ( tag==
m_Values[i].Tag() )
return true;
68 const std::vector<double>
GetVector(
unsigned i)
const {
69 std::vector<double> dValues;
71 for (
unsigned j=0 ; j<
m_Values[i].Val().size() ; j++ ) {
80 else return string(
"");
93 std::string
GetString(
const std::string& tag)
const {
102 const std::vector<double>
GetVector(
const std::string& tag)
const {
109 std::vector<int>
a;
a.reserve(s.size());
110 for (
size_t i=0 ; i<s.size() ; i++ )
a.push_back(
int(s[i]) );
122 void Set(
const string& tag,
double& value )
const {
126 void Set(
const string& tag,
int& value )
const {
130 void Set(
const std::string& tag, std::string& value)
const {
134 void Set(
const string& tag, std::vector<double>& value )
const {
138 void Set(
const string& tag, std::vector<int>& value )
const {
142 value.resize(v.size());
143 for (
unsigned i=v.size() ; i-- ; ) value[i] = v[i];
147 void Set(
const std::string& tag, std::vector<std::string>& value)
const {
154 std::vector<string>
Tags(
const std::string& pattern=
"")
const {
155 std::vector<string>
tags;
160 for (
unsigned i=0 ; i<
m_Values.size() ; i++ ) {
198 cerr <<
"ReadCards::GetValue() no tag: " << tag <<
" in file: " <<
m_FileName << endl;
203 bool AddTag(
const string& tag,
const vector<string>& values) {
204 for (
unsigned i=0 ; i<
m_Values.size() ; i++ ) {
206 cerr <<
"ReadCards::addTag() tag " << tag <<
" already defined in file " <<
m_FileName << endl;
230 void Construct(
const std::string& filename);
241 cerr <<
"ReadCards() syntax error in file " <<
m_FileName <<
" : " << s << endl;
246 double handle(
const std::string& s,
const std::string& =
"")
const {
248 char temps[1024] =
"";
250 if ( (
r = std::sscanf(s.c_str(),
"%lf%1023s", &d, temps))==0 ||
r!=1 ||
string(temps)!=
"" ) {
251 cerr <<
"ReadCards() error converting string to number : " << s << endl;
void Set(const std::string &tag, std::vector< std::string > &value) const
vector< string > parseright(string &s)
void Set(const string &tag, std::vector< double > &value) const
std::vector< int > m_ValuesFlag
bool AddTag(const string &tag, const vector< string > &values)
std::vector< string > Tags(const std::string &pattern="") const
void declareProperty(const std::string &key, T &t)
static std::vector< std::string > m_Path
string parseleft(string &s)
double handle(const std::string &s, const std::string &="") const
double GetValue(const string &tag) const
string GetValueString(unsigned i) const
void parse()
parse the remaining cleaned input string
const std::vector< int > GetIntVector(const std::string &tag) const
void declareProperty(const std::string &key, std::vector< T > &t)
const std::vector< double > GetVector(unsigned i) const
int GetIndex(const std::string &tag) const
void Construct(const std::string &filename)
check for file in cwd or if not, check in the RESPLOTDIR, then read the file
void Set(const string &tag, double &value) const
void declareProperty(const std::string &key, std::string &t)
std::vector< std::string > GetStringVector(const std::string &tag) const
void error(const std::string &s)
void declareProperty(const std::string &key, std::vector< std::string > &t)
bool isTagDefined(const string &tag) const
void Set(const std::string &tag, std::string &value) const
ReadCards(const std::string &filename)
std::string GetString(const unsigned i) const
void clean()
remove comments and whitespace
std::vector< Value > m_Values
std::string GetString(const std::string &tag) const
const std::vector< double > GetVector(const std::string &tag) const
double GetValue(int i) const
void Set(const string &tag, int &value) const
void Set(const string &tag, std::vector< int > &value) const
std::vector< std::string > tags
std::string find(const std::string &s)
return a remapped string