From 92b2d500937a985275cee574ba10803b8e949356 Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Mon, 7 Oct 2019 19:07:36 -0500
Subject: hscript: Implement Network class

---
 hscript/CMakeLists.txt |  1 +
 hscript/network.cc     | 32 ++++++++++++++++++++++++++++++++
 hscript/network.hh     | 10 +++++++---
 3 files changed, 40 insertions(+), 3 deletions(-)
 create mode 100644 hscript/network.cc

diff --git a/hscript/CMakeLists.txt b/hscript/CMakeLists.txt
index dcdb8ad..65126e4 100644
--- a/hscript/CMakeLists.txt
+++ b/hscript/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(HSCRIPT_SOURCE
 	script.cc
         key.cc
+        network.cc
 )
 
 set(HSCRIPT_INCLUDE
diff --git a/hscript/network.cc b/hscript/network.cc
new file mode 100644
index 0000000..8f79d96
--- /dev/null
+++ b/hscript/network.cc
@@ -0,0 +1,32 @@
+/*
+ * network.cc - Implementation of the network Key classes
+ * libhscript, the HorizonScript library for
+ * Project Horizon
+ *
+ * Copyright (c) 2019 Adélie Linux and contributors.  All rights reserved.
+ * This code is licensed under the AGPL 3.0 license, as noted in the
+ * LICENSE-code file in the root directory of this repository.
+ *
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
+
+#include "network.hh"
+
+using namespace Horizon::Keys;
+
+Key *Network::parseFromData(const std::string data, int lineno, int *errors,
+                            int *warnings) {
+    bool value;
+    if(!BooleanKey::parse(data, &value)) {
+        output_error("installfile:" + std::to_string(lineno),
+                     "network: expected 'true' or 'false'",
+                     "'" + data + "' is not a valid Boolean value");
+        if(errors) *errors += 1;
+        return nullptr;
+    }
+    return new Network(value);
+}
+
+bool Network::execute() {
+    return false;
+}
diff --git a/hscript/network.hh b/hscript/network.hh
index e3e6595..7fc0504 100644
--- a/hscript/network.hh
+++ b/hscript/network.hh
@@ -14,14 +14,18 @@
 #define __HSCRIPT_NETWORK_HH_
 
 #include "key.hh"
+#include "util/output.hh"
 
 namespace Horizon {
 namespace Keys {
 
-class Network : public Key {
+class Network : public BooleanKey {
+private:
+    Network(bool _value) : BooleanKey(_value) {}
 public:
-    /*! Determine if networking is enabled. */
-    bool enabled();
+    static Key *parseFromData(const std::string data, int lineno, int *errors,
+                              int *warnings);
+    bool execute() override;
 };
 
 class NetAddress : public Key {
-- 
cgit v1.2.3-70-g09d2