return o;
}
-void
-NameFormat::add (string name, char placeholder, string title)
-{
- _components.push_back (Component (name, placeholder, title));
-}
-
-optional<NameFormat::Component>
-NameFormat::component_by_placeholder (char p) const
-{
- BOOST_FOREACH (Component const & i, _components) {
- if (i.placeholder == p) {
- return i;
- }
- }
-
- return optional<Component> ();
-}
-
string
-NameFormat::get (Map values) const
+NameFormat::get (Map values, string suffix) const
{
string result;
for (size_t i = 0; i < _specification.length(); ++i) {
bool done = false;
if (_specification[i] == '%' && (i < _specification.length() - 1)) {
- optional<Component> c = component_by_placeholder (_specification[i + 1]);
- if (c) {
- result += filter (values[c->name]);
+ Map::const_iterator j = values.find(_specification[i + 1]);
+ if (j != values.end()) {
+ result += filter (j->second);
++i;
done = true;
}
}
}
- return result;
+ return result + suffix;
}
bool