Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86635 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2013-11-12 04:12:17


Author: danieljames
Date: 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013)
New Revision: 86635
URL: http://svn.boost.org/trac/boost/changeset/86635

Log:
Rename id_manager to document_state.

Added:
   trunk/tools/quickbook/src/document_state.cpp (contents, props changed)
      - copied, changed from r86522, trunk/tools/quickbook/src/id_manager.cpp
   trunk/tools/quickbook/src/document_state.hpp (contents, props changed)
      - copied, changed from r86522, trunk/tools/quickbook/src/id_manager.hpp
   trunk/tools/quickbook/src/document_state_impl.hpp (contents, props changed)
      - copied, changed from r86522, trunk/tools/quickbook/src/id_manager_impl.hpp
Deleted:
   trunk/tools/quickbook/src/id_manager.cpp
   trunk/tools/quickbook/src/id_manager.hpp
   trunk/tools/quickbook/src/id_manager_impl.hpp
Text files modified:
   trunk/tools/quickbook/src/Jamfile.v2 | 2
   trunk/tools/quickbook/src/actions.cpp | 48 ++--
   trunk/tools/quickbook/src/doc_info_actions.cpp | 18
   trunk/tools/quickbook/src/document_state.cpp | 60 ++--
   trunk/tools/quickbook/src/document_state.hpp | 18
   trunk/tools/quickbook/src/document_state_impl.hpp | 18
   trunk/tools/quickbook/src/fwd.hpp | 2
   trunk/tools/quickbook/src/id_generation.cpp | 18
   /dev/null | 456 ----------------------------------------
   /dev/null | 86 -------
   /dev/null | 144 ------------
   trunk/tools/quickbook/src/id_xml.cpp | 2
   trunk/tools/quickbook/src/quickbook.cpp | 8
   trunk/tools/quickbook/src/state.cpp | 4
   trunk/tools/quickbook/src/state.hpp | 4
   15 files changed, 101 insertions(+), 787 deletions(-)

Modified: trunk/tools/quickbook/src/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/src/Jamfile.v2 Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/Jamfile.v2 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -32,7 +32,7 @@
     files.cpp
     input_path.cpp
     values.cpp
- id_manager.cpp
+ document_state.cpp
     id_generation.cpp
     id_xml.cpp
     post_process.cpp

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/actions.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -32,7 +32,7 @@
 #include "input_path.hpp"
 #include "block_tags.hpp"
 #include "phrase_tags.hpp"
-#include "id_manager.hpp"
+#include "document_state.hpp"
 
 namespace quickbook
 {
@@ -67,7 +67,7 @@
                 id_category::categories category =
                     id_category::explicit_anchor_id)
         {
- std::string placeholder = state.ids.add_anchor(id, category);
+ std::string placeholder = state.document.add_anchor(id, category);
             state.anchors.push_back(placeholder);
             return placeholder;
         }
@@ -295,7 +295,7 @@
         value_consumer values = phrase;
         state.phrase
             << "<footnote id=\""
- << state.ids.add_id("f", id_category::numbered)
+ << state.document.add_id("f", id_category::numbered)
             << "\"><para>"
             << values.consume().get_encoded()
             << "</para></footnote>";
