diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-04-20 22:01:57 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-04-20 22:01:57 +0300 |
commit | 773fbb10eb59c4e855eccf9966a6ef3a68e3e0c3 (patch) | |
tree | 55178311afbf48536088fa4a83b3bf45d8ebcf0c /bbot/manifest.cxx | |
parent | 4b9c521172a2c30a84f76fcedcec37247878a24f (diff) |
Get rid of variable struct
Diffstat (limited to 'bbot/manifest.cxx')
-rw-r--r-- | bbot/manifest.cxx | 38 |
1 files changed, 35 insertions, 3 deletions
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 <butl/utility> // digit() #include <butl/tab-parser> +#include <butl/string-parser> #include <butl/manifest-parser> #include <butl/manifest-serializer> @@ -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:: |