34 AutoTag(
const std::string& name,
35 const std::string& expression,
36 const std::vector<TagCondition>& conditions);
42 AutoTag(
const Json::Value& json);
51 template<
typename View>
52 void reapplyMods(
const std::map<
int, std::vector<std::pair<std::string, std::string>>>& files,
54 std::optional<ProgressNode*> progress_node = {})
62 (*progress_node)->advance();
72 template<
typename View>
75 std::optional<ProgressNode*> progress_node = {})
86 template<
typename View>
87 void updateMods(
const std::map<
int, std::vector<std::pair<std::string, std::string>>>& files,
89 std::optional<ProgressNode*> progress_node = {})
93 auto iter = std::ranges::find(
mods_, mod);
94 if(iter !=
mods_.end())
99 (*progress_node)->advance();
109 template<
typename View>
112 std::optional<ProgressNode*> progress_node = {})
121 void setEvaluator(
const std::string& expression,
const std::vector<TagCondition>& conditions);
126 Json::Value
toJson()
const;
132 bool operator==(
const std::string& name)
const;
157 template<
typename View>
158 static std::map<int, std::vector<std::pair<std::string, std::string>>>
readModFiles(
159 const std::filesystem::path& staging_dir,
161 std::optional<ProgressNode*> progress_node = {})
163 std::map<int, std::vector<std::pair<std::string, std::string>>> files;
167 const std::filesystem::path mod_path = staging_dir / std::to_string(mod);
168 for(
const auto& dir_entry : std::filesystem::recursive_directory_iterator(mod_path))
170 std::string
path = path_utils::getRelativePath(dir_entry.path(), mod_path);
171 if(
path.front() ==
'/')
173 files[mod].emplace_back(
path, dir_entry.path().filename().string());
176 (*progress_node)->advance();
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.
Definition autotag.h:73
Json::Value toJson() const
Serializes this tag to a json object.
Definition autotag.cpp:71
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 ne...
Definition autotag.h:110
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.
Definition autotag.h:52
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 v...
Definition autotag.h:158
void setEvaluator(const std::string &expression, const std::vector< TagCondition > &conditions)
Changes the conditions and expression used by this tag.
Definition autotag.cpp:63
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 ne...
Definition autotag.h:87
bool operator==(const std::string &name) const
Compares this tag by name to the given name.
Definition autotag.cpp:92
std::vector< TagCondition > conditions_
Conditions used by the TagConditionNode.
Definition autotag.h:185
std::string expression_
Expression used by the TagConditionNode.
Definition autotag.h:183
TagConditionNode evaluator_
This tag is applied to a mod if this nodes evaluate function returns true for the mods installation d...
Definition autotag.h:190
std::vector< TagCondition > getConditions() const
Getter for this tags conditions.
Definition autotag.cpp:102
int getNumConditions() const
Returns the number of conditions for this tag.
Definition autotag.cpp:107
AutoTag(const std::string &name, const std::string &expression, const std::vector< TagCondition > &conditions)
Constructor.
Definition autotag.cpp:10
std::string getExpression() const
Getter for this tags expression.
Definition autotag.cpp:97
Represents a node in a tree used to model a boolean expression for evaluating if the files in a direc...
Definition tagconditionnode.h:19
bool evaluate(const std::vector< std::pair< std::string, std::string > > &files) const
Checks if files in the given vector satisfy the boolean expression modeled by this tree node.
Definition tagconditionnode.cpp:80
Abstract base class for a tag assigned to a set of mods.
Definition tag.h:17
std::vector< int > mods_
Contains ids of all mods to which this tag has been added.
Definition tag.h:56
char path[256]
Path to which to extract the file.
Definition lspakfilelistentry.h:1
Header for the path_utils namespace.
Header for the ProgressNode class.
Header for the Tag class.
Header for the TagConditionNode class.