Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69170 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-02-22 15:31:31


Author: danieljames
Date: 2011-02-22 15:31:27 EST (Tue, 22 Feb 2011)
New Revision: 69170
URL: http://svn.boost.org/trac/boost/changeset/69170

Log:
Convert begin and end section to new style.
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 78 ++++++++++++++++++++-------------------
   branches/quickbook-filenames/tools/quickbook/src/actions.hpp | 57 -----------------------------
   branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp | 2 -
   branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp | 2 -
   branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp | 11 ++---
   branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp | 4 +-
   6 files changed, 47 insertions(+), 107 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-02-22 15:31:27 EST (Tue, 22 Feb 2011)
@@ -50,8 +50,10 @@
     }
 
     void header_action(quickbook::actions&, value);
+ void begin_section_action(quickbook::actions&, value);
+ void end_section_action(quickbook::actions&, value, file_position);
 
- void element_action::operator()(iterator, iterator) const
+ void element_action::operator()(iterator first, iterator) const
     {
         value_consumer values = actions.values.get();
         if(!values.is()) return;
@@ -68,6 +70,10 @@
         case block_tags::heading5:
         case block_tags::heading6:
             return header_action(actions, v);
+ case block_tags::begin_section:
+ return begin_section_action(actions, v);
+ case block_tags::end_section:
+ return end_section_action(actions, v, first.get_position());
         default:
             break;
         }
@@ -1307,57 +1313,53 @@
         }
     }
 
- void begin_section_action::operator()(iterator, iterator) const
+ void begin_section_action(quickbook::actions& actions, value begin_section_list)
     {
         if(actions.suppress) return;
 
- value_consumer values = actions.values.get();
- value begin_section_list = values.consume(block_tags::begin_section);
- assert(!values.is());
-
- values = begin_section_list;
+ value_consumer values = begin_section_list;
 
         value element_id = values.optional_consume(general_tags::element_id);
         value content = values.consume();
         assert(!values.is());
 
- section_id = !element_id.is_empty() ?
+ actions.section_id = !element_id.is_empty() ?
             element_id.get_quickbook() :
             detail::make_identifier(content.get_quickbook());
 
- if (section_level != 0)
- qualified_section_id += '.';
+ if (actions.section_level != 0)
+ actions.qualified_section_id += '.';
         else
- BOOST_ASSERT(qualified_section_id.empty());
+ BOOST_ASSERT(actions.qualified_section_id.empty());
 
- qualified_section_id += section_id;
- ++section_level;
+ actions.qualified_section_id += actions.section_id;
+ ++actions.section_level;
 
- actions.output_pre(out);
+ actions.output_pre(actions.out);
 
         if (qbk_version_n < 103) // version 1.2 and below
         {
- out << "\n<section id=\""
- << library_id << "." << section_id << "\">\n";
+ actions.out << "\n<section id=\""
+ << actions.doc_id << "." << actions.section_id << "\">\n";
         }
         else // version 1.3 and above
         {
- out << "\n<section id=\"" << library_id
- << "." << qualified_section_id << "\">\n";
+ actions.out << "\n<section id=\"" << actions.doc_id
+ << "." << actions.qualified_section_id << "\">\n";
         }
 
         actions.anchors.swap(actions.saved_anchors);
- actions.output_pre(out);
+ actions.output_pre(actions.out);
 
         if (qbk_version_n < 103) // version 1.2 and below
         {
- out << "<title>" << content.get_boostbook() << "</title>\n";
+ actions.out << "<title>" << content.get_boostbook() << "</title>\n";
         }
         else // version 1.3 and above
         {
- out << "<title>"
- << "<link linkend=\"" << library_id
- << "." << qualified_section_id << "\">"
+ actions.out << "<title>"
+ << "<link linkend=\"" << actions.doc_id
+ << "." << actions.qualified_section_id << "\">"
                 << content.get_boostbook()
                 << "</link>"
                 << "</title>\n"
@@ -1365,36 +1367,31 @@
         }
     }
 
- void end_section_action::operator()(iterator, iterator) const
+ void end_section_action(quickbook::actions& actions, value end_section, file_position pos)
     {
- if(!actions.output_pre(out)) return;
-
- value_consumer values = actions.values.get();
- value end_section = values.consume(block_tags::end_section);
- assert(!values.is());
+ if(!actions.output_pre(actions.out)) return;
 
- if (section_level <= min_section_level)
+ if (actions.section_level <= actions.min_section_level)
         {
- file_position const pos = end_section.get_position();
             detail::outerr(actions.filename, pos.line)
                 << "Mismatched [endsect] near column " << pos.column << ".\n";
- ++error_count;
+ ++actions.error_count;
             
             return;
         }
 
- --section_level;
- out << "</section>";
+ --actions.section_level;
+ actions.out << "</section>";
 
- if (section_level == 0)
+ if (actions.section_level == 0)
         {
- qualified_section_id.clear();
+ actions.qualified_section_id.clear();
         }
         else
         {
             std::string::size_type const n =
- qualified_section_id.find_last_of('.');
- qualified_section_id.erase(n, std::string::npos);
+ actions.qualified_section_id.find_last_of('.');
+ actions.qualified_section_id.erase(n, std::string::npos);
         }
     }
     
