1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#define XERR
#include "parser.ih"
// static
VSDvect Parser::VSDparameters(VaryType varyType, StringVect const &keywords,
initializer_list<char> const &required)
{
VSDvect vsdVect(required.size(), VSD{ varyType });
auto lines = any(keywords); // all config lines of 'keywords'
unsigned count = 0;
while (true)
{
auto const *line = lines.get(); // get the next line
if (not line)
break;
VSD vsd{ varyType };
char type;
if (not Parser::extract(*line, type, vsd)) // get the next VSD
continue;
// check whether the
// type (a..x) is OK
auto idIter = find(required.begin(), required.end(), type);
if (idIter == required.end())
{
Err::msg(Err::INVALID_TYPE) << '`' << type << '\'' << endl;
continue;
}
++count; // found a VSD specification
vsdVect[idIter - required.begin()] = vsd; // store the extracted VSD
}
if (count != required.size())
Err::msg(Err::VSD_MISSING) << count << " specifications\n";
return vsdVect;
}
|