From 03dff10cbde4c55e4ac9b53a01ba84f4bdac169b Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 13 Jun 2019 20:42:11 +0200 Subject: Load properties from json and propagate to context create --- common/command.cc | 9 ++++++++- common/command.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/command.cc b/common/command.cc index 4822585c..209f8cab 100644 --- a/common/command.cc +++ b/common/command.cc @@ -358,7 +358,14 @@ int CommandHandler::exec() if (executeBeforeContext()) return 0; - std::unique_ptr ctx = createContext(); + std::unordered_map values; + if (vm.count("json")) { + std::string filename = vm["json"].as(); + std::ifstream f(filename); + if (!load_json_settings(f, filename, values)) + log_error("Loading design failed.\n"); + } + std::unique_ptr ctx = createContext(values); settings = std::unique_ptr(new Settings(ctx.get())); setupContext(ctx.get()); setupArchContext(ctx.get()); diff --git a/common/command.h b/common/command.h index d4f9a12e..5c5ceb9a 100644 --- a/common/command.h +++ b/common/command.h @@ -39,7 +39,7 @@ class CommandHandler protected: virtual void setupArchContext(Context *ctx) = 0; - virtual std::unique_ptr createContext() = 0; + virtual std::unique_ptr createContext(std::unordered_map &values) = 0; virtual po::options_description getArchOptions() = 0; virtual void validate(){}; virtual void customAfterLoad(Context *ctx){}; -- cgit v1.2.3