summaryrefslogtreecommitdiff
path: root/hscript/user.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/user.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/user.hh')
-rw-r--r--hscript/user.hh69
1 files changed, 39 insertions, 30 deletions
diff --git a/hscript/user.hh b/hscript/user.hh
index d29944f..8a093fb 100644
--- a/hscript/user.hh
+++ b/hscript/user.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.
*
@@ -22,21 +22,23 @@ namespace Keys {
class RootPassphrase : public StringKey {
private:
- RootPassphrase(int _line, const std::string &my_pw) :
- StringKey(_line, my_pw) {}
+ RootPassphrase(const Script *_s, int _line, const std::string &my_pw) :
+ StringKey(_s, _line, my_pw) {}
public:
- static Key *parseFromData(const std::string &, int, int*, int*);
- bool validate(ScriptOptions) const override;
- bool execute(ScriptOptions) const override;
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
+ bool validate() const override;
+ bool execute() const override;
};
class Username : public StringKey {
private:
- Username(int _line, const std::string &name) :
- StringKey(_line, name) {}
+ Username(const Script *_s, int _line, const std::string &name) :
+ StringKey(_s, _line, name) {}
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 UserAlias : public Key {
@@ -44,18 +46,20 @@ private:
const std::string _username;
const std::string _alias;
- UserAlias(int _line, const std::string &_n, const std::string &_a) :
- Key(_line), _username(_n), _alias(_a) {}
+ UserAlias(const Script *_s, int _line, const std::string &_n,
+ const std::string &_a) :
+ Key(_s, _line), _username(_n), _alias(_a) {}
public:
- static Key *parseFromData(const std::string &, int, int*, int*);
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
/*! Retrieve the username for this alias. */
const std::string &username() const { return this->_username; }
/*! Retrieve the alias for the account. */
const std::string &alias() const { return this->_alias; }
- bool validate(ScriptOptions) const override;
- bool execute(ScriptOptions) const override;
+ bool validate() const override;
+ bool execute() const override;
};
class UserPassphrase : public Key {
@@ -63,18 +67,20 @@ private:
const std::string _username;
const std::string _passphrase;
- UserPassphrase(int _line, const std::string &_n, const std::string &_p) :
- Key(_line), _username(_n), _passphrase(_p) {}
+ UserPassphrase(const Script *_s, int _line, const std::string &_n,
+ const std::string &_p) :
+ Key(_s, _line), _username(_n), _passphrase(_p) {}
public:
- static Key *parseFromData(const std::string &, int, int*, int*);
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
/*! Retrieve the username for this passphrase. */
const std::string &username() const { return this->_username; }
/*! Retrieve the passphrase for the account. */
const std::string &passphrase() const { return this->_passphrase; }
- bool validate(ScriptOptions) const override;
- bool execute(ScriptOptions) const override;
+ bool validate() const override;
+ bool execute() const override;
};
class UserIcon : public Key {
@@ -82,18 +88,20 @@ private:
const std::string _username;
const std::string _icon_path;
- UserIcon(int _line, const std::string &_n, const std::string &_i) :
- Key(_line), _username(_n), _icon_path(_i) {}
+ UserIcon(const Script *_s, int _line, const std::string &_n,
+ const std::string &_i) :
+ Key(_s, _line), _username(_n), _icon_path(_i) {}
public:
- static Key *parseFromData(const std::string &, int, int*, int*);
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
/*! Retrieve the username for this icon. */
const std::string &username() const { return this->_username; }
/*! Retrieve the icon path for the account. */
const std::string &icon() const { return this->_icon_path; }
- bool validate(ScriptOptions) const override;
- bool execute(ScriptOptions) const override;
+ bool validate() const override;
+ bool execute() const override;
};
class UserGroups : public Key {
@@ -101,19 +109,20 @@ private:
const std::string _username;
const std::set<std::string> _groups;
- UserGroups(int _line, const std::string &_n,
+ UserGroups(const Script *_s, int _line, const std::string &_n,
const std::set<std::string> &_g) :
- Key(_line), _username(_n), _groups(_g) {}
+ Key(_s, _line), _username(_n), _groups(_g) {}
public:
- static Key *parseFromData(const std::string &, int, int*, int*);
+ static Key *parseFromData(const std::string &, int, int*, int*,
+ const Script *);
/*! Retrieve the username for this group set. */
const std::string &username() const { return this->_username; }
/*! Retrieve the groups for the account. */
const std::set<std::string> &groups() const { return this->_groups; }
- bool validate(ScriptOptions) const override;
- bool execute(ScriptOptions) const override;
+ bool validate() const override;
+ bool execute() const override;
};
}