}
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)
{
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);
}
file_ptr original;
std::vector<mapped_file_section> 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();
}
}
- 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(),
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') {
}
// 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) {
}
std::vector<mapped_file_section>::const_iterator find_section(
- boost::string_ref::const_iterator pos) const
+ quickbook::string_view::const_iterator pos) const
{
std::vector<mapped_file_section>::const_iterator section =
boost::upper_bound(mapped_sections,
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;
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());
}
}
- 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)
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...
// 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;
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)))
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;
}
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) {
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()));