|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59554 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-02-07 04:08:42
Author: danieljames
Date: 2010-02-07 04:08:40 EST (Sun, 07 Feb 2010)
New Revision: 59554
URL: http://svn.boost.org/trac/boost/changeset/59554
Log:
Starting to separate out boostbook encoding.
Added:
branches/quickbook-1.5-spirit2/boostbook.cpp (contents, props changed)
branches/quickbook-1.5-spirit2/boostbook.hpp (contents, props changed)
Text files modified:
branches/quickbook-1.5-spirit2/Jamfile.v2 | 1 +
branches/quickbook-1.5-spirit2/parse_types.hpp | 2 --
branches/quickbook-1.5-spirit2/phrase_actions.cpp | 39 ++++++++++++---------------------------
branches/quickbook-1.5-spirit2/process.cpp | 18 +++++++++++-------
4 files changed, 24 insertions(+), 36 deletions(-)
Modified: branches/quickbook-1.5-spirit2/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/Jamfile.v2 2010-02-07 04:08:40 EST (Sun, 07 Feb 2010)
@@ -39,6 +39,7 @@
code_snippet.cpp
code_snippet_grammar.cpp
syntax_highlight.cpp
+ boostbook.cpp
/boost//program_options
/boost//filesystem
: #<define>QUICKBOOK_NO_DATES
Added: branches/quickbook-1.5-spirit2/boostbook.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/boostbook.cpp 2010-02-07 04:08:40 EST (Sun, 07 Feb 2010)
@@ -0,0 +1,31 @@
+#include "fwd.hpp"
+#include "boostbook.hpp"
+#include "phrase.hpp"
+#include "actions_class.hpp"
+#include "utils.hpp"
+
+namespace quickbook
+{
+ void output(quickbook::actions& actions, std::string const& x)
+ {
+ actions.phrase << x;
+ }
+
+ void output(quickbook::actions& actions, anchor const& x) {
+ actions.phrase << "<anchor id=\"";
+ detail::print_string(x.id, actions.phrase.get());
+ actions.phrase << "\" />\n";
+ }
+
+ void output(quickbook::actions& actions, link const& x) {
+ actions.phrase << x.type.pre;
+ detail::print_string(x.destination, actions.phrase.get());
+ actions.phrase << "\">";
+ actions.phrase << x.content;
+ actions.phrase << x.type.post;
+ }
+
+ void output(quickbook::actions& actions, formatted const& x) {
+ actions.phrase << x.type.pre << x.content << x.type.post;
+ }
+}
Added: branches/quickbook-1.5-spirit2/boostbook.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/boostbook.hpp 2010-02-07 04:08:40 EST (Sun, 07 Feb 2010)
@@ -0,0 +1,16 @@
+#include "fwd.hpp"
+#include "phrase.hpp"
+
+namespace quickbook
+{
+ // Output function for boostbook, these should eventually become an
+ // interface with implementations for boostbook and html.
+ // They probably shouldn't use quickbook::actions, instead they
+ // should either take a stream/collector to write to, or return their
+ // output by value.
+
+ void output(quickbook::actions&, std::string const&);
+ void output(quickbook::actions&, anchor const&);
+ void output(quickbook::actions&, link const&);
+ void output(quickbook::actions&, formatted const&);
+}
Modified: branches/quickbook-1.5-spirit2/parse_types.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/parse_types.hpp (original)
+++ branches/quickbook-1.5-spirit2/parse_types.hpp 2010-02-07 04:08:40 EST (Sun, 07 Feb 2010)
@@ -30,8 +30,6 @@
markup type;
std::string content;
};
-
- nothing process(quickbook::actions&, formatted const&);
}
BOOST_FUSION_ADAPT_STRUCT(
Modified: branches/quickbook-1.5-spirit2/phrase_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_actions.cpp 2010-02-07 04:08:40 EST (Sun, 07 Feb 2010)
@@ -22,48 +22,33 @@
return nothing();
}
- nothing process(quickbook::actions& actions, macro const& x) {
+ std::string process(quickbook::actions& actions, macro const& x) {
+ // TODO: Should the dates be encoded?
if (x.raw_markup == quickbook_get_date)
{
char strdate[64];
strftime(strdate, sizeof(strdate), "%Y-%b-%d", current_time);
- actions.phrase << strdate;
+ return strdate;
}
else if (x.raw_markup == quickbook_get_time)
{
char strdate[64];
strftime(strdate, sizeof(strdate), "%I:%M:%S %p", current_time);
- actions.phrase << strdate;
+ return strdate;
}
else
{
- actions.phrase << x.raw_markup;
+ return x.raw_markup;
}
- return nothing();
- }
-
- nothing process(quickbook::actions& actions, anchor const& x) {
- actions.phrase << "<anchor id=\"";
- detail::print_string(x.id, actions.phrase.get());
- actions.phrase << "\" />\n";
- return nothing();
- }
-
- nothing process(quickbook::actions& actions, link const& x) {
- actions.phrase << x.type.pre;
- detail::print_string(x.destination, actions.phrase.get());
- actions.phrase << "\">";
- if(x.content.empty())
- detail::print_string(x.destination, actions.phrase.get());
- else
- actions.phrase << x.content;
- actions.phrase << x.type.post;
- return nothing();
}
- nothing process(quickbook::actions& actions, formatted const& x) {
- actions.phrase << x.type.pre << x.content << x.type.post;
- return nothing();
+ link process(quickbook::actions& actions, link const& x) {
+ link r = x;
+ if(r.content.empty()) {
+ // TODO: Encode this
+ r.content = x.destination;
+ }
+ return r;
}
nothing process(quickbook::actions& actions, simple_markup const& x) {
Modified: branches/quickbook-1.5-spirit2/process.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/process.cpp (original)
+++ branches/quickbook-1.5-spirit2/process.cpp 2010-02-07 04:08:40 EST (Sun, 07 Feb 2010)
@@ -10,13 +10,14 @@
=============================================================================*/
#include "fwd.hpp"
+#include "phrase_actions.hpp"
#include "actions.hpp"
#include "parse_types.hpp"
-#include "phrase.hpp"
#include "block.hpp"
#include "code.hpp"
#include "syntax_highlight.hpp"
#include "template.hpp"
+#include "boostbook.hpp"
namespace quickbook
{
@@ -26,14 +27,17 @@
output(actions, process(actions, x));
}
- void output(quickbook::actions&, nothing) {}
+ template <typename T>
+ T const& process(quickbook::actions&, T const& x)
+ {
+ return x;
+ }
+
+ void output(quickbook::actions&, nothing) {
+ }
- nothing process(quickbook::actions&, formatted const&);
- nothing process(quickbook::actions&, source_mode const&);
- nothing process(quickbook::actions&, macro const&);
+ void output(quickbook::actions&, std::string const&);
nothing process(quickbook::actions&, call_template const&);
- nothing process(quickbook::actions&, anchor const&);
- nothing process(quickbook::actions&, link const&);
nothing process(quickbook::actions&, simple_markup const&);
nothing process(quickbook::actions&, cond_phrase const&);
nothing process(quickbook::actions&, break_ const&);
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