![]() |
Limo
A simple mod manager
|
Tag which is automatically added to a mod when its files fulfill the tags conditions. Conditions are managed by a TagConditionNode object. More...
#include <autotag.h>
Public Member Functions | |
AutoTag (const std::string &name, const std::string &expression, const std::vector< TagCondition > &conditions) | |
Constructor. | |
AutoTag (const Json::Value &json) | |
Deserializes an AutoTag from the given json object. | |
template<typename View> | |
void | reapplyMods (const std::map< int, std::vector< std::pair< std::string, std::string > > > &files, const View &mods, std::optional< ProgressNode * > progress_node={}) |
Removes this tag from all mods, then applies it to all given mods which fulfill its conditions. | |
template<typename View> | |
void | reapplyMods (const std::filesystem::path &staging_dir, const View &mods, std::optional< ProgressNode * > progress_node={}) |
Removes this tag from all mods, then applies it to all given mods which fulfill its conditions. | |
template<typename View> | |
void | updateMods (const std::map< int, std::vector< std::pair< std::string, std::string > > > &files, const View &mods, std::optional< ProgressNode * > progress_node={}) |
Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed. | |
template<typename View> | |
void | updateMods (const std::filesystem::path &staging_dir, const View &mods, std::optional< ProgressNode * > progress_node={}) |
Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed. | |
void | setEvaluator (const std::string &expression, const std::vector< TagCondition > &conditions) |
Changes the conditions and expression used by this tag. | |
Json::Value | toJson () const |
Serializes this tag to a json object. | |
bool | operator== (const std::string &name) const |
Compares this tag by name to the given name. | |
std::string | getExpression () const |
Getter for this tags expression. | |
std::vector< TagCondition > | getConditions () const |
Getter for this tags conditions. | |
int | getNumConditions () const |
Returns the number of conditions for this tag. | |
![]() | |
std::string | getName () const |
Getter for the tags name. | |
void | setName (const std::string &name) |
Setter for the tags name. | |
std::vector< int > | getMods () const |
Returns all mods to which this tag has been added. | |
int | getNumMods () const |
Returns the number of mods to which this tag has been added. | |
bool | hasMod (int mod_id) const |
Checks if this tag has been added to the given mod. | |
Static Public Member Functions | |
template<typename View> | |
static std::map< int, std::vector< std::pair< std::string, std::string > > > | readModFiles (const std::filesystem::path &staging_dir, View mods, std::optional< ProgressNode * > progress_node={}) |
Recursively iterates over all files for all mods with given ids and creates a a map of mod ids to a vector containing pairs of path and file name. This vector is used as input for the reapplyMods and updateMods functions. | |
Private Attributes | |
std::string | expression_ |
Expression used by the TagConditionNode. | |
std::vector< TagCondition > | conditions_ |
Conditions used by the TagConditionNode. | |
TagConditionNode | evaluator_ |
This tag is applied to a mod if this nodes evaluate function returns true for the mods installation directory. | |
Additional Inherited Members | |
![]() | |
std::string | name_ |
Name of this tag. | |
std::vector< int > | mods_ {} |
Contains ids of all mods to which this tag has been added. | |
Tag which is automatically added to a mod when its files fulfill the tags conditions. Conditions are managed by a TagConditionNode object.
AutoTag::AutoTag | ( | const std::string & | name, |
const std::string & | expression, | ||
const std::vector< TagCondition > & | conditions ) |
Constructor.
name | Name of the new tag. |
expression | Boolean expression used to combine the given conditions. The tag is applied to a mod when this evaluates to true. |
conditions | Vector of conditions used to decide if this tag is to be applied. These act as variables in the tags expression. |
AutoTag::AutoTag | ( | const Json::Value & | json | ) |
Deserializes an AutoTag from the given json object.
json | Source json object. |
ParseError | when the json object is invalid. |
std::vector< TagCondition > AutoTag::getConditions | ( | ) | const |
Getter for this tags conditions.
std::string AutoTag::getExpression | ( | ) | const |
Getter for this tags expression.
int AutoTag::getNumConditions | ( | ) | const |
Returns the number of conditions for this tag.
bool AutoTag::operator== | ( | const std::string & | name | ) | const |
Compares this tag by name to the given name.
name | Name to compare to. |
|
inlinestatic |
Recursively iterates over all files for all mods with given ids and creates a a map of mod ids to a vector containing pairs of path and file name. This vector is used as input for the reapplyMods and updateMods functions.
staging_dir | Staging directory for the given mods. |
mods | Iterable container containing int ids of all mods to be checked. |
progress_node | Used to inform about progress. |
|
inline |
Removes this tag from all mods, then applies it to all given mods which fulfill its conditions.
staging_dir | Directory containing the mods. |
mods | Iterable container containing int ids of all mods to be checked. |
progress_node | Used to inform about progress. |
|
inline |
Removes this tag from all mods, then applies it to all given mods which fulfill its conditions.
files | Maps mod ids to a vector of pairs of paths and file names for that mod. |
mods | Iterable container containing int ids of all mods to be checked. |
progress_node | Used to inform about progress. |
void AutoTag::setEvaluator | ( | const std::string & | expression, |
const std::vector< TagCondition > & | conditions ) |
Changes the conditions and expression used by this tag.
expression | The new expression. |
conditions | The new conditions. |
|
virtual |
|
inline |
Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed.
staging_dir | Directory containing the mods. |
mods | Iterable container containing int ids of all mods to be checked. |
progress_node | Used to inform about progress. |
|
inline |
Reevaluates if the given mods should have this tag. Adds/ removes the tag from all given mods when needed.
files | Maps mod ids to a vector of pairs of paths and file names for that mod. |
mods | Iterable container containing int ids of all mods to be checked. |
progress_node | Used to inform about progress. |