mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches

An application configuration manager. More...

An application configuration manager.

Author
Jared R. Males

Definition in file appConfigurator.hpp.

#include <list>
#include <fstream>
#include <format>
#include "../mxlib.hpp"
#include "clOptions.hpp"
#include "iniFile.hpp"
#include "configTarget.hpp"

Go to the source code of this file.

Classes

struct  mx::app::appConfigurator
 Class to manage a set of configurable values, and read their values from config/ini files and the command line. More...

Namespaces

namespace  mx
 The mxlib c++ namespace.

Functions

void mx::app::writeConfigFile (const std::string &fname, const std::vector< std::string > &sections, const std::vector< std::string > &keywords, const std::vector< std::string > &values)
 A simple config file writing function, useful for testing.

Variables

int(* mx::app::detail::appConfiguratorParser )(iniFile &parser, const std::string &filename)
 Optional parser override used to deterministically test appConfigurator parser failures.

Function Documentation

◆ writeConfigFile()

void mx::app::writeConfigFile ( const std::string & fname,
const std::vector< std::string > & sections,
const std::vector< std::string > & keywords,
const std::vector< std::string > & values )

A simple config file writing function, useful for testing.

Write a config file to the path specified by fname. Each of the parameters is a vector, and each component is required of each vector.

Example:

writeConfigFile( "/tmp/test.conf", {"", "", "sect1", "sect1", "sect2", "sect2"},
{"key0", "key1", "key2", "key3", "key4", "key5"},
{"val0", "val1", "val2", "val3", "val4", "val5"} );

results in the file /tmp/test.conf containing

key0=val0
key1=val1

[sect1]
key2=val2
key3=val3

[sect2]
key4=val4
key5=val5

* 

No error checking is done.

Parameters
[in]fnamethe complete path for the output file.
[in]sectionssections, one per config value
[in]keywordskeywords, one per config value
[in]valuesthe values

Definition at line 893 of file appConfigurator.cpp.

Variable Documentation

◆ appConfiguratorParser

int(* mx::app::detail::appConfiguratorParser) (iniFile &parser, const std::string &filename) ( iniFile & parser,
const std::string & filename )
inline
Initial value:
=
nullptr

Optional parser override used to deterministically test appConfigurator parser failures.

Parameters
[in,out]parserparser receiving file contents.
[in]filenamefile requested by readConfig.

Definition at line 50 of file appConfigurator.hpp.