Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75626 - branches/quickbook-dev/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-11-22 18:48:54


Author: danieljames
Date: 2011-11-22 18:48:54 EST (Tue, 22 Nov 2011)
New Revision: 75626
URL: http://svn.boost.org/trac/boost/changeset/75626

Log:
Quickbook: Clean up starting and ending snippets.
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp | 23 ++++++++++++++++-------
   1 files changed, 16 insertions(+), 7 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp 2011-11-22 18:48:54 EST (Tue, 22 Nov 2011)
@@ -43,7 +43,9 @@
         void pass_thru(string_iterator first, string_iterator last);
         void escaped_comment(string_iterator first, string_iterator last);
         void start_snippet(string_iterator first, string_iterator last);
+ void start_snippet_impl(std::string const&, string_iterator);
         void end_snippet(string_iterator first, string_iterator last);
+ void end_snippet_impl(string_iterator);
         void callout(string_iterator first, string_iterator last);
         
         void append_code(string_iterator first, string_iterator last);
@@ -470,8 +472,7 @@
         {
             if (!snippet_stack)
             {
- // TODO: This should be: start_snippet(first,first);
- push_snippet_data("!", callout_id, first);
+ start_snippet_impl("!", first);
             }
     
             snippet_data& snippet = *snippet_stack;
@@ -481,7 +482,7 @@
 
             if (snippet.id == "!")
             {
- end_snippet(last, last);
+ end_snippet_impl(last);
             }
         }
     }
@@ -489,17 +490,25 @@
     void code_snippet_actions::start_snippet(string_iterator first, string_iterator last)
     {
         append_code(first, last);
- std::string id(mark_begin, mark_end);
- push_snippet_data(id, callout_id, first);
+ start_snippet_impl(std::string(mark_begin, mark_end), first);
     }
 
     void code_snippet_actions::end_snippet(string_iterator first, string_iterator last)
     {
         // TODO: Error?
         if(!snippet_stack) return;
-
         append_code(first, last);
+ end_snippet_impl(first);
+ }
+
+ void code_snippet_actions::start_snippet_impl(std::string const& id,
+ string_iterator position)
+ {
+ push_snippet_data(id, callout_id, position);
+ }
 
+ void code_snippet_actions::end_snippet_impl(string_iterator position)
+ {
         boost::shared_ptr<snippet_data> snippet = pop_snippet_data();
         value callouts = snippet->callouts.release();
 
@@ -512,7 +521,7 @@
         }
         f.add(content, snippet->start_pos, content.get_pos());
         if (in_code) {
- f.add("\n```\n\n", first);
+ f.add("\n```\n\n", position);
         }
 
         std::vector<std::string> params;


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