From 7e9ad089942bc3f1f9b461c87203b515c6d4a237 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 29 Jul 2016 16:21:13 +0100 Subject: Simplify NameFormat classes a bit. --- src/name_format.cc | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'src/name_format.cc') 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_by_placeholder (char p) const -{ - BOOST_FOREACH (Component const & i, _components) { - if (i.placeholder == p) { - return i; - } - } - - return optional (); + _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 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; } -- cgit v1.2.3