diff options
-rw-r--r-- | hscript/disk.cc | 2 | ||||
-rw-r--r-- | hscript/disk.hh | 9 | ||||
-rw-r--r-- | hscript/key.cc | 6 | ||||
-rw-r--r-- | hscript/key.hh | 12 | ||||
-rw-r--r-- | hscript/meta.cc | 6 | ||||
-rw-r--r-- | hscript/meta.hh | 6 | ||||
-rw-r--r-- | hscript/network.cc | 4 | ||||
-rw-r--r-- | hscript/network.hh | 8 | ||||
-rw-r--r-- | hscript/script.cc | 2 | ||||
-rw-r--r-- | hscript/user.cc | 2 | ||||
-rw-r--r-- | hscript/user.hh | 2 |
11 files changed, 31 insertions, 28 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc index 665e209..7786730 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -18,7 +18,7 @@ using namespace Horizon::Keys; -Key *Mount::parseFromData(const std::string data, int lineno, int *errors, +Key *Mount::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { std::string dev, where, opt; std::string::size_type where_pos, opt_pos; diff --git a/hscript/disk.hh b/hscript/disk.hh index 36e1e1d..d849e2f 100644 --- a/hscript/disk.hh +++ b/hscript/disk.hh @@ -48,9 +48,10 @@ private: const std::string _mountpoint; const std::string _opts; - Mount(int _line, std::string my_block, std::string my_mountpoint, - std::string my_opts = "") : Key(_line), _block(my_block), - _mountpoint(my_mountpoint), _opts(my_opts) {} + Mount(int _line, const std::string &my_block, + const std::string &my_mountpoint, const std::string &my_opts = "") : + Key(_line), _block(my_block), _mountpoint(my_mountpoint), + _opts(my_opts) {} public: /*! Retrieve the block device to which this mount pertains. */ const std::string device() const { return this->_block; } @@ -59,7 +60,7 @@ public: /*! Retrieve the mount options for this mount, if any. */ const std::string options() const { return this->_opts; } - static Key *parseFromData(const std::string data, int lineno, int *errors, + static Key *parseFromData(const std::string &data, int lineno, int *errors, int *warnings); bool validate(ScriptOptions) const override; bool execute(ScriptOptions) const override; diff --git a/hscript/key.cc b/hscript/key.cc index 80ebfc6..10191e0 100644 --- a/hscript/key.cc +++ b/hscript/key.cc @@ -17,9 +17,9 @@ Horizon::Keys::Key::~Key() { } -bool Horizon::Keys::BooleanKey::parse(const std::string what, - const std::string where, - const std::string key, bool *out) { +bool Horizon::Keys::BooleanKey::parse(const std::string &what, + const std::string &where, + const std::string &key, bool *out) { std::string lower(what.size(), 0); std::transform(what.begin(), what.end(), lower.begin(), ::tolower); diff --git a/hscript/key.hh b/hscript/key.hh index 960095c..f1e2647 100644 --- a/hscript/key.hh +++ b/hscript/key.hh @@ -39,8 +39,9 @@ public: * @returns nullptr if data is unparsable, otherwise a pointer to a Key. */ #define UNUSED __attribute__((unused)) - static Key *parseFromData(const std::string data UNUSED, int lineno UNUSED, - int *errors UNUSED, int *warnings UNUSED) { + static Key *parseFromData(const std::string &data UNUSED, + int lineno UNUSED, int *errors UNUSED, + int *warnings UNUSED) { return nullptr; } #undef UNUSED @@ -75,8 +76,8 @@ protected: * @param out Output variable: will contain the value. * @returns true if value is parsed successfully, false otherwise. */ - static bool parse(const std::string what, const std::string where, - const std::string key, bool *out); + static bool parse(const std::string &what, const std::string &where, + const std::string &key, bool *out); public: /*! Determines if the Key is set or not. * @returns true if the Key is truthy, false otherwise. @@ -92,7 +93,8 @@ public: class StringKey : public Key { protected: const std::string _value; - StringKey(int _line, std::string my_str) : Key(_line), _value(my_str) {} + StringKey(int _line, const std::string &my_str) : + Key(_line), _value(my_str) {} public: /*! Retrieve the value of this key. */ diff --git a/hscript/meta.cc b/hscript/meta.cc index 4fef42a..1234350 100644 --- a/hscript/meta.cc +++ b/hscript/meta.cc @@ -18,7 +18,7 @@ using namespace Horizon::Keys; -Key *Hostname::parseFromData(const std::string data, int lineno, int *errors, +Key *Hostname::parseFromData(const std::string &data, int lineno, int *errors, int *) { std::regex valid_re("[A-Za-z0-9-_.]*"); if(!std::regex_match(data, valid_re)) { @@ -119,7 +119,7 @@ bool Hostname::execute(ScriptOptions opts) const { } -Key *PkgInstall::parseFromData(const std::string data, int lineno, int *errors, +Key *PkgInstall::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { std::regex valid_pkg("[0-9A-Za-z+_.-]*((>?<|[<>]?=|[~>])[0-9A-Za-z-_.]+)?"); std::string next_pkg; @@ -146,7 +146,7 @@ Key *PkgInstall::parseFromData(const std::string data, int lineno, int *errors, return new PkgInstall(lineno, all_pkgs); } -Key *Repository::parseFromData(const std::string data, int lineno, int *errors, +Key *Repository::parseFromData(const std::string &data, int lineno, int *errors, int *) { if(data.empty() || (data[0] != '/' && data.compare(0, 4, "http"))) { if(errors) *errors += 1; diff --git a/hscript/meta.hh b/hscript/meta.hh index 846158d..b73cda4 100644 --- a/hscript/meta.hh +++ b/hscript/meta.hh @@ -25,7 +25,7 @@ private: Hostname(int _line, const std::string my_name) : StringKey(_line, my_name) {} public: - static Key *parseFromData(const std::string data, int lineno, int *errors, + static Key *parseFromData(const std::string &data, int lineno, int *errors, int *warnings); bool validate(ScriptOptions) const override; bool execute(ScriptOptions) const override; @@ -37,7 +37,7 @@ private: PkgInstall(int _line, const std::set<std::string> my_pkgs) : Key(_line), _pkgs(my_pkgs) {} public: - static Key *parseFromData(const std::string data, int lineno, int *errors, + static Key *parseFromData(const std::string &data, int lineno, int *errors, int *warnings); const std::set<std::string> packages() const { return _pkgs; } bool validate(ScriptOptions) const override { return true; } @@ -62,7 +62,7 @@ private: Repository(int _line, const std::string my_url) : StringKey(_line, my_url) {} public: - static Key *parseFromData(const std::string data, int lineno, int *errors, + static Key *parseFromData(const std::string &data, int lineno, int *errors, int *warnings); bool validate(ScriptOptions) const override; bool execute(ScriptOptions) const override; diff --git a/hscript/network.cc b/hscript/network.cc index f14381f..3dc5f1e 100644 --- a/hscript/network.cc +++ b/hscript/network.cc @@ -17,7 +17,7 @@ using namespace Horizon::Keys; -Key *Network::parseFromData(const std::string data, int lineno, int *errors, +Key *Network::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { bool value; if(!BooleanKey::parse(data, "installfile:" + std::to_string(lineno), @@ -32,7 +32,7 @@ bool Network::execute(ScriptOptions) const { return false; } -Key *NetAddress::parseFromData(const std::string data, int lineno, int *errors, +Key *NetAddress::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { long elements = std::count(data.cbegin(), data.cend(), ' ') + 1; std::string::size_type type_pos, addr_pos, prefix_pos, gw_pos, next_end; diff --git a/hscript/network.hh b/hscript/network.hh index 282429b..179346e 100644 --- a/hscript/network.hh +++ b/hscript/network.hh @@ -23,7 +23,7 @@ class Network : public BooleanKey { private: Network(int _line, bool _value) : BooleanKey(_line, _value) {} public: - static Key *parseFromData(const std::string data, int lineno, int *errors, + static Key *parseFromData(const std::string &data, int lineno, int *errors, int *warnings); bool execute(ScriptOptions) const override; }; @@ -46,12 +46,12 @@ 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) : + 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) {} public: - static Key *parseFromData(const std::string data, int lineno, int *errors, + static Key *parseFromData(const std::string &data, int lineno, int *errors, int *warnings); /*! Retrieve the interface to which this 'netaddress' key is associated. */ diff --git a/hscript/script.cc b/hscript/script.cc index d70a552..8afa6aa 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -28,7 +28,7 @@ #define LINE_MAX 512 -typedef Horizon::Keys::Key *(*key_parse_fn)(std::string, int, int*, int*); +typedef Horizon::Keys::Key *(*key_parse_fn)(const std::string &, int, int*, int*); const std::map<std::string, key_parse_fn> valid_keys = { {"network", &Horizon::Keys::Network::parseFromData}, diff --git a/hscript/user.cc b/hscript/user.cc index cc656a1..2b89167 100644 --- a/hscript/user.cc +++ b/hscript/user.cc @@ -15,7 +15,7 @@ using namespace Horizon::Keys; -Key *RootPassphrase::parseFromData(const std::string data, int lineno, +Key *RootPassphrase::parseFromData(const std::string &data, int lineno, int *errors, int *warnings) { if(data.size() < 5 || data[0] != '$' || (data[1] != '2' && data[1] != '6') || data[2] != '$') { diff --git a/hscript/user.hh b/hscript/user.hh index 5b3750c..3f4d23b 100644 --- a/hscript/user.hh +++ b/hscript/user.hh @@ -23,7 +23,7 @@ private: RootPassphrase(int _line, const std::string my_pw) : StringKey(_line, my_pw) {} public: - static Key *parseFromData(const std::string data, int lineno, int *errors, + static Key *parseFromData(const std::string &data, int lineno, int *errors, int *warnings); bool validate(ScriptOptions) const override; bool execute(ScriptOptions) const override; |