summaryrefslogtreecommitdiff
path: root/hscript/network.hh
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-02-26 04:33:29 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-02-26 04:33:29 -0600
commit75f10ffe70935187bb900501866a8d555b83a855 (patch)
tree22e60be53af48fcec8465fef2681e9cd5f8cb36e /hscript/network.hh
parentca78cc8d66498cccf54ed26d5318f09362859ba7 (diff)
downloadhorizon-75f10ffe70935187bb900501866a8d555b83a855.tar.gz
horizon-75f10ffe70935187bb900501866a8d555b83a855.tar.bz2
horizon-75f10ffe70935187bb900501866a8d555b83a855.tar.xz
horizon-75f10ffe70935187bb900501866a8d555b83a855.zip
hscript: Refactor Keys to be owned by a Script*
This means that a Key can introspect its Script.
Diffstat (limited to 'hscript/network.hh')
-rw-r--r--hscript/network.hh48
1 files changed, 26 insertions, 22 deletions
diff --git a/hscript/network.hh b/hscript/network.hh
index b556ab8..ec8d2cf 100644
--- a/hscript/network.hh
+++ b/hscript/network.hh
@@ -3,7 +3,7 @@
* libhscript, the HorizonScript library for
* Project Horizon
*
- * Copyright (c) 2019 Adélie Linux and contributors. All rights reserved.
+ * Copyright (c) 2019-2020 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.
*
@@ -21,11 +21,12 @@ namespace Keys {
class Network : public BooleanKey {
private:
- Network(int _line, bool _value) : BooleanKey(_line, _value) {}
+ Network(const Script *_s, int _line, bool _value) :
+ BooleanKey(_s, _line, _value) {}
public:
- static Key *parseFromData(const std::string &data, int lineno, int *errors,
- int *warnings);
- bool execute(ScriptOptions) const override;
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
+ bool execute() const override;
};
class NetAddress : public Key {
@@ -46,13 +47,14 @@ private:
const uint8_t _prefix;
const std::string _gw;
- NetAddress(const int _line, const std::string &_i, const AddressType &_t,
- const std::string &_a, const uint8_t _p, const std::string &_g) :
- Key(_line), _iface(_i), _type(_t), _address(_a), _prefix(_p), _gw(_g)
+ NetAddress(const Script *_sc, const int _line, const std::string &_i,
+ const AddressType &_t, const std::string &_a, const uint8_t _p,
+ const std::string &_g) : Key(_sc, _line), _iface(_i), _type(_t),
+ _address(_a), _prefix(_p), _gw(_g)
{}
public:
- static Key *parseFromData(const std::string &data, int lineno, int *errors,
- int *warnings);
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
/*! Retrieve the interface to which this 'netaddress' key is associated. */
const std::string iface() const { return this->_iface; }
@@ -65,16 +67,18 @@ public:
/*! Retrieve the gateway, if any. */
const std::string gateway() const { return this->_gw; }
- bool validate(ScriptOptions) const override;
- bool execute(ScriptOptions) const override;
+ bool validate() const override;
+ bool execute() const override;
};
class Nameserver : public StringKey {
private:
- Nameserver(int _line, const std::string &ns) : StringKey(_line, ns) {}
+ Nameserver(const Script *_s, int _line, const std::string &ns) :
+ StringKey(_s, _line, ns) {}
public:
- static Key *parseFromData(const std::string &, int, int *, int *);
- bool execute(ScriptOptions) const override;
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
+ bool execute() const override;
};
class NetSSID : public Key {
@@ -91,12 +95,12 @@ private:
const SecurityType _sec;
const std::string _pw;
- NetSSID(int _line, const std::string &_if, const std::string &_s,
- SecurityType _t, const std::string &_p) : Key(_line), _iface(_if),
- _ssid(_s), _sec(_t), _pw(_p) {}
+ NetSSID(const Script *_sc, int _line, const std::string &_if,
+ const std::string &_s, SecurityType _t, const std::string &_p) :
+ Key(_sc, _line), _iface(_if), _ssid(_s), _sec(_t), _pw(_p) {}
public:
- static Key *parseFromData(const std::string &data, int lineno, int *errors,
- int *warnings);
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
/*! Retrieve the interface to which this 'netssid' key is associated. */
const std::string iface() const { return this->_iface; }
@@ -109,8 +113,8 @@ public:
*/
const std::string passphrase() const { return this->_pw; }
- bool validate(ScriptOptions) const override;
- bool execute(ScriptOptions) const override;
+ bool validate() const override;
+ bool execute() const override;
};
}