NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
config-file.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MANAGEMENT_CONFIG_FILE_HPP
23 #define NDN_MANAGEMENT_CONFIG_FILE_HPP
24 
25 #include "../common.hpp"
26 
27 #include <fstream>
28 
29 #include <boost/property_tree/ptree.hpp>
30 #include <boost/filesystem.hpp>
31 
32 namespace ndn {
33 
48 class ConfigFile : noncopyable
49 {
50 public:
51 
52  class Error : public std::runtime_error
53  {
54  public:
55  Error(const std::string& what)
56  : std::runtime_error(what)
57  {
58 
59  }
60  };
61 
62  typedef boost::property_tree::ptree Parsed;
63 
69  ConfigFile();
70 
71  ~ConfigFile();
72 
73  const boost::filesystem::path&
74  getPath() const;
75 
76  const Parsed&
77  getParsedConfiguration() const;
78 
79 private:
80 
81  bool
82  open();
83 
84  void
85  close();
86 
97  const Parsed&
98  parse();
99 
112  boost::filesystem::path
113  findConfigFile();
114 
115 private:
116  boost::filesystem::path m_path; // absolute path to active configuration file (if any)
117  std::ifstream m_input;
118  Parsed m_config;
119 };
120 
121 inline const boost::filesystem::path&
123 {
124  return m_path;
125 }
126 
127 inline const ConfigFile::Parsed&
129 {
130  return m_config;
131 }
132 
133 } // namespace ndn
134 
135 
136 #endif // NDN_MANAGEMENT_CONFIG_FILE_HPP
Copyright (c) 2011-2015 Regents of the University of California.
STL namespace.
boost::property_tree::ptree Parsed
Definition: config-file.hpp:62
System configuration file for NDN platform.
Definition: config-file.hpp:48
ConfigFile()
Locate, open, and parse a library configuration file.
Definition: config-file.cpp:29
const boost::filesystem::path & getPath() const
Error(const std::string &what)
Definition: config-file.hpp:55
const Parsed & getParsedConfiguration() const