@@ -1563,10 +1560,15 @@
         *boost::spirit::classic::find(actions.macro, "__FILENAME__")
             = detail::path_to_generic(actions.filename);
 
+ // save values
+ actions.values.builder.save();
+
         // parse the file
         quickbook::parse_file(actions.filename.string().c_str(), actions, true);
 
         // restore the values
+ actions.values.builder.restore();
+
         std::swap(actions.filename, filein);
 
         actions.doc_type.swap(doc_type);

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.hpp 2011-02-22 15:31:27 EST (Tue, 22 Feb 2011)
@@ -609,63 +609,6 @@
         quickbook::actions& actions;
     };
 
- struct begin_section_action
- {
- // Handles begin page
-
- begin_section_action(
- collector& out
- , collector& phrase
- , std::string& library_id
- , std::string& section_id
- , int& section_level
- , std::string& qualified_section_id
- , quickbook::actions& actions)
- : out(out)
- , phrase(phrase)
- , library_id(library_id)
- , section_id(section_id)
- , section_level(section_level)
- , qualified_section_id(qualified_section_id)
- , actions(actions) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& phrase;
- std::string& library_id;
- std::string& section_id;
- int& section_level;
- std::string& qualified_section_id;
- quickbook::actions& actions;
- };
-
- struct end_section_action
- {
- end_section_action(
- collector& out
- , int& section_level
- , int& min_section_level
- , std::string& qualified_section_id
- , int& error_count
- , quickbook::actions& actions)
- : out(out)
- , section_level(section_level)
- , min_section_level(min_section_level)
- , qualified_section_id(qualified_section_id)
- , error_count(error_count)
- , actions(actions) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- int& section_level;
- int& min_section_level;
- std::string& qualified_section_id;
- int& error_count;
- quickbook::actions& actions;
- };
-
    struct element_id_warning_action
    {
         element_id_warning_action(quickbook::actions& actions_)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp 2011-02-22 15:31:27 EST (Tue, 22 Feb 2011)
@@ -141,8 +141,6 @@
         , table(*this)
         , anchor(*this)
 
- , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id, *this)
- , end_section(out, section_level, min_section_level, qualified_section_id, error_count, *this)
         , element_id_warning(*this)
         , xinclude(out, *this)
         , include(*this)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp 2011-02-22 15:31:27 EST (Tue, 22 Feb 2011)
@@ -181,8 +181,6 @@
         table_action table;
         anchor_action anchor;
 
- begin_section_action begin_section;
- end_section_action end_section;
         element_id_warning_action element_id_warning;
         xinclude_action xinclude;
         include_action include;

Modified: branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp 2011-02-22 15:31:27 EST (Tue, 22 Feb 2011)
@@ -67,22 +67,21 @@
                 ;
 
         elements.add
- ("section", element_info(element_info::block, &local.begin_section))
- ("endsect", element_info(element_info::block, &local.end_section))
+ ("section", element_info(element_info::block, &local.begin_section, block_tags::begin_section))
+ ("endsect", element_info(element_info::block, &local.end_section, block_tags::end_section))
             ;
 
         local.begin_section =
- actions.values.scoped(block_tags::begin_section)
+ actions.values.scoped
             [ space
>> local.element_id
>> space
>> local.inner_phrase
- ] [actions.begin_section]
+ ]
             ;
 
         local.end_section =
- cl::eps_p [actions.values.entry(ph::arg1, ph::arg2, block_tags::end_section)]
- [actions.end_section]
+ cl::eps_p [actions.values.entry(ph::arg1, ph::arg2)]
             ;
 
         local.heading

Modified: branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp 2011-02-22 15:31:27 EST (Tue, 22 Feb 2011)
@@ -174,7 +174,7 @@
         void operator()(Iterator begin, Iterator end,
                 value::tag_type tag = value::no_tag) const
         {
- b.insert(qbk_value(begin, end, tag));
+ b.insert(qbk_value(begin, end, b.release_tag(tag)));
         }
 
         template <typename Iterator>
@@ -182,7 +182,7 @@
                 std::string const& v,
                 value::tag_type tag = value::no_tag) const
         {
- b.insert(qbk_value(v, begin.get_position(), tag));
+ b.insert(qbk_value(v, begin.get_position(), b.release_tag(tag)));
         }
 
         value_builder& b;


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