diff --git a/src/actions.cpp b/src/actions.cpp index 67520e7..4f54420 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -65,7 +65,7 @@ namespace quickbook } std::string add_anchor(quickbook::state& state, - boost::string_ref id, + quickbook::string_view id, id_category::categories category = id_category::explicit_anchor_id) { @@ -536,7 +536,7 @@ namespace quickbook if (saved_conditional) { - boost::string_ref macro1 = values.consume().get_quickbook(); + quickbook::string_view macro1 = values.consume().get_quickbook(); std::string macro(macro1.begin(), macro1.end()); state.conditional = find(state.macro, macro.c_str()); @@ -760,7 +760,7 @@ namespace quickbook int code_tag = code_block.get_tag(); value_consumer values = code_block; - boost::string_ref code_value = values.consume().get_quickbook(); + quickbook::string_view code_value = values.consume().get_quickbook(); values.finish(); bool inline_code = code_tag == code_tags::inline_code || @@ -870,8 +870,8 @@ namespace quickbook detail::print_string(v.get_encoded(), out); } else { - boost::string_ref value = v.get_quickbook(); - for(boost::string_ref::const_iterator + quickbook::string_view value = v.get_quickbook(); + for(quickbook::string_view::const_iterator first = value.begin(), last = value.end(); first != last; ++first) { @@ -1267,7 +1267,7 @@ namespace quickbook file_ptr saved_current_file = state.current_file; state.current_file = content.get_file(); - boost::string_ref source = content.get_quickbook(); + quickbook::string_view source = content.get_quickbook(); parse_iterator first(source.begin()); parse_iterator last(source.end()); diff --git a/src/code_snippet.cpp b/src/code_snippet.cpp index fe54f46..5b5fc72 100644 --- a/src/code_snippet.cpp +++ b/src/code_snippet.cpp @@ -87,8 +87,8 @@ namespace quickbook } mapped_file_builder content; - boost::string_ref::const_iterator mark_begin, mark_end; - boost::string_ref::const_iterator last_code_pos; + quickbook::string_view::const_iterator mark_begin, mark_end; + quickbook::string_view::const_iterator last_code_pos; bool in_code; boost::shared_ptr snippet_stack; std::vector& storage; @@ -382,7 +382,7 @@ namespace quickbook in_code = true; } - content.add(boost::string_ref(last_code_pos, first - last_code_pos)); + content.add(quickbook::string_view(last_code_pos, first - last_code_pos)); } } @@ -419,7 +419,7 @@ namespace quickbook in_code = true; } - content.add(boost::string_ref(mark_begin, mark_end - mark_begin)); + content.add(quickbook::string_view(mark_begin, mark_end - mark_begin)); } void code_snippet_actions::escaped_comment(string_iterator first, string_iterator last) @@ -437,7 +437,7 @@ namespace quickbook snippet_data& snippet = *snippet_stack; content.add_at_pos("\n", mark_begin); - content.unindent_and_add(boost::string_ref(mark_begin, mark_end - mark_begin)); + content.unindent_and_add(quickbook::string_view(mark_begin, mark_end - mark_begin)); if (snippet.id == "!") { diff --git a/src/document_state.cpp b/src/document_state.cpp index 2841389..9e84c90 100644 --- a/src/document_state.cpp +++ b/src/document_state.cpp @@ -33,7 +33,7 @@ namespace quickbook // Constructor for files that aren't the root of a document. file_info(boost::shared_ptr const& parent, unsigned compatibility_version, - boost::string_ref doc_id_1_1, + quickbook::string_view doc_id_1_1, id_placeholder const* override_id) : parent(parent), document(parent->document), compatibility_version(compatibility_version), @@ -47,7 +47,7 @@ namespace quickbook file_info(boost::shared_ptr const& parent, boost::shared_ptr const& document, unsigned compatibility_version, - boost::string_ref doc_id_1_1) : + quickbook::string_view doc_id_1_1) : parent(parent), document(document), compatibility_version(compatibility_version), depth(0), override_depth(0), override_id(0), @@ -77,8 +77,8 @@ namespace quickbook source_mode_info const source_mode; section_info(boost::shared_ptr const& parent, - file_info const* current_file, boost::string_ref id, - boost::string_ref id_1_1, id_placeholder const* placeholder_1_6, + file_info const* current_file, quickbook::string_view id, + quickbook::string_view id_1_1, id_placeholder const* placeholder_1_6, source_mode_info const& source_mode) : parent(parent), compatibility_version(current_file->compatibility_version), @@ -102,8 +102,8 @@ namespace quickbook void document_state::start_file( unsigned compatibility_version, - boost::string_ref include_doc_id, - boost::string_ref id, + quickbook::string_view include_doc_id, + quickbook::string_view id, value const& title) { state->start_file(compatibility_version, false, include_doc_id, id, title); @@ -111,8 +111,8 @@ namespace quickbook std::string document_state::start_file_with_docinfo( unsigned compatibility_version, - boost::string_ref include_doc_id, - boost::string_ref id, + quickbook::string_view include_doc_id, + quickbook::string_view id, value const& title) { return state->start_file(compatibility_version, true, include_doc_id, @@ -124,7 +124,7 @@ namespace quickbook state->end_file(); } - std::string document_state::begin_section(boost::string_ref id, + std::string document_state::begin_section(quickbook::string_view id, id_category category, source_mode_info const& source_mode) { return state->begin_section(id, category, source_mode)->to_string(); @@ -147,28 +147,28 @@ namespace quickbook source_mode_info(); } - std::string document_state::old_style_id(boost::string_ref id, id_category category) + std::string document_state::old_style_id(quickbook::string_view id, id_category category) { return state->old_style_id(id, category)->to_string(); } - std::string document_state::add_id(boost::string_ref id, id_category category) + std::string document_state::add_id(quickbook::string_view id, id_category category) { return state->add_id(id, category)->to_string(); } - std::string document_state::add_anchor(boost::string_ref id, id_category category) + std::string document_state::add_anchor(quickbook::string_view id, id_category category) { return state->add_placeholder(id, category)->to_string(); } std::string document_state::replace_placeholders_with_unresolved_ids( - boost::string_ref xml) const + quickbook::string_view xml) const { return replace_ids(*state, xml); } - std::string document_state::replace_placeholders(boost::string_ref xml) const + std::string document_state::replace_placeholders(quickbook::string_view xml) const { assert(!state->current_file); std::vector ids = generate_ids(*state, xml); @@ -186,7 +186,7 @@ namespace quickbook id_placeholder::id_placeholder( unsigned index, - boost::string_ref id, + quickbook::string_view id, id_category category, id_placeholder const* parent_) : index(index), @@ -211,7 +211,7 @@ namespace quickbook // id_placeholder const* document_state_impl::add_placeholder( - boost::string_ref id, id_category category, + quickbook::string_view id, id_category category, id_placeholder const* parent) { placeholders.push_back(id_placeholder( @@ -219,7 +219,7 @@ namespace quickbook return &placeholders.back(); } - id_placeholder const* document_state_impl::get_placeholder(boost::string_ref value) const + id_placeholder const* document_state_impl::get_placeholder(quickbook::string_view value) const { // If this isn't a placeholder id. if (value.size() <= 1 || *value.begin() != '$') @@ -242,8 +242,8 @@ namespace quickbook id_placeholder const* document_state_impl::start_file( unsigned compatibility_version, bool document_root, - boost::string_ref include_doc_id, - boost::string_ref id, + quickbook::string_view include_doc_id, + quickbook::string_view id, value const& title) { boost::shared_ptr parent = current_file; @@ -256,7 +256,7 @@ namespace quickbook // specified in an 'include' element) unless backwards compatibility // is required. - boost::string_ref initial_doc_id; + quickbook::string_view initial_doc_id; if (document_root || compatibility_version >= 106u || @@ -348,7 +348,7 @@ namespace quickbook } id_placeholder const* document_state_impl::add_id( - boost::string_ref id, + quickbook::string_view id, id_category category) { return add_id_to_section(id, category, @@ -356,7 +356,7 @@ namespace quickbook } id_placeholder const* document_state_impl::add_id_to_section( - boost::string_ref id, + quickbook::string_view id, id_category category, boost::shared_ptr const& section) { @@ -391,7 +391,7 @@ namespace quickbook } id_placeholder const* document_state_impl::old_style_id( - boost::string_ref id, + quickbook::string_view id, id_category category) { return current_file->compatibility_version < 103u ? @@ -401,7 +401,7 @@ namespace quickbook } id_placeholder const* document_state_impl::begin_section( - boost::string_ref id, + quickbook::string_view id, id_category category, source_mode_info const& source_mode) { @@ -410,7 +410,7 @@ namespace quickbook } id_placeholder const* document_state_impl::create_new_section( - boost::string_ref id, + quickbook::string_view id, id_category category, source_mode_info const& source_mode) { diff --git a/src/document_state.hpp b/src/document_state.hpp index 2210c41..15e6253 100644 --- a/src/document_state.hpp +++ b/src/document_state.hpp @@ -10,7 +10,7 @@ #define BOOST_QUICKBOOK_DOCUMENT_STATE_HPP #include -#include +#include "string_view.hpp" #include #include "values.hpp" #include "syntax_highlight.hpp" @@ -54,31 +54,31 @@ namespace quickbook std::string start_file_with_docinfo( unsigned compatibility_version, - boost::string_ref include_doc_id, - boost::string_ref id, + quickbook::string_view include_doc_id, + quickbook::string_view id, value const& title); void start_file( unsigned compatibility_version, - boost::string_ref include_doc_id, - boost::string_ref id, + quickbook::string_view include_doc_id, + quickbook::string_view id, value const& title); void end_file(); - std::string begin_section(boost::string_ref, id_category, + std::string begin_section(quickbook::string_view, id_category, source_mode_info const&); void end_section(); int section_level() const; source_mode_info section_source_mode() const; - std::string old_style_id(boost::string_ref, id_category); - std::string add_id(boost::string_ref, id_category); - std::string add_anchor(boost::string_ref, id_category); + std::string old_style_id(quickbook::string_view, id_category); + std::string add_id(quickbook::string_view, id_category); + std::string add_anchor(quickbook::string_view, id_category); std::string replace_placeholders_with_unresolved_ids( - boost::string_ref) const; - std::string replace_placeholders(boost::string_ref) const; + quickbook::string_view) const; + std::string replace_placeholders(quickbook::string_view) const; unsigned compatibility_version() const; private: diff --git a/src/document_state_impl.hpp b/src/document_state_impl.hpp index e9258e3..66e0ceb 100644 --- a/src/document_state_impl.hpp +++ b/src/document_state_impl.hpp @@ -12,7 +12,7 @@ #include "document_state.hpp" #include "phrase_tags.hpp" #include "utils.hpp" -#include +#include "string_view.hpp" #include #include #include @@ -46,7 +46,7 @@ namespace quickbook // but not when an explicit id contains // dots. - id_placeholder(unsigned index, boost::string_ref id, + id_placeholder(unsigned index, quickbook::string_view id, id_category category, id_placeholder const* parent_); std::string to_string() const; @@ -69,10 +69,10 @@ namespace quickbook // Placeholder methods - id_placeholder const* add_placeholder(boost::string_ref, id_category, + id_placeholder const* add_placeholder(quickbook::string_view, id_category, id_placeholder const* parent = 0); - id_placeholder const* get_placeholder(boost::string_ref) const; + id_placeholder const* get_placeholder(quickbook::string_view) const; id_placeholder const* get_id_placeholder( boost::shared_ptr const& section) const; @@ -82,41 +82,41 @@ namespace quickbook id_placeholder const* start_file( unsigned compatibility_version, bool document_root, - boost::string_ref include_doc_id, - boost::string_ref id, + quickbook::string_view include_doc_id, + quickbook::string_view id, value const& title); void end_file(); id_placeholder const* add_id( - boost::string_ref id, + quickbook::string_view id, id_category category); id_placeholder const* old_style_id( - boost::string_ref id, + quickbook::string_view id, id_category category); id_placeholder const* begin_section( - boost::string_ref id, + quickbook::string_view id, id_category category, source_mode_info const&); void end_section(); private: id_placeholder const* add_id_to_section( - boost::string_ref id, + quickbook::string_view id, id_category category, boost::shared_ptr const& section); id_placeholder const* create_new_section( - boost::string_ref id, + quickbook::string_view id, id_category category, source_mode_info const&); }; - std::string replace_ids(document_state_impl const& state, boost::string_ref xml, + std::string replace_ids(document_state_impl const& state, quickbook::string_view xml, std::vector const* = 0); - std::vector generate_ids(document_state_impl const&, boost::string_ref); + std::vector generate_ids(document_state_impl const&, quickbook::string_view); - std::string normalize_id(boost::string_ref src_id); - std::string normalize_id(boost::string_ref src_id, std::size_t); + std::string normalize_id(quickbook::string_view src_id); + std::string normalize_id(quickbook::string_view src_id, std::size_t); // // Xml subset parser used for finding id values. @@ -134,13 +134,13 @@ namespace quickbook std::vector id_attributes; struct callback { - virtual void start(boost::string_ref) {} - virtual void id_value(boost::string_ref) {} - virtual void finish(boost::string_ref) {} + virtual void start(quickbook::string_view) {} + virtual void id_value(quickbook::string_view) {} + virtual void finish(quickbook::string_view) {} virtual ~callback() {} }; - void parse(boost::string_ref, callback&); + void parse(quickbook::string_view, callback&); }; } diff --git a/src/files.cpp b/src/files.cpp index 9999b0f..ceb4ba7 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -142,11 +142,11 @@ namespace quickbook } file_position relative_position( - boost::string_ref::const_iterator begin, - boost::string_ref::const_iterator iterator) + quickbook::string_view::const_iterator begin, + quickbook::string_view::const_iterator iterator) { file_position pos; - boost::string_ref::const_iterator line_begin = begin; + quickbook::string_view::const_iterator line_begin = begin; while (begin != iterator) { @@ -178,7 +178,7 @@ namespace quickbook return pos; } - file_position file::position_of(boost::string_ref::const_iterator iterator) const + file_position file::position_of(quickbook::string_view::const_iterator iterator) const { return relative_position(source().begin(), iterator); } @@ -257,7 +257,7 @@ namespace quickbook file_ptr original; std::vector mapped_sections; - void add_empty_mapped_file_section(boost::string_ref::const_iterator pos) { + void add_empty_mapped_file_section(quickbook::string_view::const_iterator pos) { std::string::size_type original_pos = pos - original->source().begin(); @@ -272,12 +272,12 @@ namespace quickbook } } - void add_mapped_file_section(boost::string_ref::const_iterator pos) { + void add_mapped_file_section(quickbook::string_view::const_iterator pos) { mapped_sections.push_back(mapped_file_section( pos - original->source().begin(), source().size())); } - void add_indented_mapped_file_section(boost::string_ref::const_iterator pos) + void add_indented_mapped_file_section(quickbook::string_view::const_iterator pos) { mapped_sections.push_back(mapped_file_section( pos - original->source().begin(), source().size(), @@ -297,13 +297,13 @@ namespace quickbook case mapped_file_section::indented: { // Will contain the start of the current line. - boost::string_ref::size_type our_line = section->our_pos; + quickbook::string_view::size_type our_line = section->our_pos; // Will contain the number of lines in the block before // the current line. unsigned newline_count = 0; - for(boost::string_ref::size_type i = section->our_pos; + for(quickbook::string_view::size_type i = section->our_pos; i != pos; ++i) { if (source()[i] == '\n') { @@ -313,7 +313,7 @@ namespace quickbook } // The start of the line in the original source. - boost::string_ref::size_type original_line = + quickbook::string_view::size_type original_line = section->original_pos; while(newline_count > 0) { @@ -347,7 +347,7 @@ namespace quickbook } std::vector::const_iterator find_section( - boost::string_ref::const_iterator pos) const + quickbook::string_view::const_iterator pos) const { std::vector::const_iterator section = boost::upper_bound(mapped_sections, @@ -359,12 +359,12 @@ namespace quickbook return section; } - virtual file_position position_of(boost::string_ref::const_iterator) const; + virtual file_position position_of(quickbook::string_view::const_iterator) const; private: static std::string::size_type skip_indentation( - boost::string_ref src, std::string::size_type i) + quickbook::string_view src, std::string::size_type i) { while (i != src.size() && (src[i] == ' ' || src[i] == '\t')) ++i; return i; @@ -419,13 +419,13 @@ namespace quickbook return data->new_file->source().size(); } - void mapped_file_builder::add_at_pos(boost::string_ref x, iterator pos) + void mapped_file_builder::add_at_pos(quickbook::string_view x, iterator pos) { data->new_file->add_empty_mapped_file_section(pos); data->new_file->source_.append(x.begin(), x.end()); } - void mapped_file_builder::add(boost::string_ref x) + void mapped_file_builder::add(quickbook::string_view x) { data->new_file->add_mapped_file_section(x.begin()); data->new_file->source_.append(x.begin(), x.end()); @@ -469,11 +469,11 @@ namespace quickbook } } - boost::string_ref::size_type indentation_count(boost::string_ref x) + quickbook::string_view::size_type indentation_count(quickbook::string_view x) { unsigned count = 0; - for(boost::string_ref::const_iterator begin = x.begin(), end = x.end(); + for(quickbook::string_view::const_iterator begin = x.begin(), end = x.end(); begin != end; ++begin) { switch(*begin) @@ -493,7 +493,7 @@ namespace quickbook return count; } - void mapped_file_builder::unindent_and_add(boost::string_ref x) + void mapped_file_builder::unindent_and_add(quickbook::string_view x) { // I wanted to do everything using a string_ref, but unfortunately // they don't have all the overloads used in here. So... @@ -510,8 +510,8 @@ namespace quickbook // Get the first line indentation std::string::size_type indent = program.find_first_not_of(" \t", start) - start; - boost::string_ref::size_type full_indent = indentation_count( - boost::string_ref(&program[start], indent)); + quickbook::string_view::size_type full_indent = indentation_count( + quickbook::string_view(&program[start], indent)); std::string::size_type pos = start; @@ -530,12 +530,12 @@ namespace quickbook indent = (std::min)(indent, n-pos); full_indent = (std::min)(full_indent, indentation_count( - boost::string_ref(&program[pos], n-pos))); + quickbook::string_view(&program[pos], n-pos))); } // Detect if indentation is mixed. bool mixed_indentation = false; - boost::string_ref first_indent(&program[start], indent); + quickbook::string_view first_indent(&program[start], indent); pos = start; while (std::string::npos != (pos = program.find_first_of("\r\n", pos))) @@ -546,7 +546,7 @@ namespace quickbook std::string::size_type n = program.find_first_not_of(" \t", pos); if (n == std::string::npos || n-pos < indent) continue; - if (boost::string_ref(&program[pos], indent) != first_indent) { + if (quickbook::string_view(&program[pos], indent) != first_indent) { mixed_indentation = true; break; } @@ -570,7 +570,7 @@ namespace quickbook if (mixed_indentation) { - unsigned length = indentation_count(boost::string_ref( + unsigned length = indentation_count(quickbook::string_view( &program[pos], next - pos)); if (length > full_indent) { @@ -595,7 +595,7 @@ namespace quickbook data->new_file->source_.append(unindented_program); } - file_position mapped_file::position_of(boost::string_ref::const_iterator pos) const + file_position mapped_file::position_of(quickbook::string_view::const_iterator pos) const { return original->position_of(original->source().begin() + to_original_pos(find_section(pos), pos - source().begin())); diff --git a/src/files.hpp b/src/files.hpp index 0a2e530..73c530e 100644 --- a/src/files.hpp +++ b/src/files.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include "string_view.hpp" #include #include #include @@ -56,15 +56,15 @@ namespace quickbook { unsigned qbk_version; unsigned ref_count; public: - boost::string_ref source() const { return source_; } + quickbook::string_view source() const { return source_; } - file(fs::path const& path, boost::string_ref source, + file(fs::path const& path, quickbook::string_view source, unsigned qbk_version) : path(path), source_(source.begin(), source.end()), is_code_snippets(false), qbk_version(qbk_version), ref_count(0) {} - file(file const& f, boost::string_ref source) : + file(file const& f, quickbook::string_view source) : path(f.path), source_(source.begin(), source.end()), is_code_snippets(f.is_code_snippets), qbk_version(f.qbk_version), ref_count(0) @@ -87,7 +87,7 @@ namespace quickbook { qbk_version = v; } - virtual file_position position_of(boost::string_ref::const_iterator) const; + virtual file_position position_of(quickbook::string_view::const_iterator) const; friend void intrusive_ptr_add_ref(file* ptr) { ++ptr->ref_count; } @@ -112,8 +112,8 @@ namespace quickbook { struct mapped_file_builder { - typedef boost::string_ref::const_iterator iterator; - typedef boost::string_ref::size_type pos; + typedef quickbook::string_view::const_iterator iterator; + typedef quickbook::string_view::size_type pos; mapped_file_builder(); ~mapped_file_builder(); @@ -125,11 +125,11 @@ namespace quickbook { bool empty() const; pos get_pos() const; - void add_at_pos(boost::string_ref, iterator); - void add(boost::string_ref); + void add_at_pos(quickbook::string_view, iterator); + void add(quickbook::string_view); void add(mapped_file_builder const&); void add(mapped_file_builder const&, pos, pos); - void unindent_and_add(boost::string_ref); + void unindent_and_add(quickbook::string_view); private: mapped_file_builder_data* data; diff --git a/src/fwd.hpp b/src/fwd.hpp index 5dec2d6..224e3c1 100644 --- a/src/fwd.hpp +++ b/src/fwd.hpp @@ -13,7 +13,7 @@ #include "iterator.hpp" #include -#include +#include "string_view.hpp" namespace quickbook { @@ -27,7 +27,7 @@ namespace quickbook typedef boost::intrusive_ptr file_ptr; typedef unsigned source_mode_type; - typedef boost::string_ref::const_iterator string_iterator; + typedef quickbook::string_view::const_iterator string_iterator; typedef lookback_iterator parse_iterator; inline void ignore_variable(void const*) {} diff --git a/src/glob.cpp b/src/glob.cpp index 474bdeb..91bac35 100644 --- a/src/glob.cpp +++ b/src/glob.cpp @@ -11,7 +11,7 @@ namespace quickbook { - typedef boost::string_ref::const_iterator glob_iterator; + typedef quickbook::string_view::const_iterator glob_iterator; void check_glob_range(glob_iterator&, glob_iterator); void check_glob_escape(glob_iterator&, glob_iterator); @@ -21,7 +21,7 @@ namespace quickbook bool match_range(glob_iterator& pattern_begin, glob_iterator pattern_end, unsigned char x); - bool check_glob(boost::string_ref pattern) + bool check_glob(quickbook::string_view pattern) { bool is_glob = false; bool is_ascii = true; @@ -125,8 +125,8 @@ namespace quickbook ++begin; } - bool glob(boost::string_ref const& pattern, - boost::string_ref const& filename) + bool glob(quickbook::string_view const& pattern, + quickbook::string_view const& filename) { // If there wasn't this special case then '*' would match an // empty string. @@ -260,29 +260,29 @@ namespace quickbook return invert_match != matched; } - std::size_t find_glob_char(boost::string_ref pattern, + std::size_t find_glob_char(quickbook::string_view pattern, std::size_t pos) { - // Weird style is because boost::string_ref's find_first_of + // Weird style is because quickbook::string_view's find_first_of // doesn't take a position argument. std::size_t removed = 0; while (true) { pos = pattern.find_first_of("[]?*\\"); - if (pos == boost::string_ref::npos) return pos; + if (pos == quickbook::string_view::npos) return pos; if (pattern[pos] != '\\') return pos + removed; pattern.remove_prefix(pos + 2); removed += pos + 2; } } - std::string glob_unescape(boost::string_ref pattern) + std::string glob_unescape(quickbook::string_view pattern) { std::string result; while (true) { std::size_t pos = pattern.find("\\"); - if (pos == boost::string_ref::npos) { + if (pos == quickbook::string_view::npos) { result.append(pattern.data(), pattern.size()); break; } diff --git a/src/glob.hpp b/src/glob.hpp index 8e84589..5b79c07 100644 --- a/src/glob.hpp +++ b/src/glob.hpp @@ -6,7 +6,7 @@ http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ -#include +#include "string_view.hpp" #include namespace quickbook @@ -18,13 +18,13 @@ namespace quickbook }; // Is this path a glob? Throws glob_error if glob is invalid. - bool check_glob(boost::string_ref); + bool check_glob(quickbook::string_view); // pre: glob is valid (call check_glob first on user data). - bool glob(boost::string_ref const& pattern, - boost::string_ref const& filename); + bool glob(quickbook::string_view const& pattern, + quickbook::string_view const& filename); - std::size_t find_glob_char(boost::string_ref, + std::size_t find_glob_char(quickbook::string_view, std::size_t start = 0); - std::string glob_unescape(boost::string_ref); + std::string glob_unescape(quickbook::string_view); } diff --git a/src/id_generation.cpp b/src/id_generation.cpp index b6445a5..664014d 100644 --- a/src/id_generation.cpp +++ b/src/id_generation.cpp @@ -27,13 +27,13 @@ namespace quickbook { static const std::size_t max_size = 32; typedef std::vector placeholder_index; - placeholder_index index_placeholders(document_state_impl const&, boost::string_ref); + placeholder_index index_placeholders(document_state_impl const&, quickbook::string_view); void generate_id_block( placeholder_index::iterator, placeholder_index::iterator, std::vector& generated_ids); - std::vector generate_ids(document_state_impl const& state, boost::string_ref xml) + std::vector generate_ids(document_state_impl const& state, quickbook::string_view xml) { std::vector generated_ids(state.placeholders.size()); @@ -102,7 +102,7 @@ namespace quickbook { count(0) {} - void id_value(boost::string_ref value) + void id_value(quickbook::string_view value) { set_placeholder_order(state.get_placeholder(value)); } @@ -118,7 +118,7 @@ namespace quickbook { placeholder_index index_placeholders( document_state_impl const& state, - boost::string_ref xml) + quickbook::string_view xml) { // The order that the placeholder appear in the xml source. std::vector order(state.placeholders.size()); @@ -287,7 +287,7 @@ namespace quickbook { { document_state_impl const& state; std::vector const* ids; - boost::string_ref::const_iterator source_pos; + quickbook::string_view::const_iterator source_pos; std::string result; replace_ids_callback(document_state_impl const& state, @@ -298,16 +298,16 @@ namespace quickbook { result() {} - void start(boost::string_ref xml) + void start(quickbook::string_view xml) { source_pos = xml.begin(); } - void id_value(boost::string_ref value) + void id_value(quickbook::string_view value) { if (id_placeholder const* p = state.get_placeholder(value)) { - boost::string_ref id = ids ? + quickbook::string_view id = ids ? (*ids)[p->index] : p->unresolved_id; result.append(source_pos, value.begin()); @@ -316,14 +316,14 @@ namespace quickbook { } } - void finish(boost::string_ref xml) + void finish(quickbook::string_view xml) { result.append(source_pos, xml.end()); source_pos = xml.end(); } }; - std::string replace_ids(document_state_impl const& state, boost::string_ref xml, + std::string replace_ids(document_state_impl const& state, quickbook::string_view xml, std::vector const* ids) { xml_processor processor; @@ -338,12 +338,12 @@ namespace quickbook { // Normalizes generated ids. // - std::string normalize_id(boost::string_ref src_id) + std::string normalize_id(quickbook::string_view src_id) { return normalize_id(src_id, max_size); } - std::string normalize_id(boost::string_ref src_id, std::size_t size) + std::string normalize_id(quickbook::string_view src_id, std::size_t size) { std::string id(src_id.begin(), src_id.end()); diff --git a/src/id_xml.cpp b/src/id_xml.cpp index d69336b..40f07f6 100644 --- a/src/id_xml.cpp +++ b/src/id_xml.cpp @@ -73,9 +73,9 @@ namespace quickbook while(it != end && !find_char(text, *it)) ++it; } - void xml_processor::parse(boost::string_ref source, callback& c) + void xml_processor::parse(quickbook::string_view source, callback& c) { - typedef boost::string_ref::const_iterator iterator; + typedef quickbook::string_view::const_iterator iterator; c.start(source); @@ -118,7 +118,7 @@ namespace quickbook iterator name_start = it; read_to_one_of(it, end, "= \t\n\r>"); if (it == end || *it == '>') break; - boost::string_ref name(name_start, it - name_start); + quickbook::string_view name(name_start, it - name_start); ++it; read_some_of(it, end, "= \t\n\r"); @@ -131,7 +131,7 @@ namespace quickbook it = std::find(it, end, delim); if (it == end) break; - boost::string_ref value(value_start, it - value_start); + quickbook::string_view value(value_start, it - value_start); ++it; if (boost::find(id_attributes, detail::to_s(name)) diff --git a/src/include_paths.cpp b/src/include_paths.cpp index d3906b2..19f0fa2 100644 --- a/src/include_paths.cpp +++ b/src/include_paths.cpp @@ -153,7 +153,7 @@ namespace quickbook if (next != std::string::npos) ++next; - boost::string_ref glob( + quickbook::string_view glob( path.data() + glob_begin, glob_end - glob_begin); @@ -305,12 +305,12 @@ namespace quickbook file_path < other.file_path; } - quickbook_path quickbook_path::operator/(boost::string_ref x) const + quickbook_path quickbook_path::operator/(quickbook::string_view x) const { return quickbook_path(*this) /= x; } - quickbook_path& quickbook_path::operator/=(boost::string_ref x) + quickbook_path& quickbook_path::operator/=(quickbook::string_view x) { fs::path x2 = detail::generic_to_path(x); file_path /= x2; diff --git a/src/include_paths.hpp b/src/include_paths.hpp index 7c51dc0..5882092 100644 --- a/src/include_paths.hpp +++ b/src/include_paths.hpp @@ -47,8 +47,8 @@ namespace quickbook quickbook_path parent_path() const; bool operator<(quickbook_path const& other) const; - quickbook_path operator/(boost::string_ref) const; - quickbook_path& operator/=(boost::string_ref); + quickbook_path operator/(quickbook::string_view) const; + quickbook_path& operator/=(quickbook::string_view); // The actual location of the file. fs::path file_path; diff --git a/src/native_text.cpp b/src/native_text.cpp index 23836c5..62ff520 100644 --- a/src/native_text.cpp +++ b/src/native_text.cpp @@ -54,7 +54,7 @@ namespace detail { return std::string(buffer.get()); } - std::wstring from_utf8(boost::string_ref text) + std::wstring from_utf8(quickbook::string_view text) { std::string x(text.begin(), text.end()); int buffer_count = MultiByteToWideChar(CP_UTF8, 0, x.c_str(), -1, 0, 0); @@ -85,7 +85,7 @@ namespace detail { #endif #if QUICKBOOK_WIDE_PATHS - fs::path generic_to_path(boost::string_ref x) + fs::path generic_to_path(quickbook::string_view x) { return fs::path(from_utf8(x)); } @@ -95,7 +95,7 @@ namespace detail { return to_utf8(x.generic_wstring()); } #else - fs::path generic_to_path(boost::string_ref x) + fs::path generic_to_path(quickbook::string_view x) { return fs::path(x.begin(), x.end()); } @@ -171,7 +171,7 @@ namespace detail { if (_isatty(_fileno(stderr))) _setmode(_fileno(stderr), _O_U16TEXT); } - void write_utf8(ostream::base_ostream& out, boost::string_ref x) + void write_utf8(ostream::base_ostream& out, quickbook::string_view x) { out << from_utf8(x); } @@ -197,7 +197,7 @@ namespace detail { { } - void write_utf8(ostream::base_ostream& out, boost::string_ref x) + void write_utf8(ostream::base_ostream& out, quickbook::string_view x) { out << x; } @@ -286,7 +286,7 @@ namespace detail { return *this; } - ostream& ostream::operator<<(boost::string_ref x) { + ostream& ostream::operator<<(quickbook::string_view x) { write_utf8(base, x); return *this; } diff --git a/src/native_text.hpp b/src/native_text.hpp index 34ce0c8..a31daa0 100644 --- a/src/native_text.hpp +++ b/src/native_text.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include "string_view.hpp" #include #include #include @@ -71,7 +71,7 @@ namespace quickbook typedef boost::wstring_ref command_line_string_ref; #else typedef std::string command_line_string; - typedef boost::string_ref command_line_string_ref; + typedef quickbook::string_view command_line_string_ref; #endif // A light wrapper around C++'s streams that gets things right @@ -89,7 +89,7 @@ namespace quickbook typedef std::ostream base_ostream; typedef std::ios base_ios; typedef std::string string; - typedef boost::string_ref string_ref; + typedef quickbook::string_view string_ref; #endif base_ostream& base; @@ -101,7 +101,7 @@ namespace quickbook // std::string should be UTF-8 (what a mess!) ostream& operator<<(std::string const&); - ostream& operator<<(boost::string_ref); + ostream& operator<<(quickbook::string_view); // Other value types. ostream& operator<<(int x); @@ -126,7 +126,7 @@ namespace quickbook fs::path command_line_to_path(command_line_string const&); std::string path_to_generic(fs::path const&); - fs::path generic_to_path(boost::string_ref); + fs::path generic_to_path(quickbook::string_view); void initialise_output(); diff --git a/src/quickbook.cpp b/src/quickbook.cpp index 1716b50..264b058 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -62,7 +62,7 @@ namespace quickbook end = preset_defines.end(); it != end; ++it) { - boost::string_ref val(*it); + quickbook::string_view val(*it); parse_iterator first(val.begin()); parse_iterator last(val.end()); diff --git a/src/string_view.hpp b/src/string_view.hpp new file mode 100644 index 0000000..3f28b3e --- /dev/null +++ b/src/string_view.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2017 Daniel James + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_QUICKBOOK_STRING_VIEW_HPP) +#define BOOST_SPIRIT_QUICKBOOK_STRING_VIEW_HPP + +#include + +namespace quickbook { + // boost::string_view now can't be constructed from an rvalue std::string, + // which is something that quickbook does in several places, so this wraps + // it to allow that. + + struct string_view : boost::string_view { + typedef boost::string_view base; + + string_view() : base() {} + string_view(string_view const& x) : base(x) {} + string_view(std::string const& x) : base(x) {} + string_view(const char* x) : base(x) {} + string_view(const char* x, typename base::size_type len) : base(x, len) {} + }; +} + +#endif diff --git a/src/syntax_highlight.cpp b/src/syntax_highlight.cpp index 12e2c5e..14bc4be 100644 --- a/src/syntax_highlight.cpp +++ b/src/syntax_highlight.cpp @@ -34,7 +34,7 @@ namespace quickbook // State bool support_callouts; - boost::string_ref marked_text; + quickbook::string_view marked_text; syntax_highlight_actions(quickbook::state& state, bool is_block) : state(state), @@ -129,7 +129,7 @@ namespace quickbook void syntax_highlight_actions::mark_text(parse_iterator first, parse_iterator last) { - marked_text = boost::string_ref(first.base(), last.base() - first.base()); + marked_text = quickbook::string_view(first.base(), last.base() - first.base()); } void syntax_highlight_actions::callout(parse_iterator, parse_iterator) diff --git a/src/utils.cpp b/src/utils.cpp index 6f3b49a..195d8b6 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -15,12 +15,12 @@ namespace quickbook { namespace detail { - std::string encode_string(boost::string_ref str) + std::string encode_string(quickbook::string_view str) { std::string result; result.reserve(str.size()); - for (boost::string_ref::const_iterator it = str.begin(); + for (quickbook::string_view::const_iterator it = str.begin(); it != str.end(); ++it) { switch (*it) @@ -50,9 +50,9 @@ namespace quickbook { namespace detail } } - void print_string(boost::string_ref str, std::ostream& out) + void print_string(quickbook::string_view str, std::ostream& out) { - for (boost::string_ref::const_iterator cur = str.begin(); + for (quickbook::string_view::const_iterator cur = str.begin(); cur != str.end(); ++cur) { print_char(*cur, out); diff --git a/src/utils.hpp b/src/utils.hpp index 3f5c545..93e7ed1 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -14,12 +14,12 @@ #include #include #include -#include +#include "string_view.hpp" namespace quickbook { namespace detail { - std::string encode_string(boost::string_ref); + std::string encode_string(quickbook::string_view); void print_char(char ch, std::ostream& out); - void print_string(boost::string_ref str, std::ostream& out); + void print_string(quickbook::string_view str, std::ostream& out); char filter_identifier_char(char ch); template @@ -36,17 +36,17 @@ namespace quickbook { namespace detail { // URI escape string std::string escape_uri(std::string uri); - inline std::string escape_uri(boost::string_ref uri) { + inline std::string escape_uri(quickbook::string_view uri) { return escape_uri(std::string(uri.begin(), uri.end())); } // URI escape string, leaving characters generally used in URIs. std::string partially_escape_uri(std::string uri); - inline std::string partially_escape_uri(boost::string_ref uri) { + inline std::string partially_escape_uri(quickbook::string_view uri) { return escape_uri(std::string(uri.begin(), uri.end())); } - inline std::string to_s(boost::string_ref x) { + inline std::string to_s(quickbook::string_view x) { return std::string(x.begin(), x.end()); } }} diff --git a/src/values.cpp b/src/values.cpp index 59c11cf..8a049e3 100644 --- a/src/values.cpp +++ b/src/values.cpp @@ -50,7 +50,7 @@ namespace quickbook file_ptr value_node::get_file() const { UNDEFINED_ERROR(); } string_iterator value_node::get_position() const { UNDEFINED_ERROR(); } int value_node::get_int() const { UNDEFINED_ERROR(); } - boost::string_ref value_node::get_quickbook() const { UNDEFINED_ERROR(); } + quickbook::string_view value_node::get_quickbook() const { UNDEFINED_ERROR(); } std::string value_node::get_encoded() const { UNDEFINED_ERROR(); } value_node* value_node::get_list() const { UNDEFINED_ERROR(); } @@ -332,7 +332,7 @@ namespace quickbook virtual value_node* clone() const; virtual file_ptr get_file() const; virtual string_iterator get_position() const; - virtual boost::string_ref get_quickbook() const; + virtual quickbook::string_view get_quickbook() const; virtual bool empty() const; virtual bool equals(value_node*) const; @@ -354,7 +354,7 @@ namespace quickbook virtual value_node* clone() const; virtual file_ptr get_file() const; virtual string_iterator get_position() const; - virtual boost::string_ref get_quickbook() const; + virtual quickbook::string_view get_quickbook() const; virtual std::string get_encoded() const; virtual bool empty() const; virtual bool is_encoded() const; @@ -433,8 +433,8 @@ namespace quickbook string_iterator qbk_value_impl::get_position() const { return begin_; } - boost::string_ref qbk_value_impl::get_quickbook() const - { return boost::string_ref(begin_, end_ - begin_); } + quickbook::string_view qbk_value_impl::get_quickbook() const + { return quickbook::string_view(begin_, end_ - begin_); } bool qbk_value_impl::empty() const { return begin_ == end_; } @@ -481,8 +481,8 @@ namespace quickbook string_iterator encoded_qbk_value_impl::get_position() const { return begin_; } - boost::string_ref encoded_qbk_value_impl::get_quickbook() const - { return boost::string_ref(begin_, end_ - begin_); } + quickbook::string_view encoded_qbk_value_impl::get_quickbook() const + { return quickbook::string_view(begin_, end_ - begin_); } std::string encoded_qbk_value_impl::get_encoded() const { return encoded_value_; } diff --git a/src/values.hpp b/src/values.hpp index e681c8a..c012ca2 100644 --- a/src/values.hpp +++ b/src/values.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include "string_view.hpp" #include #include "fwd.hpp" #include "files.hpp" @@ -51,7 +51,7 @@ namespace quickbook virtual file_ptr get_file() const; virtual string_iterator get_position() const; - virtual boost::string_ref get_quickbook() const; + virtual quickbook::string_view get_quickbook() const; virtual std::string get_encoded() const; virtual int get_int() const; @@ -113,7 +113,7 @@ namespace quickbook { return value_->get_file(); } string_iterator get_position() const { return value_->get_position(); } - boost::string_ref get_quickbook() const + quickbook::string_view get_quickbook() const { return value_->get_quickbook(); } std::string get_encoded() const { return value_->get_encoded(); } diff --git a/test/unit/source_map_test.cpp b/test/unit/source_map_test.cpp index 3eb3057..dd98a5d 100644 --- a/test/unit/source_map_test.cpp +++ b/test/unit/source_map_test.cpp @@ -8,13 +8,13 @@ #include "fwd.hpp" #include "files.hpp" -#include +#include "string_view.hpp" #include #include void simple_map_tests() { - boost::string_ref source("First Line\nSecond Line"); + quickbook::string_view source("First Line\nSecond Line"); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); @@ -34,7 +34,7 @@ void simple_map_tests() { // Add full text builder.start(fake_file); - builder.add(boost::string_ref(line1, line2_end - line1)); + builder.add(quickbook::string_view(line1, line2_end - line1)); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), source); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), @@ -51,10 +51,10 @@ void simple_map_tests() { // Add first line builder.start(fake_file); - builder.add(boost::string_ref(line1, line1_end - line1)); + builder.add(quickbook::string_view(line1, line1_end - line1)); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref(source.begin(), line1_end - line1)); + quickbook::string_view(source.begin(), line1_end - line1)); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(1,1)); BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), @@ -65,9 +65,9 @@ void simple_map_tests() { // Add second line builder.start(fake_file); - builder.add(boost::string_ref(line2, line2_end - line2)); + builder.add(quickbook::string_view(line2, line2_end - line2)); quickbook::file_ptr f1 = builder.release(); - BOOST_TEST_EQ(f1->source(), boost::string_ref("Second Line")); + BOOST_TEST_EQ(f1->source(), quickbook::string_view("Second Line")); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(2,1)); BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 2), @@ -78,12 +78,12 @@ void simple_map_tests() { // Out of order builder.start(fake_file); - builder.add(boost::string_ref(line2, line2_end - line2)); - builder.add(boost::string_ref(line1_end, 1)); - builder.add(boost::string_ref(line1, line1_end - line1)); + builder.add(quickbook::string_view(line2, line2_end - line2)); + builder.add(quickbook::string_view(line1_end, 1)); + builder.add(quickbook::string_view(line1, line1_end - line1)); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Second Line\nFirst Line")); + quickbook::string_view("Second Line\nFirst Line")); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(2,1)); @@ -101,12 +101,12 @@ void simple_map_tests() { // Repeated text builder.start(fake_file); - builder.add(boost::string_ref(line2, line2_end - line2)); - builder.add(boost::string_ref(line1_end, 1)); - builder.add(boost::string_ref(line2, line2_end - line2)); + builder.add(quickbook::string_view(line2, line2_end - line2)); + builder.add(quickbook::string_view(line1_end, 1)); + builder.add(quickbook::string_view(line2, line2_end - line2)); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Second Line\nSecond Line")); + quickbook::string_view("Second Line\nSecond Line")); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(2,1)); @@ -126,11 +126,11 @@ void simple_map_tests() { // Generated text builder.start(fake_file); builder.add_at_pos("------\n", line1); - builder.add(boost::string_ref(line1, line1_end - line1)); + builder.add(quickbook::string_view(line1, line1_end - line1)); builder.add_at_pos("\n------\n", line1_end); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("------\nFirst Line\n------\n")); + quickbook::string_view("------\nFirst Line\n------\n")); quickbook::string_iterator newline = boost::find(f1->source(), '\n'); @@ -157,7 +157,7 @@ void simple_map_tests() void indented_map_tests() { - boost::string_ref source( + quickbook::string_view source( " Code line1\n" " Code line2\n"); quickbook::file_ptr fake_file = new quickbook::file( @@ -170,7 +170,7 @@ void indented_map_tests() builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\nCode line2\n")); + quickbook::string_view("Code line1\nCode line2\n")); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(1,4)); BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), @@ -197,7 +197,7 @@ void indented_map_tests() quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\nCode line2\n")); + quickbook::string_view("Code line1\nCode line2\n")); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(1,4)); BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), @@ -214,12 +214,12 @@ void indented_map_tests() { builder.start(fake_file); - builder.unindent_and_add(boost::string_ref( + builder.unindent_and_add(quickbook::string_view( fake_file->source().begin() + 3, fake_file->source().end() - (fake_file->source().begin() + 3))); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n Code line2\n")); + quickbook::string_view("Code line1\n Code line2\n")); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(1,4)); BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), @@ -237,7 +237,7 @@ void indented_map_tests() void indented_map_tests2() { - boost::string_ref source( + quickbook::string_view source( " Code line1\n" "\n" " Code line2\n"); @@ -251,7 +251,7 @@ void indented_map_tests2() builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n\nCode line2\n")); + quickbook::string_view("Code line1\n\nCode line2\n")); BOOST_TEST_EQ(f1->position_of(f1->source().begin()), quickbook::file_position(1,4)); BOOST_TEST_EQ(f1->position_of(f1->source().begin() + 1), @@ -272,36 +272,36 @@ void indented_map_leading_blanks_test() quickbook::mapped_file_builder builder; { - boost::string_ref source("\n\n Code line1\n"); + quickbook::string_view source("\n\n Code line1\n"); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n")); + quickbook::string_view("Code line1\n")); } { - boost::string_ref source(" \n \n Code line1\n"); + quickbook::string_view source(" \n \n Code line1\n"); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n")); + quickbook::string_view("Code line1\n")); } { - boost::string_ref source(" Code line1\n \n Code line2"); + quickbook::string_view source(" Code line1\n \n Code line2"); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n\nCode line2")); + quickbook::string_view("Code line1\n\nCode line2")); } } @@ -310,36 +310,36 @@ void indented_map_trailing_blanks_test() quickbook::mapped_file_builder builder; { - boost::string_ref source("\n\n Code line1\n "); + quickbook::string_view source("\n\n Code line1\n "); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n")); + quickbook::string_view("Code line1\n")); } { - boost::string_ref source(" \n \n Code line1\n "); + quickbook::string_view source(" \n \n Code line1\n "); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n ")); + quickbook::string_view("Code line1\n ")); } { - boost::string_ref source(" Code line1\n \n Code line2\n "); + quickbook::string_view source(" Code line1\n \n Code line2\n "); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line1\n\nCode line2\n")); + quickbook::string_view("Code line1\n\nCode line2\n")); } } @@ -349,36 +349,36 @@ void indented_map_mixed_test() quickbook::mapped_file_builder builder; { - boost::string_ref source("\tCode line 1\n Code line 2\n\t Code line 3\n \tCode line 4"); + quickbook::string_view source("\tCode line 1\n Code line 2\n\t Code line 3\n \tCode line 4"); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line 1\nCode line 2\n Code line 3\n Code line 4")); + quickbook::string_view("Code line 1\nCode line 2\n Code line 3\n Code line 4")); } { - boost::string_ref source(" Code line 1\n\tCode line 2"); + quickbook::string_view source(" Code line 1\n\tCode line 2"); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line 1\n Code line 2")); + quickbook::string_view("Code line 1\n Code line 2")); } { - boost::string_ref source(" Code line 1\n \tCode line 2"); + quickbook::string_view source(" Code line 1\n \tCode line 2"); quickbook::file_ptr fake_file = new quickbook::file( "(fake file)", source, 105u); builder.start(fake_file); builder.unindent_and_add(fake_file->source()); quickbook::file_ptr f1 = builder.release(); BOOST_TEST_EQ(f1->source(), - boost::string_ref("Code line 1\n\tCode line 2")); + quickbook::string_view("Code line 1\n\tCode line 2")); } } diff --git a/test/unit/values_test.cpp b/test/unit/values_test.cpp index d3da4a8..9c673a7 100644 --- a/test/unit/values_test.cpp +++ b/test/unit/values_test.cpp @@ -35,7 +35,7 @@ void qbk_tests() fake_file->source().begin(), fake_file->source().end()); } - BOOST_TEST_EQ(q.get_quickbook(), boost::string_ref(source)); + BOOST_TEST_EQ(q.get_quickbook(), quickbook::string_view(source)); } void sort_test()