@@ -349,7 +349,7 @@
             {
                 state.out << "<bridgehead renderas=\"sect" << level << "\"";
                 state.out << " id=\"";
- state.out << state.ids.add_id("h", id_category::numbered);
+ state.out << state.document.add_id("h", id_category::numbered);
                 state.out << "\">";
                 state.out << "<phrase id=\"" << id << "\"/>";
                 state.out << "<link linkend=\"" << id << "\">";
@@ -381,7 +381,7 @@
 
         if (generic)
         {
- level = state.ids.section_level() + 1;
+ level = state.document.section_level() + 1;
                                             // We need to use a heading which is one greater
                                             // than the current.
             if (level > 6 ) // The max is h6, clip it if it goes
@@ -398,18 +398,18 @@
         {
             // Use an explicit id.
 
- std::string anchor = state.ids.add_id(
+ std::string anchor = state.document.add_id(
                 element_id.get_quickbook(),
                 id_category::explicit_id);
 
             write_bridgehead(state, level,
                 content.get_encoded(), anchor, self_linked_headers);
         }
- else if (state.ids.compatibility_version() >= 106u)
+ else if (state.document.compatibility_version() >= 106u)
         {
             // Generate ids for 1.6+
 
- std::string anchor = state.ids.add_id(
+ std::string anchor = state.document.add_id(
                 detail::make_identifier(content.get_quickbook()),
                 id_category::generated_heading);
 
@@ -430,19 +430,19 @@
             // the content, it's just used to generate this id.
 
             std::string id = detail::make_identifier(
- state.ids.replace_placeholders_with_unresolved_ids(
+ state.document.replace_placeholders_with_unresolved_ids(
                         content.get_encoded()));
 
- if (generic || state.ids.compatibility_version() >= 103) {
+ if (generic || state.document.compatibility_version() >= 103) {
                 std::string anchor =
- state.ids.add_id(id, id_category::generated_heading);
+ state.document.add_id(id, id_category::generated_heading);
 
                 write_bridgehead(state, level,
                     content.get_encoded(), anchor, self_linked_headers);
             }
             else {
                 std::string anchor =
- state.ids.old_style_id(id, id_category::generated_heading);
+ state.document.old_style_id(id, id_category::generated_heading);
 
                 write_bridgehead(state, level,
                     content.get_encoded(), anchor, false);
@@ -574,8 +574,8 @@
 
     std::string state::add_callout(value v)
     {
- std::string callout_id1 = ids.add_id("c", id_category::numbered);
- std::string callout_id2 = ids.add_id("c", id_category::numbered);
+ std::string callout_id1 = document.add_id("c", id_category::numbered);
+ std::string callout_id2 = document.add_id("c", id_category::numbered);
 
         callouts.insert(encoded_value(callout_id1));
         callouts.insert(encoded_value(callout_id2));
@@ -1288,7 +1288,7 @@
 
             // Store the current section level so that we can ensure that
             // [section] and [endsect] tags in the template are balanced.
- state.min_section_level = state.ids.section_level();
+ state.min_section_level = state.document.section_level();
 
             ///////////////////////////////////
             // Prepare the arguments as local templates
@@ -1325,7 +1325,7 @@
                 return;
             }
 
- if (state.ids.section_level() != state.min_section_level)
+ if (state.document.section_level() != state.min_section_level)
             {
                 detail::outerr(state.current_file, first)
                     << "Mismatched sections in template "
@@ -1567,14 +1567,14 @@
         std::string table_id;
 
         if (!element_id.empty()) {
- table_id = state.ids.add_id(element_id, id_category::explicit_id);
+ table_id = state.document.add_id(element_id, id_category::explicit_id);
         }
         else if (has_title) {
- if (state.ids.compatibility_version() >= 105) {
- table_id = state.ids.add_id(detail::make_identifier(title.get_quickbook()), id_category::generated);
+ if (state.document.compatibility_version() >= 105) {
+ table_id = state.document.add_id(detail::make_identifier(title.get_quickbook()), id_category::generated);
             }
             else {
- table_id = state.ids.add_id("t", id_category::numbered);
+ table_id = state.document.add_id("t", id_category::numbered);
             }
         }
 
@@ -1657,7 +1657,7 @@
         value content = values.consume();
         values.finish();
 
- std::string full_id = state.ids.begin_section(
+ std::string full_id = state.document.begin_section(
             !element_id.empty() ?
                 element_id.get_quickbook() :
                 detail::make_identifier(content.get_quickbook()),
@@ -1670,7 +1670,7 @@
 
         write_anchors(state, state.out);
 
- if (self_linked_headers && state.ids.compatibility_version() >= 103)
+ if (self_linked_headers && state.document.compatibility_version() >= 103)
         {
             state.out << "<link linkend=\"" << full_id << "\">"
                 << content.get_encoded()
@@ -1689,7 +1689,7 @@
     {
         write_anchors(state, state.out);
 
- if (state.ids.section_level() <= state.min_section_level)
+ if (state.document.section_level() <= state.min_section_level)
         {
             file_position const pos = state.current_file->position_of(first);
 
@@ -1701,7 +1701,7 @@
         }
 
         state.out << "</section>";
- state.ids.end_section();
+ state.document.end_section();
     }
     
     void element_id_warning_action::operator()(parse_iterator first, parse_iterator) const

Modified: trunk/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_actions.cpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/doc_info_actions.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -20,7 +20,7 @@
 #include "state.hpp"
 #include "actions.hpp"
 #include "doc_info_tags.hpp"
-#include "id_manager.hpp"
+#include "document_state.hpp"
 
 namespace quickbook
 {
@@ -239,20 +239,20 @@
 
         if (!compatibility_version) {
             compatibility_version = use_doc_info ?
- qbk_version_n : state.ids.compatibility_version();
+ qbk_version_n : state.document.compatibility_version();
         }
 
         // Start file, finish here if not generating document info.
 
         if (!use_doc_info)
         {
- state.ids.start_file(compatibility_version, include_doc_id_, id_,
+ state.document.start_file(compatibility_version, include_doc_id_, id_,
                     doc_title);
             return "";
         }
 
         std::string id_placeholder =
- state.ids.start_file_with_docinfo(
+ state.document.start_file_with_docinfo(
                 compatibility_version, include_doc_id_, id_, doc_title);
 
         // Make sure we really did have a document info block.
@@ -463,7 +463,7 @@
         if (!license.empty())
         {
             tmp << " <legalnotice id=\""
- << state.ids.add_id("legal", id_category::generated)
+ << state.document.add_id("legal", id_category::generated)
                 << "\">\n"
                 << " <para>\n"
                 << " " << doc_info_output(license, 103) << "\n"
@@ -544,18 +544,18 @@
         // *after* everything else.
 
         // Close any open sections.
- if (!doc_type.empty() && state.ids.section_level() > 1) {
+ if (!doc_type.empty() && state.document.section_level() > 1) {
             detail::outwarn(state.current_file->path)
                 << "Missing [endsect] detected at end of file."
                 << std::endl;
 
- while(state.ids.section_level() > 1) {
+ while(state.document.section_level() > 1) {
                 state.out << "</section>";
- state.ids.end_section();
+ state.document.end_section();
             }
         }
 
- state.ids.end_file();
+ state.document.end_file();
         if (!doc_type.empty()) state.out << "\n</" << doc_type << ">\n\n";
     }
 

Copied and modified: trunk/tools/quickbook/src/document_state.cpp (from r86522, trunk/tools/quickbook/src/id_manager.cpp)
==============================================================================
--- trunk/tools/quickbook/src/id_manager.cpp Wed Oct 30 04:44:08 2013 (r86522, copy source)
+++ trunk/tools/quickbook/src/document_state.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -6,7 +6,7 @@
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
 
-#include "id_manager_impl.hpp"
+#include "document_state_impl.hpp"
 #include "utils.hpp"
 #include <boost/make_shared.hpp>
 #include <boost/lexical_cast.hpp>
@@ -88,17 +88,17 @@
     };
 
     //
- // id_manager
+ // document_state
     //
 
- id_manager::id_manager()
- : state(new id_state)
+ document_state::document_state()
+ : state(new document_state_impl)
     {
     }
 
- id_manager::~id_manager() {}
+ document_state::~document_state() {}
 
- void id_manager::start_file(
+ void document_state::start_file(
             unsigned compatibility_version,
             boost::string_ref include_doc_id,
             boost::string_ref id,
@@ -107,7 +107,7 @@
         state->start_file(compatibility_version, false, include_doc_id, id, title);
     }
 
- std::string id_manager::start_file_with_docinfo(
+ std::string document_state::start_file_with_docinfo(
             unsigned compatibility_version,
             boost::string_ref include_doc_id,
             boost::string_ref id,
@@ -117,56 +117,56 @@
             id, title)->to_string();
     }
 
- void id_manager::end_file()
+ void document_state::end_file()
     {
         state->end_file();
     }
 
- std::string id_manager::begin_section(boost::string_ref id,
+ std::string document_state::begin_section(boost::string_ref id,
             id_category category)
     {
         return state->begin_section(id, category)->to_string();
     }
 
- void id_manager::end_section()
+ void document_state::end_section()
     {
         return state->end_section();
     }
 
- int id_manager::section_level() const
+ int document_state::section_level() const
     {
         return state->current_file->document->current_section->level;
     }
 
- std::string id_manager::old_style_id(boost::string_ref id, id_category category)
+ std::string document_state::old_style_id(boost::string_ref id, id_category category)
     {
         return state->old_style_id(id, category)->to_string();
     }
 
- std::string id_manager::add_id(boost::string_ref id, id_category category)
+ std::string document_state::add_id(boost::string_ref id, id_category category)
     {
         return state->add_id(id, category)->to_string();
     }
 
- std::string id_manager::add_anchor(boost::string_ref id, id_category category)
+ std::string document_state::add_anchor(boost::string_ref id, id_category category)
     {
         return state->add_placeholder(id, category)->to_string();
     }
 
- std::string id_manager::replace_placeholders_with_unresolved_ids(
+ std::string document_state::replace_placeholders_with_unresolved_ids(
             boost::string_ref xml) const
     {
         return replace_ids(*state, xml);
     }
 
- std::string id_manager::replace_placeholders(boost::string_ref xml) const
+ std::string document_state::replace_placeholders(boost::string_ref xml) const
     {
         assert(!state->current_file);
         std::vector<std::string> ids = generate_ids(*state, xml);
         return replace_ids(*state, xml, &ids);
     }
 
- unsigned id_manager::compatibility_version() const
+ unsigned document_state::compatibility_version() const
     {
         return state->current_file->compatibility_version;
     }
@@ -198,10 +198,10 @@
     }
 
     //
- // id_state
+ // document_state_impl
     //
 
- id_placeholder const* id_state::add_placeholder(
+ id_placeholder const* document_state_impl::add_placeholder(
             boost::string_ref id, id_category category,
             id_placeholder const* parent)
     {
@@ -210,7 +210,7 @@
         return &placeholders.back();
     }
 
- id_placeholder const* id_state::get_placeholder(boost::string_ref value) const
+ id_placeholder const* document_state_impl::get_placeholder(boost::string_ref value) const
     {
         // If this isn't a placeholder id.
         if (value.size() <= 1 || *value.begin() != '$')
@@ -222,7 +222,7 @@
         return &placeholders.at(index);
     }
 
- id_placeholder const* id_state::get_id_placeholder(
+ id_placeholder const* document_state_impl::get_id_placeholder(
             boost::shared_ptr<section_info> const& section) const
     {
         return !section ? 0 :
@@ -230,7 +230,7 @@
                 current_file->override_id : section->placeholder_1_6;
     }
 
- id_placeholder const* id_state::start_file(
+ id_placeholder const* document_state_impl::start_file(
             unsigned compatibility_version,
             bool document_root,
             boost::string_ref include_doc_id,
@@ -329,12 +329,12 @@
         }
     }
 
- void id_state::end_file()
+ void document_state_impl::end_file()
     {
         current_file = current_file->parent;
     }
 
- id_placeholder const* id_state::add_id(
+ id_placeholder const* document_state_impl::add_id(
             boost::string_ref id,
             id_category category)
     {
@@ -342,7 +342,7 @@
             current_file->document->current_section);
     }
 
- id_placeholder const* id_state::add_id_to_section(
+ id_placeholder const* document_state_impl::add_id_to_section(
             boost::string_ref id,
             id_category category,
             boost::shared_ptr<section_info> const& section)
@@ -377,7 +377,7 @@
         }
     }
 
- id_placeholder const* id_state::old_style_id(
+ id_placeholder const* document_state_impl::old_style_id(
         boost::string_ref id,
         id_category category)
     {
@@ -387,7 +387,7 @@
                 add_id(id, category);
     }
 
- id_placeholder const* id_state::begin_section(
+ id_placeholder const* document_state_impl::begin_section(
             boost::string_ref id,
             id_category category)
     {
@@ -395,7 +395,7 @@
         return create_new_section(id, category);
     }
 
- id_placeholder const* id_state::create_new_section(
+ id_placeholder const* document_state_impl::create_new_section(
             boost::string_ref id,
             id_category category)
     {
@@ -444,11 +444,11 @@
         current_file->document->current_section =
             boost::make_shared<section_info>(parent,
                 current_file.get(), id, id_1_1, placeholder_1_6);
-
+
         return p;
     }
 
- void id_state::end_section()
+ void document_state_impl::end_section()
     {
         current_file->document->current_section =
             current_file->document->current_section->parent;

Copied and modified: trunk/tools/quickbook/src/document_state.hpp (from r86522, trunk/tools/quickbook/src/id_manager.hpp)
==============================================================================
--- trunk/tools/quickbook/src/id_manager.hpp Wed Oct 30 04:44:08 2013 (r86522, copy source)
+++ trunk/tools/quickbook/src/document_state.hpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -1,13 +1,13 @@
 /*=============================================================================
- Copyright (c) 2011 Daniel James
+ Copyright (c) 2011,2013 Daniel James
 
     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_QUICKBOOK_ID_MANAGER_HPP)
-#define BOOST_QUICKBOOK_ID_MANAGER_HPP
+#if !defined(BOOST_QUICKBOOK_DOCUMENT_STATE_HPP)
+#define BOOST_QUICKBOOK_DOCUMENT_STATE_HPP
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/utility/string_ref.hpp>
@@ -44,12 +44,12 @@
         categories c;
     };
 
- struct id_state;
+ struct document_state_impl;
 
- struct id_manager
+ struct document_state
     {
- id_manager();
- ~id_manager();
+ document_state();
+ ~document_state();
 
         std::string start_file_with_docinfo(
                 unsigned compatibility_version,
@@ -76,10 +76,10 @@
         std::string replace_placeholders_with_unresolved_ids(
                 boost::string_ref) const;
         std::string replace_placeholders(boost::string_ref) const;
-
+
         unsigned compatibility_version() const;
     private:
- boost::scoped_ptr<id_state> state;
+ boost::scoped_ptr<document_state_impl> state;
     };
 }
 

Copied and modified: trunk/tools/quickbook/src/document_state_impl.hpp (from r86522, trunk/tools/quickbook/src/id_manager_impl.hpp)
==============================================================================
--- trunk/tools/quickbook/src/id_manager_impl.hpp Wed Oct 30 04:44:08 2013 (r86522, copy source)
+++ trunk/tools/quickbook/src/document_state_impl.hpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -6,10 +6,10 @@
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
 
-#if !defined(BOOST_QUICKBOOK_ID_MANAGER_IMPL_HPP)
-#define BOOST_QUICKBOOK_ID_MANAGER_IMPL_HPP
+#if !defined(BOOST_QUICKBOOK_DOCUMENT_STATE_IMPL_HPP)
+#define BOOST_QUICKBOOK_DOCUMENT_STATE_IMPL_HPP
 
-#include "id_manager.hpp"
+#include "document_state.hpp"
 #include "utils.hpp"
 #include <boost/utility/string_ref.hpp>
 #include <boost/shared_ptr.hpp>
@@ -29,7 +29,7 @@
 
     struct id_placeholder
     {
- unsigned index; // The index in id_state::placeholders.
+ unsigned index; // The index in document_state_impl::placeholders.
                                 // Use for the dollar identifiers in
                                 // intermediate xml.
         std::string unresolved_id;
@@ -52,16 +52,16 @@
     };
 
     //
- // id_state
+ // document_state_impl
     //
- // Contains all the data tracked by the id_manager.
+ // Contains all the data tracked by document_state.
     //
 
     struct file_info;
     struct doc_info;
     struct section_info;
 
- struct id_state
+ struct document_state_impl
     {
         boost::shared_ptr<file_info> current_file;
         std::deque<id_placeholder> placeholders;
@@ -108,9 +108,9 @@
                 id_category category);
     };
 
- std::string replace_ids(id_state const& state, boost::string_ref xml,
+ std::string replace_ids(document_state_impl const& state, boost::string_ref xml,
             std::vector<std::string> const* = 0);
- std::vector<std::string> generate_ids(id_state const&, boost::string_ref);
+ std::vector<std::string> generate_ids(document_state_impl const&, boost::string_ref);
 
     std::string normalize_id(boost::string_ref src_id);
     std::string normalize_id(boost::string_ref src_id, std::size_t);

Modified: trunk/tools/quickbook/src/fwd.hpp
==============================================================================
--- trunk/tools/quickbook/src/fwd.hpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/fwd.hpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -20,7 +20,7 @@
     struct state;
     struct quickbook_grammar;
     struct collector;
- struct id_manager;
+ struct document_state;
     struct section_info;
     struct file;
     struct template_symbol;

Modified: trunk/tools/quickbook/src/id_generation.cpp
==============================================================================
--- trunk/tools/quickbook/src/id_generation.cpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/id_generation.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -7,7 +7,7 @@
 =============================================================================*/
 
 #include <cctype>
-#include "id_manager_impl.hpp"
+#include "document_state_impl.hpp"
 #include <boost/make_shared.hpp>
 #include <boost/unordered_map.hpp>
 #include <boost/lexical_cast.hpp>
@@ -27,13 +27,13 @@
     static const std::size_t max_size = 32;
 
     typedef std::vector<id_placeholder const*> placeholder_index;
- placeholder_index index_placeholders(id_state const&, boost::string_ref);
+ placeholder_index index_placeholders(document_state_impl const&, boost::string_ref);
 
     void generate_id_block(
             placeholder_index::iterator, placeholder_index::iterator,
             std::vector<std::string>& generated_ids);
 
- std::vector<std::string> generate_ids(id_state const& state, boost::string_ref xml)
+ std::vector<std::string> generate_ids(document_state_impl const& state, boost::string_ref xml)
     {
         std::vector<std::string> generated_ids(state.placeholders.size());
 
@@ -91,11 +91,11 @@
 
     struct get_placeholder_order_callback : xml_processor::callback
     {
- id_state const& state;
+ document_state_impl const& state;
         std::vector<unsigned>& order;
         unsigned count;
 
- get_placeholder_order_callback(id_state const& state,
+ get_placeholder_order_callback(document_state_impl const& state,
                 std::vector<unsigned>& order)
           : state(state),
             order(order),
@@ -117,7 +117,7 @@
     };
 
     placeholder_index index_placeholders(
- id_state const& state,
+ document_state_impl const& state,
             boost::string_ref xml)
     {
         // The order that the placeholder appear in the xml source.
@@ -285,12 +285,12 @@
 
     struct replace_ids_callback : xml_processor::callback
     {
- id_state const& state;
+ document_state_impl const& state;
         std::vector<std::string> const* ids;
         boost::string_ref::const_iterator source_pos;
         std::string result;
 
- replace_ids_callback(id_state const& state,
+ replace_ids_callback(document_state_impl const& state,
                 std::vector<std::string> const* ids)
           : state(state),
             ids(ids),
@@ -323,7 +323,7 @@
         }
     };
 
- std::string replace_ids(id_state const& state, boost::string_ref xml,
+ std::string replace_ids(document_state_impl const& state, boost::string_ref xml,
             std::vector<std::string> const* ids)
     {
         xml_processor processor;

Deleted: trunk/tools/quickbook/src/id_manager.cpp
==============================================================================
--- trunk/tools/quickbook/src/id_manager.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86634)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,456 +0,0 @@
-/*=============================================================================
- Copyright (c) 2011, 2013 Daniel James
-
- 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)
-=============================================================================*/
-
-#include "id_manager_impl.hpp"
-#include "utils.hpp"
-#include <boost/make_shared.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/range/algorithm.hpp>
-#include <cctype>
-
-namespace quickbook
-{
- struct file_info
- {
- boost::shared_ptr<file_info> const parent;
- boost::shared_ptr<doc_info> const document;
-
- bool const document_root; // !parent || document != parent->document
- unsigned const compatibility_version;
- unsigned const depth;
- unsigned const override_depth;
- id_placeholder const* const override_id;
-
- // The 1.1-1.5 document id would actually change per file due to
- // explicit ids in includes and a bug which would sometimes use the
- // document title instead of the id.
- std::string const doc_id_1_1;
-
- // Constructor for files that aren't the root of a document.
- file_info(boost::shared_ptr<file_info> const& parent,
- unsigned compatibility_version,
- boost::string_ref doc_id_1_1,
- id_placeholder const* override_id) :
- parent(parent), document(parent->document), document_root(false),
- compatibility_version(compatibility_version),
- depth(parent->depth + 1),
- override_depth(override_id ? depth : parent->override_depth),
- override_id(override_id ? override_id : parent->override_id),
- doc_id_1_1(detail::to_s(doc_id_1_1))
- {}
-
- // Constructor for files that are the root of a document.
- file_info(boost::shared_ptr<file_info> const& parent,
- boost::shared_ptr<doc_info> const& document,
- unsigned compatibility_version,
- boost::string_ref doc_id_1_1) :
- parent(parent), document(document), document_root(true),
- compatibility_version(compatibility_version),
- depth(0), override_depth(0), override_id(0),
- doc_id_1_1(detail::to_s(doc_id_1_1))
- {}
- };
-
- struct doc_info
- {
- boost::shared_ptr<section_info> current_section;
-
- // Note: these are mutable to remain bug compatible with old versions
- // of quickbook. They would set these values at the start of new files
- // and sections and then not restore them at the end.
- std::string last_title_1_1;
- std::string section_id_1_1;
- };
-
- struct section_info
- {
- boost::shared_ptr<section_info> const parent;
- unsigned const compatibility_version;
- unsigned const file_depth;
- unsigned const level;
- std::string const id_1_1;
- id_placeholder const* const placeholder_1_6;
-
- section_info(boost::shared_ptr<section_info> const& parent,
- file_info const* current_file, boost::string_ref id,
- boost::string_ref id_1_1, id_placeholder const* placeholder_1_6) :
- parent(parent),
- compatibility_version(current_file->compatibility_version),
- file_depth(current_file->depth),
- level(parent ? parent->level + 1 : 1),
- id_1_1(detail::to_s(id_1_1)),
- placeholder_1_6(placeholder_1_6) {}
- };
-
- //
- // id_manager
- //
-
- id_manager::id_manager()
- : state(new id_state)
- {
- }
-
- id_manager::~id_manager() {}
-
- void id_manager::start_file(
- unsigned compatibility_version,
- boost::string_ref include_doc_id,
- boost::string_ref id,
- value const& title)
- {
- state->start_file(compatibility_version, false, include_doc_id, id, title);
- }
-
- std::string id_manager::start_file_with_docinfo(
- unsigned compatibility_version,
- boost::string_ref include_doc_id,
- boost::string_ref id,
- value const& title)
- {
- return state->start_file(compatibility_version, true, include_doc_id,
- id, title)->to_string();
- }
-
- void id_manager::end_file()
- {
- state->end_file();
- }
-
- std::string id_manager::begin_section(boost::string_ref id,
- id_category category)
- {
- return state->begin_section(id, category)->to_string();
- }
-
- void id_manager::end_section()
- {
- return state->end_section();
- }
-
- int id_manager::section_level() const
- {
- return state->current_file->document->current_section->level;
- }
-
- std::string id_manager::old_style_id(boost::string_ref id, id_category category)
- {
- return state->old_style_id(id, category)->to_string();
- }
-
- std::string id_manager::add_id(boost::string_ref id, id_category category)
- {
- return state->add_id(id, category)->to_string();
- }
-
- std::string id_manager::add_anchor(boost::string_ref id, id_category category)
- {
- return state->add_placeholder(id, category)->to_string();
- }
-
- std::string id_manager::replace_placeholders_with_unresolved_ids(
- boost::string_ref xml) const
- {
- return replace_ids(*state, xml);
- }
-
- std::string id_manager::replace_placeholders(boost::string_ref xml) const
- {
- assert(!state->current_file);
- std::vector<std::string> ids = generate_ids(*state, xml);
- return replace_ids(*state, xml, &ids);
- }
-
- unsigned id_manager::compatibility_version() const
- {
- return state->current_file->compatibility_version;
- }
-
- //
- // id_placeholder
- //
-
- id_placeholder::id_placeholder(
- unsigned index,
- boost::string_ref id,
- id_category category,
- id_placeholder const* parent_)
- : index(index),
- unresolved_id(parent_ ?
- parent_->unresolved_id + '.' + detail::to_s(id) :
- detail::to_s(id)),
- id(id.begin(), id.end()),
- parent(parent_),
- category(category),
- num_dots(boost::range::count(id, '.') +
- (parent_ ? parent_->num_dots + 1 : 0))
- {
- }
-
- std::string id_placeholder::to_string() const
- {
- return '$' + boost::lexical_cast<std::string>(index);
- }
-
- //
- // id_state
- //
-
- id_placeholder const* id_state::add_placeholder(
- boost::string_ref id, id_category category,
- id_placeholder const* parent)
- {
- placeholders.push_back(id_placeholder(
- placeholders.size(), id, category, parent));
- return &placeholders.back();
- }
-
- id_placeholder const* id_state::get_placeholder(boost::string_ref value) const
- {
- // If this isn't a placeholder id.
- if (value.size() <= 1 || *value.begin() != '$')
- return 0;
-
- unsigned index = boost::lexical_cast<int>(std::string(
- value.begin() + 1, value.end()));
-
- return &placeholders.at(index);
- }
-
- id_placeholder const* id_state::get_id_placeholder(
- boost::shared_ptr<section_info> const& section) const
- {
- return !section ? 0 :
- section->file_depth < current_file->override_depth ?
- current_file->override_id : section->placeholder_1_6;
- }
-
- id_placeholder const* id_state::start_file(
- unsigned compatibility_version,
- bool document_root,
- boost::string_ref include_doc_id,
- boost::string_ref id,
- value const& title)
- {
- boost::shared_ptr<file_info> parent = current_file;
- assert(parent || document_root);
-
- boost::shared_ptr<doc_info> document =
- document_root ? boost::make_shared<doc_info>() : parent->document;
-
- // Choose specified id to use. Prefer 'include_doc_id' (the id
- // specified in an 'include' element) unless backwards compatibility
- // is required.
-
- boost::string_ref initial_doc_id;
-
- if (document_root ||
- compatibility_version >= 106u ||
- parent->compatibility_version >= 106u)
- {
- initial_doc_id = !include_doc_id.empty() ? include_doc_id : id;
- }
- else {
- initial_doc_id = !id.empty() ? id : include_doc_id;
- }
-
- // Work out this file's doc_id for older versions of quickbook.
- // A bug meant that this need to be done per file, not per
- // document.
-
- std::string doc_id_1_1;
-
- if (document_root || compatibility_version < 106u) {
- if (title.check())
- document->last_title_1_1 = detail::to_s(title.get_quickbook());
-
- doc_id_1_1 = !initial_doc_id.empty() ? detail::to_s(initial_doc_id) :
- detail::make_identifier(document->last_title_1_1);
- }
- else if (parent) {
- doc_id_1_1 = parent->doc_id_1_1;
- }
-
- if (document_root) {
- // Create new file
-
- current_file = boost::make_shared<file_info>(parent,
- document, compatibility_version, doc_id_1_1);
-
- // Create a section for the new document.
-
- if (!initial_doc_id.empty()) {
- return create_new_section(id, id_category::explicit_section_id);
- }
- else if (!title.empty()) {
- return create_new_section(
- detail::make_identifier(title.get_quickbook()),
- id_category::generated_doc);
- }
- else if (compatibility_version >= 106u) {
- return create_new_section("doc", id_category::numbered);
- }
- else {
- return create_new_section("", id_category::generated_doc);
- }
- }
- else {
- // If an id was set for the file, then the file overrides the
- // current section's id with this id.
- //
- // Don't do this for document_root as it will create a section
- // for the document.
- //
- // Don't do this for older versions, as they use a different
- // backwards compatible mechanism to handle file ids.
-
- id_placeholder const* override_id = 0;
-
- if (!initial_doc_id.empty() && compatibility_version >= 106u)
- {
- boost::shared_ptr<section_info> null_section;
-
- override_id = add_id_to_section(initial_doc_id,
- id_category::explicit_section_id, null_section);
- }
-
- // Create new file
-
- current_file =
- boost::make_shared<file_info>(parent, compatibility_version,
- doc_id_1_1, override_id);
-
- return 0;
- }
- }
-
- void id_state::end_file()
- {
- current_file = current_file->parent;
- }
-
- id_placeholder const* id_state::add_id(
- boost::string_ref id,
- id_category category)
- {
- return add_id_to_section(id, category,
- current_file->document->current_section);
- }
-
- id_placeholder const* id_state::add_id_to_section(
- boost::string_ref id,
- id_category category,
- boost::shared_ptr<section_info> const& section)
- {
- std::string id_part(id.begin(), id.end());
-
- // Note: Normalizing id according to file compatibility version, but
- // adding to section according to section compatibility version.
-
- if (current_file->compatibility_version >= 106u &&
- category.c < id_category::explicit_id) {
- id_part = normalize_id(id);
- }
-
- id_placeholder const* placeholder_1_6 = get_id_placeholder(section);
-
- if(!section || section->compatibility_version >= 106u) {
- return add_placeholder(id_part, category, placeholder_1_6);
- }
- else {
- std::string const& qualified_id = section->id_1_1;
-
- std::string new_id;
- if (!placeholder_1_6)
- new_id = current_file->doc_id_1_1;
- if (!new_id.empty() && !qualified_id.empty()) new_id += '.';
- new_id += qualified_id;
- if (!new_id.empty() && !id_part.empty()) new_id += '.';
- new_id += id_part;
-
- return add_placeholder(new_id, category, placeholder_1_6);
- }
- }
-
- id_placeholder const* id_state::old_style_id(
- boost::string_ref id,
- id_category category)
- {
- return current_file->compatibility_version < 103u ?
- add_placeholder(
- current_file->document->section_id_1_1 + "." + detail::to_s(id), category) :
- add_id(id, category);
- }
-
- id_placeholder const* id_state::begin_section(
- boost::string_ref id,
- id_category category)
- {
- current_file->document->section_id_1_1 = detail::to_s(id);
- return create_new_section(id, category);
- }
-
- id_placeholder const* id_state::create_new_section(
- boost::string_ref id,
- id_category category)
- {
- boost::shared_ptr<section_info> parent =
- current_file->document->current_section;
-
- id_placeholder const* p = 0;
- id_placeholder const* placeholder_1_6 = 0;
-
- std::string id_1_1;
-
- if (parent && current_file->compatibility_version < 106u) {
- id_1_1 = parent->id_1_1;
- if (!id_1_1.empty() && !id.empty())
- id_1_1 += ".";
- id_1_1.append(id.begin(), id.end());
- }
-
- if (current_file->compatibility_version >= 106u) {
- p = placeholder_1_6 = add_id_to_section(id, category, parent);
- }
- else if (current_file->compatibility_version >= 103u) {
- placeholder_1_6 = get_id_placeholder(parent);
-
- std::string new_id;
- if (!placeholder_1_6) {
- new_id = current_file->doc_id_1_1;
- if (!id_1_1.empty()) new_id += '.';
- }
- new_id += id_1_1;
-
- p = add_placeholder(new_id, category, placeholder_1_6);
- }
- else {
- placeholder_1_6 = get_id_placeholder(parent);
-
- std::string new_id;
- if (parent && !placeholder_1_6)
- new_id = current_file->doc_id_1_1 + '.';
-
- new_id += detail::to_s(id);
-
- p = add_placeholder(new_id, category, placeholder_1_6);
- }
-
- current_file->document->current_section =
- boost::make_shared<section_info>(parent,
- current_file.get(), id, id_1_1, placeholder_1_6);
-
- return p;
- }
-
- void id_state::end_section()
- {
- current_file->document->current_section =
- current_file->document->current_section->parent;
- }
-}

Deleted: trunk/tools/quickbook/src/id_manager.hpp
==============================================================================
--- trunk/tools/quickbook/src/id_manager.hpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86634)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,86 +0,0 @@
-/*=============================================================================
- Copyright (c) 2011 Daniel James
-
- 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_QUICKBOOK_ID_MANAGER_HPP)
-#define BOOST_QUICKBOOK_ID_MANAGER_HPP
-
-#include <boost/scoped_ptr.hpp>
-#include <boost/utility/string_ref.hpp>
-#include <string>
-#include "values.hpp"
-
-namespace quickbook
-{
- // id_category
- //
- // Higher categories get priority over lower ones.
-
- struct id_category
- {
- enum categories
- {
- default_category = 0,
- numbered, // Just used to avoid random docbook ids
- generated, // Generated ids for other elements.
- generated_heading, // Generated ids for headings.
- generated_section, // Generated ids for sections.
- generated_doc, // Generated ids for document.
- explicit_id, // Explicitly given by user
- explicit_section_id,
- explicit_anchor_id
- };
-
- id_category() : c(default_category) {}
- id_category(categories c) : c(c) {}
- explicit id_category(int c) : c(categories(c)) {}
-
- bool operator==(id_category rhs) const { return c == rhs.c; }
-
- categories c;
- };
-
- struct id_state;
-
- struct id_manager
- {
- id_manager();
- ~id_manager();
-
- std::string start_file_with_docinfo(
- unsigned compatibility_version,
- boost::string_ref include_doc_id,
- boost::string_ref id,
- value const& title);
-
- void start_file(
- unsigned compatibility_version,
- boost::string_ref include_doc_id,
- boost::string_ref id,
- value const& title);
-
- void end_file();
-
- std::string begin_section(boost::string_ref, id_category);
- void end_section();
- int section_level() 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 replace_placeholders_with_unresolved_ids(
- boost::string_ref) const;
- std::string replace_placeholders(boost::string_ref) const;
-
- unsigned compatibility_version() const;
- private:
- boost::scoped_ptr<id_state> state;
- };
-}
-
-#endif

Deleted: trunk/tools/quickbook/src/id_manager_impl.hpp
==============================================================================
--- trunk/tools/quickbook/src/id_manager_impl.hpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86634)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,144 +0,0 @@
-/*=============================================================================
- Copyright (c) 2011-2013 Daniel James
-
- 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_QUICKBOOK_ID_MANAGER_IMPL_HPP)
-#define BOOST_QUICKBOOK_ID_MANAGER_IMPL_HPP
-
-#include "id_manager.hpp"
-#include "utils.hpp"
-#include <boost/utility/string_ref.hpp>
-#include <boost/shared_ptr.hpp>
-#include <deque>
-#include <string>
-#include <vector>
-
-namespace quickbook
-{
- //
- // id_placeholder
- //
- // When generating the xml, quickbook can't allocate the identifiers until
- // the end, so it stores in the intermedia xml a placeholder string,
- // e.g. id="$1". This represents one of these placeholders.
- //
-
- struct id_placeholder
- {
- unsigned index; // The index in id_state::placeholders.
- // Use for the dollar identifiers in
- // intermediate xml.
- std::string unresolved_id;
- // The id that would be generated
- // without any duplicate handling.
- // Used for generating old style header anchors.
- std::string id; // The node id.
- id_placeholder const* parent;
- // Placeholder of the parent id.
- id_category category;
- unsigned num_dots; // Number of dots in the id.
- // Normally equal to the section level
- // but not when an explicit id contains
- // dots.
-
- id_placeholder(unsigned index, boost::string_ref id,
- id_category category, id_placeholder const* parent_);
-
- std::string to_string() const;
- };
-
- //
- // id_state
- //
- // Contains all the data tracked by the id_manager.
- //
-
- struct file_info;
- struct doc_info;
- struct section_info;
-
- struct id_state
- {
- boost::shared_ptr<file_info> current_file;
- std::deque<id_placeholder> placeholders;
-
- // Placeholder methods
-
- id_placeholder const* add_placeholder(boost::string_ref, id_category,
- id_placeholder const* parent = 0);
-
- id_placeholder const* get_placeholder(boost::string_ref) const;
-
- id_placeholder const* get_id_placeholder(
- boost::shared_ptr<section_info> const& section) const;
-
- // Events
-
- id_placeholder const* start_file(
- unsigned compatibility_version,
- bool document_root,
- boost::string_ref include_doc_id,
- boost::string_ref id,
- value const& title);
-
- void end_file();
-
- id_placeholder const* add_id(
- boost::string_ref id,
- id_category category);
- id_placeholder const* old_style_id(
- boost::string_ref id,
- id_category category);
- id_placeholder const* begin_section(
- boost::string_ref id,
- id_category category);
- void end_section();
-
- private:
- id_placeholder const* add_id_to_section(
- boost::string_ref id,
- id_category category,
- boost::shared_ptr<section_info> const& section);
- id_placeholder const* create_new_section(
- boost::string_ref id,
- id_category category);
- };
-
- std::string replace_ids(id_state const& state, boost::string_ref xml,
- std::vector<std::string> const* = 0);
- std::vector<std::string> generate_ids(id_state const&, boost::string_ref);
-
- std::string normalize_id(boost::string_ref src_id);
- std::string normalize_id(boost::string_ref src_id, std::size_t);
-
- //
- // Xml subset parser used for finding id values.
- //
- // I originally tried to integrate this into the post processor
- // but that proved tricky. Alternatively it could use a proper
- // xml parser, but I want this to be able to survive badly
- // marked up escapes.
- //
-
- struct xml_processor
- {
- xml_processor();
-
- std::vector<std::string> id_attributes;
-
- struct callback {
- virtual void start(boost::string_ref) {}
- virtual void id_value(boost::string_ref) {}
- virtual void finish(boost::string_ref) {}
- virtual ~callback() {}
- };
-
- void parse(boost::string_ref, callback&);
- };
-}
-
-#endif

Modified: trunk/tools/quickbook/src/id_xml.cpp
==============================================================================
--- trunk/tools/quickbook/src/id_xml.cpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/id_xml.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -6,7 +6,7 @@
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
 
-#include "id_manager_impl.hpp"
+#include "document_state_impl.hpp"
 #include "utils.hpp"
 #include <boost/range/algorithm.hpp>
 

Modified: trunk/tools/quickbook/src/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/src/quickbook.cpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/quickbook.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -15,7 +15,7 @@
 #include "utils.hpp"
 #include "files.hpp"
 #include "input_path.hpp"
-#include "id_manager.hpp"
+#include "document_state.hpp"
 #include <boost/program_options.hpp>
 #include <boost/filesystem/path.hpp>
 #include <boost/filesystem/operations.hpp>
@@ -138,12 +138,12 @@
       , parse_document_options const& options_)
     {
         string_stream buffer;
- id_manager ids;
+ document_state output;
 
         int result = 0;
 
         try {
- quickbook::state state(filein_, options_.xinclude_base, buffer, ids);
+ quickbook::state state(filein_, options_.xinclude_base, buffer, output);
             set_macros(state);
 
             if (state.error_count == 0) {
@@ -184,7 +184,7 @@
 
         if (!fileout_.empty() && result == 0)
         {
- std::string stage2 = ids.replace_placeholders(buffer.str());
+ std::string stage2 = output.replace_placeholders(buffer.str());
 
             fs::ofstream fileout(fileout_);
 

Modified: trunk/tools/quickbook/src/state.cpp
==============================================================================
--- trunk/tools/quickbook/src/state.cpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/state.cpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -27,7 +27,7 @@
     unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
 
     state::state(fs::path const& filein_, fs::path const& xinclude_base_,
- string_stream& out_, id_manager& ids)
+ string_stream& out_, document_state& document)
         : grammar_()
 
         , xinclude_base(xinclude_base_)
@@ -37,7 +37,7 @@
         , anchors()
         , warned_about_breaks(false)
         , conditional(true)
- , ids(ids)
+ , document(document)
         , callouts()
         , callout_depth(0)
         , dependencies()

Modified: trunk/tools/quickbook/src/state.hpp
==============================================================================
--- trunk/tools/quickbook/src/state.hpp Tue Nov 12 02:52:06 2013 (r86634)
+++ trunk/tools/quickbook/src/state.hpp 2013-11-12 04:12:17 EST (Tue, 12 Nov 2013) (r86635)
@@ -27,7 +27,7 @@
     struct state
     {
         state(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_,
- id_manager&);
+ document_state&);
 
     private:
         boost::scoped_ptr<quickbook_grammar> grammar_;
@@ -48,7 +48,7 @@
         string_list anchors;
         bool warned_about_breaks;
         bool conditional;
- id_manager& ids;
+ document_state& document;
         value_builder callouts; // callouts are global as
         int callout_depth; // they don't nest.
         dependency_tracker dependencies;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk