19 template<
typename T,
typename Collection>
21 static void AddElement (Collection&,
unsigned int, T);
25 struct AE<T, std::vector<T> > {
26 static void AddElement (std::vector<T>& params,
unsigned int index, T param) {
27 if (params.size() == index) {
28 params.push_back (param);
29 }
else if (params.size() < index) {
30 params.resize (index + 1, 0.0);
31 params[index] = param;
37 struct AE<T, std::map<unsigned int, T> > {
38 static void AddElement (std::map<unsigned int, T>& params ,
unsigned int index
40 params[index] = param;
44 template<
typename T,
typename Collection >
47 std::stringstream strm (std::stringstream::in | std::stringstream::out);
48 strm << stringparams << noskipws;
50 unsigned int index = 0;
51 while (strm.good() ) {
53 if (strm.peek() ==
'@') {
64 if (separator ==
'@') {
73 if (strm.fail() || strm.bad() ) {
74 cerr <<
"ERROR: Unable to parse params: " << stringparams << endl;
85 std::string stringparams;
86 char *paramsfile = getenv (
"PARAMS_FILE");
88 ifstream ifs (paramsfile);
90 cerr <<
"ERROR: unable to open file " << paramsfile <<
'\n';
95 char * pParams = getenv (
"PARAMS");
99 <<
"Warning: cannot find parameter vector. Defaulting to flat parameters\n";
103 stringparams = pParams;
105 params = ParseParamString<T, std::vector<T> > (stringparams);
107 cerr <<
"Setting params to: ";
108 for (
typename std::vector<T>::const_iterator it = params.begin();
109 it != params.end(); ++it) {
static void AddElement(std::vector< T > ¶ms, unsigned int index, T param)
Collection ParseParamString(const std::string &stringparams)
static void AddElement(Collection &, unsigned int, T)
iszfstream & getline(iszfstream &izs, std::string &line)
static void AddElement(std::map< unsigned int, T > ¶ms, unsigned int index, T param)