void print_ptree(std::ostream& os, const boost::property_tree::ptree& pt, int depth) { typedef bp::ptree::const_iterator c_it; if(pt.empty()) os << "'" << pt.data() << "'\n"; else { std::string pad(""); pad.assign(depth*4,' '); ++depth; std::string pad2 = pad + " "; if(is_list(pt)) { os << "[\n"; for(c_it it=pt.begin(); it!=pt.end(); ++it) { os << pad2; print_ptree(os, it->second, depth); } os << pad << "]\n"; } else { os << "{\n"; for(c_it it=pt.begin(); it!=pt.end(); ++it) { os << pad2 << "'" << it->first << "': "; print_ptree(os, it->second, depth); } os << pad << "}\n"; } } }
int getPtree(int fd, int pid) { int ioctl_result; ptree.pid = pid; ioctl_result = ioctl(fd, IOCTL_GET_PTREE, &ptree); if (ioctl_result < 0) return -1; else { print_header(profilee); print_ptree(); return 0; } }
std::ostream& operator<<(std::ostream& os, const boost::property_tree::ptree& pt) { print_ptree(os, pt, 0); return os; }