X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tools%2Fquickbook%2Fsrc%2Ffiles.hpp;h=0a2e5309c55e5b7a60b54fc80d99977ab118904f;hb=08c1e93fa36a49f49325a07fe91ff92c964c2b6c;hp=4f217e70cd8090ae75eff87e7708350100ab9142;hpb=bb4dd8289b351fae6b55e303f189127a394a1edd;p=platform%2Fupstream%2Fboost.git diff --git a/tools/quickbook/src/files.hpp b/tools/quickbook/src/files.hpp index 4f217e7..0a2e530 100644 --- a/tools/quickbook/src/files.hpp +++ b/tools/quickbook/src/files.hpp @@ -14,8 +14,10 @@ #include #include #include +#include #include #include +#include namespace quickbook { @@ -31,6 +33,13 @@ namespace quickbook { int line; int column; + + bool operator==(file_position const& other) const + { + return line == other.line && column == other.column; + } + + friend std::ostream& operator<<(std::ostream&, file_position const&); }; struct file @@ -41,21 +50,23 @@ namespace quickbook { file(file const&); public: fs::path const path; - std::string source; + std::string source_; bool is_code_snippets; private: unsigned qbk_version; unsigned ref_count; public: + boost::string_ref source() const { return source_; } - file(fs::path const& path, std::string const& source, + file(fs::path const& path, boost::string_ref source, unsigned qbk_version) : - path(path), source(source), is_code_snippets(false), + path(path), source_(source.begin(), source.end()), is_code_snippets(false), qbk_version(qbk_version), ref_count(0) {} - file(file const& f, std::string const& source) : - path(f.path), source(source), is_code_snippets(f.is_code_snippets), + file(file const& f, boost::string_ref source) : + path(f.path), source_(source.begin(), source.end()), + is_code_snippets(f.is_code_snippets), qbk_version(f.qbk_version), ref_count(0) {} @@ -76,7 +87,7 @@ namespace quickbook { qbk_version = v; } - virtual file_position position_of(std::string::const_iterator) const; + virtual file_position position_of(boost::string_ref::const_iterator) const; friend void intrusive_ptr_add_ref(file* ptr) { ++ptr->ref_count; } @@ -101,8 +112,8 @@ namespace quickbook { struct mapped_file_builder { - typedef std::string::const_iterator iterator; - typedef std::string::size_type pos; + typedef boost::string_ref::const_iterator iterator; + typedef boost::string_ref::size_type pos; mapped_file_builder(); ~mapped_file_builder(); @@ -114,12 +125,11 @@ namespace quickbook { bool empty() const; pos get_pos() const; - void add(char const*, iterator); - void add(std::string const&, iterator); - void add(iterator, iterator); + void add_at_pos(boost::string_ref, iterator); + void add(boost::string_ref); void add(mapped_file_builder const&); void add(mapped_file_builder const&, pos, pos); - void unindent_and_add(iterator, iterator); + void unindent_and_add(boost::string_ref); private: mapped_file_builder_data* data;