aboutsummaryrefslogtreecommitdiff
path: root/bbot/machine-manifest.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-05-10 15:33:05 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-05-11 13:06:42 +0300
commit463e3454bd8553c8ee26c813a83386beeecb9837 (patch)
tree4ef042d2af01c92274637cd21ff6279e731bbe1d /bbot/machine-manifest.cxx
parente08751b52c77608eda1bb38e3437167f53e3b06b (diff)
Make machine_manifest class to partially delegate parsing/serialization to base one
Diffstat (limited to 'bbot/machine-manifest.cxx')
-rw-r--r--bbot/machine-manifest.cxx59
1 files changed, 6 insertions, 53 deletions
diff --git a/bbot/machine-manifest.cxx b/bbot/machine-manifest.cxx
index dd3b7de..3417dd7 100644
--- a/bbot/machine-manifest.cxx
+++ b/bbot/machine-manifest.cxx
@@ -57,6 +57,7 @@ namespace bbot
machine_manifest::
machine_manifest (parser& p, name_value nv, bool iu)
+ : machine_header_manifest (p, move (nv), unknown_name_mode::stop, &nv)
{
auto bad_name = [&p, &nv] (const string& d)
{
@@ -68,52 +69,14 @@ namespace bbot
throw parsing (p.name (), nv.value_line, nv.value_column + offset, d);
};
- // Make sure this is the start and we support the version.
- //
- if (!nv.name.empty ())
- bad_name ("start of machine manifest expected");
-
- if (nv.value != "1")
- bad_value ("unsupported format version");
-
optional<machine_type> type;
- for (nv = p.next (); !nv.empty (); nv = p.next ())
+ for (; !nv.empty (); nv = p.next ())
{
string& n (nv.name);
string& v (nv.value);
- if (n == "id")
- {
- if (!id.empty ())
- bad_name ("machine id redefinition");
-
- if (v.empty ())
- bad_value ("empty machine id");
-
- id = move (v);
- }
- else if (n == "name")
- {
- if (!name.empty ())
- bad_name ("machine name redefinition");
-
- if (v.empty ())
- bad_value ("empty machine name");
-
- name = move (v);
- }
- else if (n == "summary")
- {
- if (!summary.empty ())
- bad_name ("machine summary redefinition");
-
- if (v.empty ())
- bad_value ("empty machine summary");
-
- summary = move (v);
- }
- else if (n == "type")
+ if (n == "type")
{
if (type)
bad_name ("machine type redefinition");
@@ -162,15 +125,6 @@ namespace bbot
// Verify all non-optional values were specified.
//
- if (id.empty ())
- bad_value ("no machine id specified");
-
- if (name.empty ())
- bad_value ("no machine name specified");
-
- if (summary.empty ())
- bad_value ("no machine summary specified");
-
if (!type)
bad_value ("no machine type specified");
@@ -183,10 +137,9 @@ namespace bbot
// @@ Should we check that all non-optional values are specified and all
// values are valid?
//
- s.next ("", "1"); // Start of manifest.
- s.next ("id", id);
- s.next ("name", name);
- s.next ("summary", summary);
+
+ machine_header_manifest::serialize (s, false);
+
s.next ("type", to_string (type));
if (mac)