MLPACK  1.0.10
save_restore_utility.hpp
Go to the documentation of this file.
1 
25 #ifndef __MLPACK_CORE_UTIL_SAVE_RESTORE_UTILITY_HPP
26 #define __MLPACK_CORE_UTIL_SAVE_RESTORE_UTILITY_HPP
27 
28 #include <mlpack/prereqs.hpp>
29 #include <list>
30 #include <map>
31 #include <sstream>
32 #include <string>
33 
34 #include <libxml/parser.h>
35 #include <libxml/tree.h>
36 
37 #include <boost/tokenizer.hpp>
38 
39 namespace mlpack {
40 namespace util {
41 
43 {
44  private:
48  std::map<std::string, std::string> parameters;
49 
53  void RecurseOnNodes(xmlNode* n);
54 
55  public:
58 
62  bool ReadFile(const std::string& filename);
63 
67  bool WriteFile(const std::string& filename);
68 
72  template<typename T>
73  T& LoadParameter(T& t, const std::string& name);
74 
78  template<typename T>
79  std::vector<T>& LoadParameter(std::vector<T>& v, const std::string& name);
80 
84  char LoadParameter(char c, const std::string& name);
85 
89  std::string LoadParameter(std::string& str, const std::string& name);
90 
94  arma::mat& LoadParameter(arma::mat& matrix, const std::string& name);
95 
99  template<typename T>
100  void SaveParameter(const T& t, const std::string& name);
101 
102 
103 
107  template<typename T>
108  void SaveParameter(const std::vector<T>& v, const std::string& name);
109 
113  void SaveParameter(const char c, const std::string& name);
114 
118  void SaveParameter(const arma::mat& mat, const std::string& name);
119 };
120 
122 template<>
123 arma::vec& SaveRestoreUtility::LoadParameter(arma::vec& t,
124  const std::string& name);
125 
127 template<>
128 void SaveRestoreUtility::SaveParameter(const arma::vec& t,
129  const std::string& name);
130 
131 }; /* namespace util */
132 }; /* namespace mlpack */
133 
134 // Include implementation.
135 #include "save_restore_utility_impl.hpp"
136 
137 #endif