Limo
A simple mod manager
Loading...
Searching...
No Matches
fomod::FomodInstaller Class Reference

Holds data and functions needed to pass a fomod file. More...

#include <fomodinstaller.h>

Public Member Functions

 FomodInstaller ()=default
 Default constructor.
 
void init (const std::filesystem::path &config_file, const std::filesystem::path &target_path="", const std::string &app_version="")
 Initializes the installer.
 
std::optional< InstallStepstep (const std::vector< std::vector< bool > > &selection={})
 Advances installation process by one step.
 
std::optional< std::pair< std::vector< std::vector< bool > >, InstallStep > > stepBack ()
 Returns a pair of the previous installation step and the selections made at that step.
 
bool hasNextStep (const std::vector< std::vector< bool > > &selection) const
 Checks if there is at least one more valid installation step.
 
std::vector< std::pair< std::filesystem::path, std::filesystem::path > > getInstallationFiles (const std::vector< std::vector< bool > > &selection={})
 Returns all files to be installed with current selection.
 
bool hasPreviousStep () const
 Checks if there is a previous installation step.
 
bool hasNoSteps () const
 Checks if installation has not steps.
 

Static Public Member Functions

static std::pair< std::string, std::string > getMetaData (const std::filesystem::path &path)
 Extracts mod name and version from a fomod info file in path/fomod/info.xml.
 

Private Member Functions

void parseFileList (const pugi::xml_node &file_list, std::vector< File > &target_vector, bool warn_missing=true)
 Extracts all files from given file list node and appends them to given vector.
 
void parseInstallSteps (const pugi::xml_node &steps)
 Extracts all install steps from given node and stores them in steps_.
 
PluginGroup::Type parseGroupType (const std::string &type)
 Determines group type from given string.
 
void parseInstallList ()
 Updates files_ according to the fomod files conditionalFileInstalls node.
 
void initPlugin (const pugi::xml_node &xml_node, Plugin &plugin)
 Initializes given plugin plugin from fomod node.
 
PluginType parsePluginType (const std::string &type)
 Determines plugin type from given string.
 
void updateState (const std::vector< std::vector< bool > > &selection)
 Updates flags_ and files_ with selection.
 
template<typename T>
void sortVector (std::vector< T > &source, std::string order)
 Sorts given vector according to given ordering type.
 

Static Private Member Functions

static std::pair< std::string, std::string > getFomodPath (const std::filesystem::path &source, const std::string &file_name="ModuleConfig.xml")
 Tries to find fomod/file_name in the given path.
 

Private Attributes

pugi::xml_document config_file_
 Source fomod config file.
 
pugi::xml_node config_
 Root node of the config file.
 
std::filesystem::path target_path_
 Path used to check for file dependencies.
 
std::vector< Filefiles_
 Contains all files extracted from the config file.
 
std::vector< InstallStepsteps_
 Steps performed during installation.
 
int cur_step_ = -1
 Current installation step.
 
std::map< std::string, std::string > flags_
 Maps flags to their value.
 
std::filesystem::path mod_base_path_
 Base path of the mod to be installed.
 
std::vector< std::vector< std::vector< bool > > > prev_selections_
 Previous selections made during installation process.
 
std::function< bool(std::string)> version_eval_fun_ = [](auto s) { return true; }
 Used to evaluate game version conditions.
 
std::function< bool(std::string)> fomm_eval_fun_ = [](auto s) { return true; }
 Used to evaluate fomm version conditions.
 

Detailed Description

Holds data and functions needed to pass a fomod file.

Member Function Documentation

◆ getFomodPath()

std::pair< std::string, std::string > FomodInstaller::getFomodPath ( const std::filesystem::path & source,
const std::string & file_name = "ModuleConfig.xml" )
staticprivate

Tries to find fomod/file_name in the given path.

Parameters
sourcePath to check.
file_nameFile name to search for.
Returns
Name of fomod directory and file, adapted to the actual capitalization.

◆ getInstallationFiles()

std::vector< std::pair< sfs::path, sfs::path > > FomodInstaller::getInstallationFiles ( const std::vector< std::vector< bool > > & selection = {})

Returns all files to be installed with current selection.

Parameters
selectionFor every group: for every plugin: True if selected.
Returns
Pair or source, destination paths for every file.

◆ getMetaData()

std::pair< std::string, std::string > FomodInstaller::getMetaData ( const std::filesystem::path & path)
static

Extracts mod name and version from a fomod info file in path/fomod/info.xml.

Parameters
pathMod root directory.
Returns
Mod name and version.

◆ hasNextStep()

bool FomodInstaller::hasNextStep ( const std::vector< std::vector< bool > > & selection) const

Checks if there is at least one more valid installation step.

Parameters
selectionCurrent plugin selection.
Returns
True if more steps exist.

◆ hasNoSteps()

bool FomodInstaller::hasNoSteps ( ) const

Checks if installation has not steps.

Returns
True if no steps where found.

◆ hasPreviousStep()

bool FomodInstaller::hasPreviousStep ( ) const

Checks if there is a previous installation step.

Returns
True if there is one.

◆ init()

void FomodInstaller::init ( const std::filesystem::path & config_file,
const std::filesystem::path & target_path = "",
const std::string & app_version = "" )

Initializes the installer.

Parameters
config_fileFomod file to be parsed.
target_pathInstallation target, this is only used to check file dependencies.

◆ initPlugin()

void FomodInstaller::initPlugin ( const pugi::xml_node & xml_node,
Plugin & plugin )
private

Initializes given plugin plugin from fomod node.

Parameters
xml_nodeSource node.
pluginTarget plugin.

◆ parseFileList()

void FomodInstaller::parseFileList ( const pugi::xml_node & file_list,
std::vector< File > & target_vector,
bool warn_missing = true )
private

Extracts all files from given file list node and appends them to given vector.

Parameters
file_listSource file list.
target_listExtracted files will be appended to this vector.
warn_missingIf true: Warn if a file is missing.

◆ parseGroupType()

PluginGroup::Type FomodInstaller::parseGroupType ( const std::string & type)
private

Determines group type from given string.

Parameters
typeSource string.
Returns
The type.

◆ parseInstallSteps()

void FomodInstaller::parseInstallSteps ( const pugi::xml_node & steps)
private

Extracts all install steps from given node and stores them in steps_.

Parameters
stepsSource node.

◆ parsePluginType()

PluginType FomodInstaller::parsePluginType ( const std::string & type)
private

Determines plugin type from given string.

Parameters
typeSource string.
Returns
The type.

◆ sortVector()

template<typename T>
void fomod::FomodInstaller::sortVector ( std::vector< T > & source,
std::string order )
inlineprivate

Sorts given vector according to given ordering type.

Parameters
sourceVector to be sorted.
orderOrdering type.

◆ step()

std::optional< InstallStep > FomodInstaller::step ( const std::vector< std::vector< bool > > & selection = {})

Advances installation process by one step.

Parameters
selectionFor every group: for every plugin: True if selected.
Returns
The next installation step, if one exists.

◆ stepBack()

std::optional< std::pair< std::vector< std::vector< bool > >, InstallStep > > FomodInstaller::stepBack ( )

Returns a pair of the previous installation step and the selections made at that step.

Returns
The step, if one exists.

◆ updateState()

void FomodInstaller::updateState ( const std::vector< std::vector< bool > > & selection)
private

Updates flags_ and files_ with selection.

Parameters
selectionFor every group: for every plugin: True if selected.

The documentation for this class was generated from the following files: