Base class which reads an ini-based user profiles file.
More...
#include <AbstractUserProfiles.hpp>
|
| AbstractUserProfiles () |
| Default constructor. More...
|
|
| AbstractUserProfiles (const std::string &in_pluginName) |
| Constructor. More...
|
|
template<typename T > |
Error | getValueForUser (const std::string &in_valueName, const system::User &in_user, T &out_value) const |
| Gets the value with the specified name for the given user, based on the profiles configuration file. More...
|
|
template<typename T > |
Error | validateValue (const std::string &in_valueName) const |
| Parses all occurrences of the configuration setting with name in_valueName to validate it is correctly formatted. More...
|
|
Error | validateValue (const std::string &in_valueName, const CustomValueValidator &in_validator) const |
| Validates all occurrences of a value which has a non-standard type. More...
|
|
Base class which reads an ini-based user profiles file.
◆ AbstractUserProfiles() [1/2]
rstudio::launcher_plugins::options::AbstractUserProfiles::AbstractUserProfiles |
( |
| ) |
|
|
protected |
Default constructor.
This constructor should only be used if the inheriting class overrides getConfigurationFileName
.
If this constructor is used, the user profiles file will be /etc/rstudio/<getConfigurationFileName()>.conf
.
◆ AbstractUserProfiles() [2/2]
rstudio::launcher_plugins::options::AbstractUserProfiles::AbstractUserProfiles |
( |
const std::string & |
in_pluginName | ) |
|
|
explicitprotected |
Constructor.
If this constructor is used, the user profiles file will be /etc/rstudio/launcher.<in_pluginName>.profiles.conf
.
- Parameters
-
in_pluginName | The lower-case name of the plugin, to be used to set the configuration file name. |
◆ getValueForUser()
template<typename T >
Error rstudio::launcher_plugins::options::AbstractUserProfiles::getValueForUser |
( |
const std::string & |
in_valueName, |
|
|
const system::User & |
in_user, |
|
|
T & |
out_value |
|
) |
| const |
|
protected |
Gets the value with the specified name for the given user, based on the profiles configuration file.
This template method is instantiated in the CPP for a fixed set of types. Supported types: std::string int32_t uint32_t int64_t uint64_t float bool std::set<U>, where U is one of the types above std::vector<U>, where U is one of the types above (except std::set) std::map<U, V> where U and V are any two of the types above
If additional types are required, this method should be invoked using T=std::string and the caller may parse the string value as desired.
- Template Parameters
-
T | The type of the value, as defined above. |
- Parameters
-
in_valueName | The name of the value to retrieve for the specified user. |
in_user | The user for which to retrieve the value. |
out_value | The requested value, if no error occurred. |
- Returns
- Success if the requested value could be found for the given user and could be parsed to type T; Error otherwise.
◆ initialize()
Error rstudio::launcher_plugins::options::AbstractUserProfiles::initialize |
( |
| ) |
|
Initializes the user profiles. Must be called before attempting to retrieve configuration values.
- Returns
- Success if the user profiles file could be opened for read and parsed; Error otherwise.
◆ isValueNotFoundError()
static bool rstudio::launcher_plugins::options::AbstractUserProfiles::isValueNotFoundError |
( |
const Error & |
in_error | ) |
|
|
staticprotected |
Checks whether the error indicates that the configuration value was not found.
This method may be used to handle missing values differently than invalid values. For example, the Plugin developer may choose to use a default value if none was specified in the configuration file.
- Parameters
-
in_error | The error to check. |
- Returns
- True if this error is a value-not-found error; false otherwise.
◆ validateValue() [1/2]
template<typename T >
Error rstudio::launcher_plugins::options::AbstractUserProfiles::validateValue |
( |
const std::string & |
in_valueName | ) |
const |
|
protected |
Parses all occurrences of the configuration setting with name in_valueName to validate it is correctly formatted.
- Template Parameters
-
T | The type of the value. This is a precompiled templated function. Possible types are described in the documentation of getValueForUser. |
- Parameters
-
in_valueName | The name of the value to validate. |
- Returns
- Success if all occurrences of in_valueName within the profiles configuration file could be parsed; Error otherwise.
◆ validateValue() [2/2]
Error rstudio::launcher_plugins::options::AbstractUserProfiles::validateValue |
( |
const std::string & |
in_valueName, |
|
|
const CustomValueValidator & |
in_validator |
|
) |
| const |
|
protected |
Validates all occurrences of a value which has a non-standard type.
- Parameters
-
in_valueName | The name of the value to validate. |
in_validator | The custom validation function. This should return success if the value could be parsed correctly and an error otherwise. |
- Returns
- Success if all occurrences of in_valueName within the profiles configuration file could be parsed; Error otherwise.
The documentation for this class was generated from the following file: