ifw-core
2.0.0
|
Classes | |
class | ParameterFile |
Class to handle a set of parameters. More... | |
class | Yaml |
Class implementing the handling of Yaml files in the ICS environment. More... | |
Enumerations | |
enum | RootType { SYSROOT = 1, INTROOT = 2, DATAROOT = 4, CFGPATH = 8, ROOTS_ALL = (SYSROOT | INTROOT | DATAROOT | CFGPATH), CFG_INT_ROOT = (CFGPATH | INTROOT) } |
Types of ELT deployment environment roots. More... | |
enum | ResourceType { RES_CONFIG = 1, RES_AUDIO = 2, RES_IMAGE = 4, RES_MODEL = 8, RES_DICTIONARY = 16, RES_DATA = 32, RES_ALL } |
Functions | |
std::string | RootVarTypeNbToString (const RootType type) |
Convert root type from number to string representation. More... | |
RootType | RootVarTypeStringToNb (const std::string &type) |
Convert root type from string to number representation. More... | |
std::string | ResDirNbToString (const ResourceType type) |
Convert resource type from number to string representation. More... | |
ResourceType | ResDirStringToNb (const std::string &type) |
Convert resource type from string to number representation. More... | |
std::string | CheckAddExtension (const std::string &filename, const std::string &extension) |
Check if filename has the specified extension (no initiating dot). If not, add it. More... | |
void | RemoveFile (const std::string &filename) |
Remove the referenced file, if it exists. More... | |
std::string | CreateIfwFilename (const std::string &filename, const RootType root, const ResourceType resource, const std::string &extension="") |
Create a resource path in the IFW deployment environment. More... | |
std::string | ResolvePath (const std::string &filename) |
Resolve the filename if it contains env. variables, "~" and relative paths. More... | |
std::string | FindFile (const std::string &filename, RootType roots=RootType::ROOTS_ALL, int32_t resources=RES_ALL, const bool exception=true) |
Locate file in the locations defined by the ELT ICS deployment environment. More... | |
std::string | LoadFile (const std::string &filename, std::string *complete_filename=nullptr, RootType roots=RootType::ROOTS_ALL, ResourceType resources=RES_ALL) |
Load a file and return the content. More... | |
void | SaveFile (const std::string &filename, const std::string &buffer, const bool overwrite=true) |
Save the contents inthe buffer into the given filename. More... | |
Variables | |
const std::string | SYSROOT_STR = "SYSROOT" |
const std::string | INTROOT_STR = "INTROOT" |
const std::string | DATAROOT_STR = "DATAROOT" |
const std::string | CFGPATH_STR = "CFGPATH" |
const std::string | RES_DIR = "resource" |
const std::string | RES_CONFIG_STR = "config" |
const std::string | RES_AUDIO_STR = "audio" |
const std::string | RES_IMAGE_STR = "image" |
const std::string | RES_MODEL_STR = "model" |
const std::string | RES_DICTIONARY_STR = "dictionary" |
const std::string | RES_DATA_STR = "data" |
enum ctd::file::RootType |
std::string ctd::file::CheckAddExtension | ( | const std::string & | filename, |
const std::string & | extension | ||
) |
Check if filename has the specified extension (no initiating dot). If not, add it.
std::string ctd::file::CreateIfwFilename | ( | const std::string & | filename, |
const RootType | root, | ||
const ResourceType | resource, | ||
const std::string & | extension | ||
) |
Create a resource path in the IFW deployment environment.
std::string ctd::file::FindFile | ( | const std::string & | filename, |
RootType | roots = RootType::ROOTS_ALL , |
||
int32_t | resources = RES_ALL , |
||
const bool | exception = true |
||
) |
Locate file in the locations defined by the ELT ICS deployment environment.
[in] | filename | Filename to find. |
[out] | completeFilename | Complete name of file located. |
[in] | roots | Specifies in which root or roots to look. |
[in] | resources | Specify the type of resource or resources. |
[in] | exception | If true, throw exception if no matching file found. |
Deprecated: Use rad::FindFile() instead.
The function is used to resolve the input filename and to check the location.
Typically it is known which type of resource file is concerned, so that only one type is given.
If several roots are specified, the order in which files are checked for are:
If a configuration resource file type is in question, the function should be called like e.g.:
std::string completeName; ctd::file::File::FindFile("myProj/myPkg/myMod/myConfiguration.cfg", completeName, (CFGROOT & INTROOT), RES_CONFIG);
The input filename name shall be given with the namespace of the context, i.e., the module in which it lives and under which directory it will be installed in the appropriate root.
The function does not attempt to add an extension to the input name, which consequently must be given.
std::string ctd::file::LoadFile | ( | const std::string & | filename, |
std::string * | complete_filename = nullptr , |
||
RootType | roots = RootType::ROOTS_ALL , |
||
ResourceType | resources = RES_ALL |
||
) |
Load a file and return the content.
filename | Name of the file. The file may be searched for in the ICS file locations. |
roots | The ICS deployment root directories to check for the file (if applicable). |
resources | Type of resource locations to check for the file (if applicable). |
If the complete path of the file is given, the parameters "RootTypes" and "ResourceTypes" have no effect.
void ctd::file::RemoveFile | ( | const std::string & | filename | ) |
Remove the referenced file, if it exists.
std::string ctd::file::ResDirNbToString | ( | ResourceType | type | ) |
Convert resource type from number to string representation.
ResourceType ctd::file::ResDirStringToNb | ( | const std::string & | type | ) |
Convert resource type from string to number representation.
std::string ctd::file::ResolvePath | ( | const std::string & | filename | ) |
Resolve the filename if it contains env. variables, "~" and relative paths.
std::string ctd::file::RootVarTypeNbToString | ( | RootType | type | ) |
Convert root type from number to string representation.
RootType ctd::file::RootVarTypeStringToNb | ( | const std::string & | type | ) |
Convert root type from string to number representation.
void ctd::file::SaveFile | ( | const std::string & | filename, |
const std::string & | buffer, | ||
const bool | overwrite = true |
||
) |
Save the contents inthe buffer into the given filename.
filename | Name of file. Will be resolve, if necessary. |
buffer | Buffer to write into the file. |
overwrite | Overwrite (replace) file if already existing. |
const std::string ctd::file::CFGPATH_STR = "CFGPATH" |
const std::string ctd::file::DATAROOT_STR = "DATAROOT" |
const std::string ctd::file::INTROOT_STR = "INTROOT" |
const std::string ctd::file::RES_AUDIO_STR = "audio" |
const std::string ctd::file::RES_CONFIG_STR = "config" |
const std::string ctd::file::RES_DATA_STR = "data" |
const std::string ctd::file::RES_DICTIONARY_STR = "dictionary" |
const std::string ctd::file::RES_DIR = "resource" |
const std::string ctd::file::RES_IMAGE_STR = "image" |
const std::string ctd::file::RES_MODEL_STR = "model" |
const std::string ctd::file::SYSROOT_STR = "SYSROOT" |