FeatureSpec* FeatureSpec::parse(char const*& line) { char const* st = next_token_line(line, " \t("); char const* attribute = strndup(st, line - st); // skip blanks line = next_token_line(line, " \t"); if (!line || line[0] != '(') { cerr << "Missing '(' after attribute name in feature: " << attribute << line << endl; return 0; } TokenPath* path = TokenPath::parse(line); if (!path) { cerr << "Bad path for feature: " << attribute << line << endl; return 0; } if (!line || line[0] != ')') { cerr << "Missing ')' after feature: " << attribute << line << endl; return 0; } line++; FeatureSpec* fs = new FeatureSpec(attribute, path); // skip blanks st = next_token_line(line, " \t"); if (st) { fs->next = FeatureSpec::parse(st); } return fs; }
void conf_single_features::parseValue(char const*& line) { char const* st = next_token_line(line, " \r\t"); char const* feature = strndup(st, line - st); TokenPath* tp; while ((tp = TokenPath::parse(line))) conf_features::add(value, new FeatureSpec(feature, tp)); }
/* virtual */ void conf<bool>::parseValue(char const*& lines) { char const* line = next_token_line(lines, "\n"); if (!strncasecmp(line, "false", 5) || !strncasecmp(line, "f", 1) || !strncasecmp(line, "no", 2) || !strncasecmp(line, "n", 1) || !strncasecmp(line, "off", 3) || !strncasecmp(line, "0", 1)) { value = false; return; } if (!strncasecmp(line, "true", 4) || !strncasecmp(line, "t", 1) || !strncasecmp(line, "yes", 3) || !strncasecmp(line, "y", 1) || !strncasecmp(line, "on", 2) || !strncasecmp(line, "1", 1)) { value = true; return; } LOG(error) << '"' << name() << "\" is not one of: " "false, f, no, n, off, 0, true, t, yes, y, on, 1" << endl; }