summaryrefslogtreecommitdiff
path: root/src/name_format.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-29 16:21:13 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-29 16:21:13 +0100
commit7e9ad089942bc3f1f9b461c87203b515c6d4a237 (patch)
treec4af2873e366d2ca59210d74a14f9cfd5e2b42ac /src/name_format.cc
parent8ef91325f4e565d04493bc05202f8e066b5e3e0c (diff)
Simplify NameFormat classes a bit.
Diffstat (limited to 'src/name_format.cc')
-rw-r--r--src/name_format.cc22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/name_format.cc b/src/name_format.cc
index 1dc1135d..300ff315 100644
--- a/src/name_format.cc
+++ b/src/name_format.cc
@@ -65,21 +65,9 @@ filter (string c)
}
void
-NameFormat::add (string name, char placeholder, string title)
+NameFormat::add (char placeholder)
{
- _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> ();
+ _components.push_back (placeholder);
}
string
@@ -89,9 +77,9 @@ NameFormat::get (Map values) const
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;
}