24 #include <boost/property_tree/ini_parser.hpp>    25 #include <boost/filesystem.hpp>    30   : m_path(findConfigFile())
    43 boost::filesystem::path
    44 ConfigFile::findConfigFile()
    46   using namespace boost::filesystem;
    48 #ifdef NDN_CXX_HAVE_TESTS    49   if (std::getenv(
"TEST_HOME")) {
    50     path testHome(std::getenv(
"TEST_HOME"));
    51     testHome /= 
".ndn/client.conf";
    52     if (exists(testHome)) {
    53       return absolute(testHome);
    56 #endif // NDN_CXX_HAVE_TESTS    58   if (std::getenv(
"HOME")) {
    59     path home(std::getenv(
"HOME"));
    60     home /= 
".ndn/client.conf";
    62       return absolute(home);
    66 #ifdef NDN_CXX_SYSCONFDIR    67   path sysconfdir(NDN_CXX_SYSCONFDIR);
    68   sysconfdir /= 
"ndn/client.conf";
    69   if (exists(sysconfdir)) {
    70     return absolute(sysconfdir);
    72 #endif // NDN_CXX_SYSCONFDIR    74   path etc(
"/etc/ndn/client.conf");
    89   m_input.open(m_path.c_str());
    90   if (!m_input.good() || !m_input.is_open()) {
    99   if (m_input.is_open()) {
   107   if (m_path.empty()) {
   108     NDN_THROW(
Error(
"Failed to locate configuration file for parsing"));
   110   if (!m_input.is_open() && !open()) {
   111     NDN_THROW(
Error(
"Failed to open configuration file for parsing"));
   115     boost::property_tree::read_ini(m_input, m_config);
   117   catch (
const boost::property_tree::ini_parser_error& error) {
   118     NDN_THROW(
Error(
"Failed to parse configuration file " + error.filename() +
   119                     " line " + 
to_string(error.line()) + 
": " + error.message()));
 
std::string to_string(const T &val)
boost::property_tree::ptree Parsed
ConfigFile()
Locate, open, and parse a library configuration file.