pick up work where I left one month ago

OMG, what was all this about?
OK... this cant possibly work this way.
At least we need to trim after splitting the attributes.
But this is not enough, we want the value, which implies
to make the type flexible (since we cant return a const& to
a substring extracted on-the-fly)
This commit is contained in:
Fischlurch 2015-08-17 01:22:01 +02:00
parent 8dcdce1a58
commit 61b6868bff
4 changed files with 25 additions and 9 deletions

View file

@ -90,7 +90,6 @@
#include "lib/itertools.hpp"
#include "lib/util.hpp"
//#include "lib/format-string.hpp"
#include <boost/noncopyable.hpp>
#include <algorithm>
@ -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<class ITER>
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<>

View file

@ -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

View file

@ -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.

View file

@ -227,7 +227,7 @@
Problem ist, wir definieren den Typ Record generisch,
</p>
<p>
verwenden dann aber nur die spezialisierung Record&lt;GenNode&gt;
verwenden dann aber nur die Spezialisierung Record&lt;GenNode&gt;
</p>
<p>
Und die Builder-Funktionen brauchen eigentlich spezielles Wissen &#252;ber den zu konstruierenden Zieltyp