summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-12-09 17:43:05 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-12-09 17:43:05 +0000
commit42f97b0aa106881e00a2ce63c4cc704ebc34b707 (patch)
tree269debb61a1a934cd9bdc8439c458d7fd5b0b072
parentlibdbpp nolonger stores column names as ustrings (diff)
downloadslicer-42f97b0aa106881e00a2ce63c4cc704ebc34b707.tar.bz2
slicer-42f97b0aa106881e00a2ce63c4cc704ebc34b707.tar.xz
slicer-42f97b0aa106881e00a2ce63c4cc704ebc34b707.zip
Allow poassing options to conversions
-rw-r--r--slicer/slicer/parser.cpp22
-rw-r--r--slicer/slicer/parser.h5
2 files changed, 21 insertions, 6 deletions
diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp
index 607ff36..ab0bc88 100644
--- a/slicer/slicer/parser.cpp
+++ b/slicer/slicer/parser.cpp
@@ -5,11 +5,13 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp>
+#include <boost/algorithm/string/split.hpp>
#include <Slice/CPlusPlusUtil.h>
#include <boost/shared_ptr.hpp>
#include <boost/filesystem/convenience.hpp>
#include <mutex>
#include <fprintbf.h>
+#include <safeMapFind.h>
namespace fs = boost::filesystem;
@@ -527,13 +529,13 @@ namespace Slicer {
auto conversions = metaDataValues("slicer:conversion:", dm);
for (const auto & conversion : conversions) {
auto split = metaDataSplit(conversion);
- if (split.size() != 3) {
- throw std::runtime_error("conversion needs 3 parts type:toModelFunc:toExchangeFunc");
+ if (split.size() < 3) {
+ throw std::runtime_error("conversion needs at least 3 parts type:toModelFunc:toExchangeFunc[:options]");
}
- for (auto & p : split) {
- boost::algorithm::replace_all(p, ".", "::");
+ for (auto & pi : {0, 1, 2}) {
+ boost::algorithm::replace_all(split[pi], ".", "::");
}
- rtn.push_back(ConversionSpec({split[0], split[1], split[2]}));
+ rtn.push_back(split);
}
return rtn;
}
@@ -597,5 +599,15 @@ namespace Slicer {
return s.Components();
}
+
+ Slicer::ConversionSpec::ConversionSpec(const Slicer::Args & s) :
+ ExchangeType(s[0]),
+ ConvertToModelFunc(s[1]),
+ ConvertToExchangeFunc(s[2])
+ {
+ if (s.size() >= 4) {
+ boost::algorithm::split(Options, s[3], boost::algorithm::is_any_of(","), boost::algorithm::token_compress_off);
+ }
+ }
};
diff --git a/slicer/slicer/parser.h b/slicer/slicer/parser.h
index 744ffa7..322476f 100644
--- a/slicer/slicer/parser.h
+++ b/slicer/slicer/parser.h
@@ -11,14 +11,17 @@ namespace Slicer {
class DLL_PUBLIC Slicer : public Slice::ParserVisitor {
public:
+ typedef std::vector<std::string> Args;
class ConversionSpec {
public:
+ ConversionSpec(const Args &);
+
std::string ExchangeType;
std::string ConvertToModelFunc;
std::string ConvertToExchangeFunc;
+ Args Options;
};
typedef std::vector<ConversionSpec> Conversions;
- typedef std::vector<std::string> Args;
Slicer(FILE * c);