diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index 7b83023b0..8830e8a7a 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -90,7 +90,6 @@ #include "lib/itertools.hpp" #include "lib/util.hpp" -//#include "lib/format-string.hpp" #include #include @@ -105,7 +104,6 @@ namespace diff{ namespace error = lumiera::error; -//using util::_Fmt; using std::string; @@ -218,7 +216,7 @@ namespace diff{ if (attribs_.end() == found) throw error::Invalid ("Record has no attribute \""+key+"\""); else - return *found; + return extractVal (*found); } /** @@ -280,8 +278,8 @@ namespace diff{ /** Implementation of Iteration-logic: detect iteration end. * @remarks seamless continuation of the iteration when reaching - * the end of the attribute collection. In this implementation, - * we use the default constructed \c ITER() to mark iteration end. + * the end of the attribute collection. In this implementation, + * we use the default constructed \c ITER() to mark iteration end. */ template friend bool @@ -322,7 +320,7 @@ namespace diff{ { return key == extractKey(elm); }); - } ///////////////////TODO this lambda triggers a GCC-4.7.2 Bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56402 + } friend bool @@ -546,7 +544,7 @@ namespace diff{ if (string::npos == pos) return ""; else - return v.substr(0,pos); //////////////////////////////TODO should trim here + return util::trim (v.substr (0,pos)); } template<> @@ -557,7 +555,7 @@ namespace diff{ if (string::npos == pos) return v; else - return v.substr(pos+1, v.length() - pos); ////////////TODO should trim here + return util::trim (v.substr (pos+1, v.length() - pos)); } template<> diff --git a/src/lib/util.cpp b/src/lib/util.cpp index 1726fa026..cebb793a4 100644 --- a/src/lib/util.cpp +++ b/src/lib/util.cpp @@ -67,6 +67,18 @@ namespace util { return res; } + + /** + * @remarks this function just forwards to boost::algorithm::trim_copy. + * Use this call when boost header inclusion is an issue, otherwise + * a direct invocation is likely to perform better, due to inlining. + */ + string + trim (string const& org) + { + return boost::algorithm::trim_copy (org); + } + } // namespace util diff --git a/src/lib/util.hpp b/src/lib/util.hpp index 961439894..effff2312 100644 --- a/src/lib/util.hpp +++ b/src/lib/util.hpp @@ -321,6 +321,12 @@ namespace util { string sanitise (string const& org); + /** remove leading and trailing whitespace + * @return a trimmed copy (default locale) + */ + string trim (string const& org); + + /** convenience shortcut: conversion to c-String via string. diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 62298c62e..fb846882e 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -227,7 +227,7 @@ Problem ist, wir definieren den Typ Record generisch,

- verwenden dann aber nur die spezialisierung Record<GenNode> + verwenden dann aber nur die Spezialisierung Record<GenNode>

Und die Builder-Funktionen brauchen eigentlich spezielles Wissen über den zu konstruierenden Zieltyp