Turi Create
4.0
|
Simple ini parsing utilities. More...
Functions | |
template<typename T > | |
std::vector< T > | turi::ini::read_sequence_section (const boost::property_tree::ptree &data, std::string key, size_t expected_elements) |
template<typename T > | |
std::map< std::string, T > | turi::ini::read_dictionary_section (const boost::property_tree::ptree &data, std::string key) |
template<typename T > | |
void | turi::ini::write_sequence_section (boost::property_tree::ptree &data, const std::string &key, const std::vector< T > &values) |
template<typename T > | |
void | turi::ini::write_dictionary_section (boost::property_tree::ptree &data, const std::string &key, const std::map< std::string, T > &values) |
Simple ini parsing utilities.
std::map<std::string, T> turi::ini::read_dictionary_section | ( | const boost::property_tree::ptree & | data, |
std::string | key | ||
) |
Reads a key in an ini/json file as a dictionary of values. In the ini file this will be represented as
[key] fish = "hello" and = "pika" chips = "chu"
In a JSON file this will be represented as {"fish":"hello", "and":"pika", "chips":"chu"}
This will return a 3 element map containing {"fish":"hello", "and":"pika", "chips":"chu"}.
Definition at line 99 of file boost_property_tree_utils.hpp.
std::vector<T> turi::ini::read_sequence_section | ( | const boost::property_tree::ptree & | data, |
std::string | key, | ||
size_t | expected_elements | ||
) |
Reads a key in an ini/json file as a sequence of values. In the ini file this will be represented as
[key] 0000 = "hello" 0001 = "pika" 0002 = "chu"
But in a JSON file this could be {"0000":"hello","0001":"pika","0002":"chu"} or ["hello","pika","chu"] depending on which writer is used. (The boost property tree writer will create the first, a regular JSON writer will create the second).
This will return a 3 element vector containing {"hello", "pika", "chu"}
Definition at line 48 of file boost_property_tree_utils.hpp.
void turi::ini::write_dictionary_section | ( | boost::property_tree::ptree & | data, |
const std::string & | key, | ||
const std::map< std::string, T > & | values | ||
) |
Writes a dictionary of values into an ini file as a section. For instance, given a 3 element map containing {"fish":"hello", "and":"pika", "chips":"chu"}.
In the ini file this will be represented as:
[key] fish = "hello" and = "pika" chips = "chu"
Definition at line 161 of file boost_property_tree_utils.hpp.
void turi::ini::write_sequence_section | ( | boost::property_tree::ptree & | data, |
const std::string & | key, | ||
const std::vector< T > & | values | ||
) |
Writes a vector of values into an ini file as a section.
For instance, given a 3 element vector containing {"hello", "pika", "chu"} The vector be represented as
[key] 0000 = "hello" 0001 = "pika" 0002 = "chu"
Definition at line 133 of file boost_property_tree_utils.hpp.