Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::property_tree::ini_parser Namespace Reference

Namespaces

 detail
 

Classes

class  ini_parser_error
 Indicates an error parsing INI formatted data. More...
 

Functions

bool validate_flags (int flags)
 Determines whether the flags are valid for use with the ini_parser. More...
 
template<class Ptree >
void read_ini (std::basic_istream< typename Ptree::key_type::value_type > &stream, Ptree &pt)
 Read INI from a the given stream and translate it to a property tree. More...
 
template<class Ptree >
void read_ini (const std::string &filename, Ptree &pt, const std::locale &loc=std::locale())
 Read INI from a the given file and translate it to a property tree. More...
 
template<class Ptree >
void write_ini (std::basic_ostream< typename Ptree::key_type::value_type > &stream, const Ptree &pt, int flags=0)
 Translates the property tree to INI and writes it the given output stream. More...
 
template<class Ptree >
void write_ini (const std::string &filename, const Ptree &pt, int flags=0, const std::locale &loc=std::locale())
 Translates the property tree to INI and writes it the given file. More...
 

Function Documentation

template<class Ptree >
void boost::property_tree::ini_parser::read_ini ( std::basic_istream< typename Ptree::key_type::value_type > &  stream,
Ptree &  pt 
)

Read INI from a the given stream and translate it to a property tree.

Note
Clears existing contents of property tree. In case of error the property tree is not modified.
Exceptions
ini_parser_errorIf a format violation is found.
Parameters
streamStream from which to read in the property tree.
[out]ptThe property tree to populate.

References BOOST_PROPERTY_TREE_THROW, boost::proto::envns_::data, boost::end, boost::container::getline(), boost::locale::boundary::line, boost::local(), boost::xpressive::make_pair, boost::expressions::stream, and boost::algorithm::trim().

Referenced by read_ini().

template<class Ptree >
void boost::property_tree::ini_parser::read_ini ( const std::string &  filename,
Ptree &  pt,
const std::locale &  loc = std::locale() 
)

Read INI from a the given file and translate it to a property tree.

Note
Clears existing contents of property tree. In case of error the property tree unmodified.
Exceptions
ini_parser_errorIn case of error deserializing the property tree.
Parameters
filenameName of file from which to read in the property tree.
[out]ptThe property tree to populate.
locThe locale to use when reading in the file contents.

References BOOST_PROPERTY_TREE_THROW, read_ini(), and boost::expressions::stream.

bool boost::property_tree::ini_parser::validate_flags ( int  flags)
inline

Determines whether the flags are valid for use with the ini_parser.

Parameters
flagsvalue to check for validity as flags to ini_parser.
Returns
true if the flags are valid, false otherwise.

Referenced by boost::property_tree::xml_parser::read_xml(), and write_ini().

template<class Ptree >
void boost::property_tree::ini_parser::write_ini ( std::basic_ostream< typename Ptree::key_type::value_type > &  stream,
const Ptree &  pt,
int  flags = 0 
)

Translates the property tree to INI and writes it the given output stream.

Precondition
pt cannot have data in its root.
pt cannot have keys both data and children.
pt cannot be deeper than two levels.
There cannot be duplicate keys on any given level of pt.
Exceptions
ini_parser_errorIn case of error translating the property tree to INI or writing to the output stream.
Parameters
streamThe stream to which to write the INI representation of the property tree.
ptThe property tree to tranlsate to INI and output.
flagsThe flags to use when writing the INI file. No flags are currently supported.

References BOOST_ASSERT, BOOST_PROPERTY_TREE_THROW, boost::property_tree::ini_parser::detail::check_dupes(), boost::end, boost::it, boost::expressions::stream, validate_flags(), and boost::detail::void.

Referenced by write_ini().

template<class Ptree >
void boost::property_tree::ini_parser::write_ini ( const std::string &  filename,
const Ptree &  pt,
int  flags = 0,
const std::locale &  loc = std::locale() 
)

Translates the property tree to INI and writes it the given file.

Precondition
pt cannot have data in its root.
pt cannot have keys both data and children.
pt cannot be deeper than two levels.
There cannot be duplicate keys on any given level of pt.
Exceptions
info_parser_errorIn case of error translating the property tree to INI or writing to the file.
Parameters
filenameThe name of the file to which to write the INI representation of the property tree.
ptThe property tree to tranlsate to INI and output.
flagsThe flags to use when writing the INI file. The following flags are supported:
  • skip_ini_validity_check – Skip check if ptree is a valid ini. The validity check covers the preconditions but takes O(n log n) time.
locThe locale to use when writing the file.

References BOOST_PROPERTY_TREE_THROW, boost::expressions::stream, and write_ini().