Large refactoring. Also, reimplemented resource manager to use parsers. Changed from json to xml (it allows comments!!!).
This commit is contained in:
43
src/utils/DumpPropertyTree.cpp
Normal file
43
src/utils/DumpPropertyTree.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* S.cpp
|
||||
*
|
||||
* Created on: Dec 1, 2016
|
||||
* Author: tibi
|
||||
*/
|
||||
|
||||
#include <utils/DumpPropertyTree.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
namespace farmlands {
|
||||
namespace utils {
|
||||
|
||||
void dumpPropertyTreeInternal(boost::property_tree::ptree& tree, unsigned level)
|
||||
{
|
||||
for (auto child : tree)
|
||||
{
|
||||
for (unsigned i = 0; i < level; i++)
|
||||
std::cout << " ";
|
||||
|
||||
std::string data = child.second.data();
|
||||
boost::trim(data);
|
||||
|
||||
std::cout<< "* " << child.first <<" = " << data << "\n";
|
||||
|
||||
dumpPropertyTreeInternal(child.second, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void dumpPropertyTree(boost::property_tree::ptree& tree)
|
||||
{
|
||||
std::string data = tree.data();
|
||||
boost::trim(data);
|
||||
|
||||
std::cout << "[root] = " << data << "\n";
|
||||
|
||||
dumpPropertyTreeInternal(tree, 1);
|
||||
}
|
||||
|
||||
} /* namespace utils */
|
||||
} /* namespace farmlands */
|
21
src/utils/DumpPropertyTree.h
Normal file
21
src/utils/DumpPropertyTree.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* S.h
|
||||
*
|
||||
* Created on: Dec 1, 2016
|
||||
* Author: tibi
|
||||
*/
|
||||
|
||||
#ifndef UTILS_DUMPPROPERTYTREE_H_
|
||||
#define UTILS_DUMPPROPERTYTREE_H_
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace farmlands {
|
||||
namespace utils {
|
||||
|
||||
void dumpPropertyTree(boost::property_tree::ptree& tree);
|
||||
|
||||
} /* namespace utils */
|
||||
} /* namespace farmlands */
|
||||
|
||||
#endif /* UTILS_DUMPPROPERTYTREE_H_ */
|
@@ -36,7 +36,9 @@ Exception::~Exception()
|
||||
}
|
||||
|
||||
|
||||
DEFINE_EXCEPTION_CPP(InvalidArgumentException, Exception)
|
||||
DEFINE_EXCEPTION_CPP(InvalidArgumentException, Exception);
|
||||
DEFINE_EXCEPTION_CPP(NotImplementedException, Exception);
|
||||
|
||||
DEFINE_EXCEPTION_CPP(IOException, Exception);
|
||||
DEFINE_EXCEPTION_CPP(ResourceLoadException, IOException);
|
||||
|
||||
|
@@ -65,8 +65,10 @@ namespace utils {
|
||||
|
||||
|
||||
// Common exceptions
|
||||
|
||||
DEFINE_EXCEPTION_CLASS(InvalidArgumentException, Exception);
|
||||
DEFINE_EXCEPTION_CLASS(NotImplementedException, Exception);
|
||||
|
||||
// IO Exceptions
|
||||
DEFINE_EXCEPTION_CLASS(IOException, Exception);
|
||||
DEFINE_EXCEPTION_CLASS(ResourceLoadException, IOException);
|
||||
|
||||
|
Reference in New Issue
Block a user