From 773fbb10eb59c4e855eccf9966a6ef3a68e3e0c3 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 20 Apr 2017 22:01:57 +0300 Subject: Get rid of variable struct --- bbot/manifest.cxx | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'bbot/manifest.cxx') diff --git a/bbot/manifest.cxx b/bbot/manifest.cxx index 0f7a053..1d164db 100644 --- a/bbot/manifest.cxx +++ b/bbot/manifest.cxx @@ -16,6 +16,7 @@ #include // digit() #include +#include #include #include @@ -442,14 +443,16 @@ namespace bbot { try { - config.emplace_back (variable (move (tf.value))); + check_config (tf.value); } - catch (const invalid_variable& e) + catch (const invalid_argument& e) { bad_value (string ("invalid task configuration: ") + e.what (), - tf.column - 1 + e.pos, + tf.column - 1, tl.line - 1); } + + config.emplace_back (move (tf.value)); } } } @@ -520,6 +523,35 @@ namespace bbot s.next ("", ""); // End of manifest. } + strings task_manifest:: + unquoted_config () + { + return string_parser::unquote (config); + } + + void task_manifest:: + check_config (const string& s) + { + auto i (s.begin ()); + auto e (s.end ()); + + // Iterate until the variable name end and check that it contains no + // whitespaces. + // + for (; i != e; ++i) + { + char c (*i); + + if (c == ' ' || c == '\t') // Whitespace in name. + throw invalid_argument ("expected variable assignment"); + else if (c == '=') + break; + } + + if (i == e) + throw invalid_argument ("no variable value"); + } + // task_response_manifest // task_response_manifest:: -- cgit v1.1