summaryrefslogtreecommitdiff
path: root/hscript/script.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-17 21:12:42 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-17 21:12:42 -0500
commit01105c999b6ff14f8ba9dae9031c3adfc8391193 (patch)
tree7524b87f5ac9d575a3ac838e2aabe873f278eb71 /hscript/script.cc
parent1a8a8fbfa85952e6bb964c4c8e04abd99f03dcf8 (diff)
downloadhorizon-01105c999b6ff14f8ba9dae9031c3adfc8391193.tar.gz
horizon-01105c999b6ff14f8ba9dae9031c3adfc8391193.tar.bz2
horizon-01105c999b6ff14f8ba9dae9031c3adfc8391193.tar.xz
horizon-01105c999b6ff14f8ba9dae9031c3adfc8391193.zip
hscript: Make dynamic_casts fit on a single line
Diffstat (limited to 'hscript/script.cc')
-rw-r--r--hscript/script.cc40
1 files changed, 15 insertions, 25 deletions
diff --git a/hscript/script.cc b/hscript/script.cc
index 444b6c0..f45c5f2 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -88,12 +88,12 @@ struct Script::ScriptPrivate {
/*! Store +key_obj+ representing the key +key_name+.
* @param key_name The name of the key that is being stored.
- * @param key_obj The Key object associated with the key.
+ * @param obj The Key object associated with the key.
* @param errors Output parameter: if given, incremented on error.
* @param warnings Output parameter: if given, incremented on warning.
* @param opts Script parsing options.
*/
- bool store_key(const std::string key_name, Keys::Key *key_obj, int lineno,
+ bool store_key(const std::string key_name, Keys::Key *obj, int lineno,
int *errors, int *warnings, ScriptOptions opts) {
#define DUPLICATE_ERROR(OBJ, KEY, OLD_VAL) \
std::string err_str("previous value was ");\
@@ -103,15 +103,15 @@ struct Script::ScriptPrivate {
output_error("installfile:" + std::to_string(lineno),\
"duplicate value for key '" + KEY + "'", err_str);
+ using namespace Horizon::Keys;
+
if(key_name == "network") {
if(this->network) {
DUPLICATE_ERROR(this->network, std::string("network"),
this->network->test() ? "true" : "false")
return false;
}
- std::unique_ptr<Keys::Network> net(
- dynamic_cast<Keys::Network *>(key_obj)
- );
+ std::unique_ptr<Network> net(dynamic_cast<Network *>(obj));
this->network = std::move(net);
return true;
} else if(key_name == "hostname") {
@@ -120,19 +120,17 @@ struct Script::ScriptPrivate {
this->hostname->value())
return false;
}
- std::unique_ptr<Keys::Hostname> name(
- dynamic_cast<Keys::Hostname *>(key_obj)
- );
+ std::unique_ptr<Hostname> name(dynamic_cast<Hostname *>(obj));
this->hostname = std::move(name);
return true;
} else if(key_name == "pkginstall") {
- Keys::PkgInstall *install = dynamic_cast<Keys::PkgInstall *>(key_obj);
+ PkgInstall *install = dynamic_cast<PkgInstall *>(obj);
for(auto &pkg : install->packages()) {
if(opts.test(StrictMode) && packages.find(pkg) != packages.end()) {
if(warnings) *warnings += 1;
output_warning("installfile:" + std::to_string(lineno),
- "package '" + pkg + "' has already been specified",
- "");
+ "pkginstall: package '" + pkg +
+ "' has already been specified");
continue;
}
packages.insert(pkg);
@@ -145,33 +143,25 @@ struct Script::ScriptPrivate {
"an encrypted passphrase")
return false;
}
- std::unique_ptr<Keys::RootPassphrase> name(
- dynamic_cast<Keys::RootPassphrase *>(key_obj)
+ std::unique_ptr<RootPassphrase> name(
+ dynamic_cast<RootPassphrase *>(obj)
);
this->rootpw = std::move(name);
return true;
} else if(key_name == "mount") {
- std::unique_ptr<Keys::Mount> mount(
- dynamic_cast<Keys::Mount *>(key_obj)
- );
+ std::unique_ptr<Mount> mount(dynamic_cast<Mount *>(obj));
this->mounts.push_back(std::move(mount));
return true;
} else if(key_name == "netaddress") {
- std::unique_ptr<Keys::NetAddress> addr(
- dynamic_cast<Keys::NetAddress *>(key_obj)
- );
+ std::unique_ptr<NetAddress> addr(dynamic_cast<NetAddress *>(obj));
this->addresses.push_back(std::move(addr));
return true;
} else if(key_name == "netssid") {
- std::unique_ptr<Keys::NetSSID> ssid(
- dynamic_cast<Keys::NetSSID *>(key_obj)
- );
+ std::unique_ptr<NetSSID> ssid(dynamic_cast<NetSSID *>(obj));
this->ssids.push_back(std::move(ssid));
return true;
} else if(key_name == "repository") {
- std::unique_ptr<Keys::Repository> repo(
- dynamic_cast<Keys::Repository *>(key_obj)
- );
+ std::unique_ptr<Repository> repo(dynamic_cast<Repository *>(obj));
this->repos.push_back(std::move(repo));
return true;
} else {