$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r65284 - branches/quickbook-1.5-spirit2/src
From: dnljms_at_[hidden]
Date: 2010-09-05 05:32:46
Author: danieljames
Date: 2010-09-05 05:32:45 EDT (Sun, 05 Sep 2010)
New Revision: 65284
URL: http://svn.boost.org/trac/boost/changeset/65284
Log:
Encapsulate code_snippets.
In a similar manner to trunk.
Text files modified: 
   branches/quickbook-1.5-spirit2/src/block_actions.cpp        |    34 ----------------------------------      
   branches/quickbook-1.5-spirit2/src/code_snippet_actions.cpp |     1 +                                       
   branches/quickbook-1.5-spirit2/src/code_snippet_grammar.cpp |    33 +++++++++++++++++++++++++++++++++       
   branches/quickbook-1.5-spirit2/src/fwd.hpp                  |     1 -                                       
   branches/quickbook-1.5-spirit2/src/quickbook.hpp            |     2 ++                                      
   5 files changed, 36 insertions(+), 35 deletions(-)
Modified: branches/quickbook-1.5-spirit2/src/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/block_actions.cpp	(original)
+++ branches/quickbook-1.5-spirit2/src/block_actions.cpp	2010-09-05 05:32:45 EDT (Sun, 05 Sep 2010)
@@ -15,8 +15,6 @@
 #include "actions.hpp"
 #include "state.hpp"
 #include "quickbook.hpp"
-#include "code_snippet_grammar.hpp"
-#include "code_snippet_types.hpp"
 #include "utils.hpp"
 #include "encoder.hpp"
 
@@ -234,38 +232,6 @@
 
     namespace
     {
-        int load_snippets(
-            std::string const& file
-          , std::vector<define_template>& storage   // for storing snippets are stored in a
-                                                    // vector of define_templates
-          , std::string const& extension
-          , std::string const& doc_id)
-        {
-            std::string code;
-            int err = detail::load(file, code);
-            if (err != 0)
-                return err; // return early on error
-    
-            iterator first(code.begin(), code.end(), file.c_str());
-            iterator last(code.end(), code.end());
-    
-            size_t fname_len = file.size();
-            bool is_python = fname_len >= 3
-                && file[--fname_len]=='y' && file[--fname_len]=='p' && file[--fname_len]=='.';
-            code_snippet_actions a(storage, doc_id, is_python ? "[python]" : "[c++]");
-            // TODO: Should I check that parse succeeded?
-            if(is_python) {
-                python_code_snippet_grammar g(a);
-                boost::spirit::qi::parse(first, last, g);
-            }
-            else {
-                cpp_code_snippet_grammar g(a);
-                boost::spirit::qi::parse(first, last, g);
-            }
-    
-            return 0;
-        }
-
         fs::path include_search(fs::path const & current, std::string const & name)
         {
             fs::path path(name);
Modified: branches/quickbook-1.5-spirit2/src/code_snippet_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/code_snippet_actions.cpp	(original)
+++ branches/quickbook-1.5-spirit2/src/code_snippet_actions.cpp	2010-09-05 05:32:45 EDT (Sun, 05 Sep 2010)
@@ -19,6 +19,7 @@
 #include "grammar.hpp"
 #include "code_snippet_types.hpp"
 #include "template.hpp"
+#include "quickbook.hpp"
 
 namespace quickbook
 {
Modified: branches/quickbook-1.5-spirit2/src/code_snippet_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/code_snippet_grammar.cpp	(original)
+++ branches/quickbook-1.5-spirit2/src/code_snippet_grammar.cpp	2010-09-05 05:32:45 EDT (Sun, 05 Sep 2010)
@@ -17,6 +17,7 @@
 #include "code_snippet_grammar.hpp"
 #include "misc_rules.hpp"
 #include "parse_utils.hpp"
+#include "utils.hpp" // For 'detail::load', rewrite so it isn't used here?
 
 namespace quickbook
 {
@@ -214,4 +215,36 @@
                 )   [member_assign(&quickbook::escaped_comment::content)]
             ;
     }
+
+    int load_snippets(
+        std::string const& file
+      , std::vector<define_template>& storage   // for storing snippets are stored in a
+                                                // vector of define_templates
+      , std::string const& extension
+      , std::string const& doc_id)
+    {
+        std::string code;
+        int err = detail::load(file, code);
+        if (err != 0)
+            return err; // return early on error
+
+        iterator first(code.begin(), code.end(), file.c_str());
+        iterator last(code.end(), code.end());
+
+        size_t fname_len = file.size();
+        bool is_python = fname_len >= 3
+            && file[--fname_len]=='y' && file[--fname_len]=='p' && file[--fname_len]=='.';
+        code_snippet_actions a(storage, doc_id, is_python ? "[python]" : "[c++]");
+        // TODO: Should I check that parse succeeded?
+        if(is_python) {
+            python_code_snippet_grammar g(a);
+            boost::spirit::qi::parse(first, last, g);
+        }
+        else {
+            cpp_code_snippet_grammar g(a);
+            boost::spirit::qi::parse(first, last, g);
+        }
+
+        return 0;
+    }
 }
Modified: branches/quickbook-1.5-spirit2/src/fwd.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/fwd.hpp	(original)
+++ branches/quickbook-1.5-spirit2/src/fwd.hpp	2010-09-05 05:32:45 EDT (Sun, 05 Sep 2010)
@@ -22,7 +22,6 @@
 
     struct state;
     struct actions;
-    struct code_snippet_actions;
 
     struct collector;
     struct string_stream;
Modified: branches/quickbook-1.5-spirit2/src/quickbook.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/quickbook.hpp	(original)
+++ branches/quickbook-1.5-spirit2/src/quickbook.hpp	2010-09-05 05:32:45 EDT (Sun, 05 Sep 2010)
@@ -27,6 +27,8 @@
 
     // forward declarations
     int parse_file(char const* filein_, state&, bool ignore_docinfo = false);
+    int load_snippets(std::string const& file, std::vector<define_template>& storage,
+        std::string const& extension, std::string const& doc_id);
 }
 
 #endif