내 프로젝트에서 boost ptree를 사용하고 싶지만 ptree.hpp에 1000 개의 헤더 파일이 포함되어 있기 때문에 컴파일 시간이 크게 늘어납니다 (예 : 1에서 7까지) 20 개 이상의 서로 다른 cpp 파일에 필요하기 때문에 이것은 수용 할 수 없습니다 (미리 컴파일 된 헤더는 많은 것을 향상시키지 않습니다). 그래서 나는 좋은 방법의 반복자를 구현하는 데 실패하고있어, 그러나전달하는 방법 boost :: ptree :: iterator
// myptree.h
#include <boost/property_tree/ptree_fwd.hpp>
class myptree {
private:
boost::property_tree::ptree *m_tree;
public:
...
// adding new (single value) members to the the tree
void put(const std::string&, double);
void put(const std::string&, int);
void put(const std::string&, const std::string&);
// returning (single value) members of the tree
double get_double(const std::string&) const;
int get_int(const std::string&) const;
std::string get_str(const std::string&) const;
// working with subtrees
void push_back(const std::string&, const myptree&);
myptree get_child(const std::string&) const;
// import/export
void read_from_json(const std::string&);
void write_to_json(const std::string&) const;
};
같은 부스트 내 자신의 클래스 ptree, 뭔가를 캡슐화 생각 해요. 이상적으로 boost::property_tree::ptree::iterator
내 개인 멤버 함수를 사용하여 m_tree
통해 반복 될 수있는 개인 멤버 변수를 갖고 싶지만 내가 이해할 때 How do I forward declare an inner class? 일반적으로 불가능합니다. 이 클래스 내에 반복자를 구현하는 우아한 방법?
관련 : http://stackoverflow.com/questions/156936 –