id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 12368,Improve property_tree documentation for path_of,harris.pc@…,Sebastian Redl,"There is no documentation on the path_of system, I did find this helpful email: http://lists.boost.org/Archives/boost/2009/06/152883.php It would be great if something like that were in the official documentation. In the end, I managed to create my own extension for storing a tree of filenames, here is the key code, just in case you feel its a good example for the documentation. (Code is still not fully tested) {{{ // a custom path-string, // I am not using fs::path because I need to treat a directory and a file // differently in terms of the name, where // a directory has a / on the end of its name. // This allows me to have a tree with a file and folder existing in the tree // at the same time (the file may have been replaced with the folder, so one // is deleted and the other is created). // class PathString { string filename; public: PathString( string const& p ) : filename(p) {} bool is_dir() const { return not empty() and filename[filename.size()-1] == '/'; } string const& str() const { return filename; } bool empty() const { return filename.empty(); } bool operator<( PathString const& b ) const { return filename < b.filename; } bool operator==( PathString const& b ) const { return filename == b.filename; } }; namespace boost { namespace property_tree { // specialisation of path_of for PathString template <> struct path_of { struct type { std::string filename; std::string::size_type start, size; public: type( std::string const& s ) : filename(s), start(0), size(filename.size()) {} std::string dump() const { return filename.substr(start); } bool empty() const { return start == size; } // aka pop_front() and return the fragment // modifies this value std::string reduce() { assert(not empty()); std::string::size_type next_sep = filename.find('/', start); // no separator, or separator found at the end if (next_sep == std::string::npos or next_sep+1 == size) { std::string part; part.swap(filename); return part; } // include the trailing separator std::string::size_type old_start = start; start = next_sep+1; return filename.substr(old_start, start-old_start); } bool single() const { // will return true if empty, it should not be asked for empty paths anyway // it is a ""single"" path if there is a slash BEFORE the last character. // if the last character is /, then it can be a ""single"" directory. // // so check if idx < filename.size()-1 --therefore--> idx+1 < filename.size() std::string::size_type idx = filename.find('/'); return idx == std::string::npos or idx+1 < filename.size(); } }; }; }}}",Feature Requests,new,To Be Determined,property_tree,Boost 1.61.0,Problem,,,