Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65030 - in trunk/tools/quickbook: . detail src test
From: dnljms_at_[hidden]
Date: 2010-08-26 16:56:52


Author: danieljames
Date: 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
New Revision: 65030
URL: http://svn.boost.org/trac/boost/changeset/65030

Log:
Move the source files into a source directory.
Added:
   trunk/tools/quickbook/src/
   trunk/tools/quickbook/src/Jamfile.v2
      - copied, changed from r65029, /trunk/tools/quickbook/Jamfile.v2
   trunk/tools/quickbook/src/actions.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/actions.cpp
   trunk/tools/quickbook/src/actions.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/actions.hpp
   trunk/tools/quickbook/src/actions_class.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/actions_class.cpp
   trunk/tools/quickbook/src/actions_class.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/actions_class.hpp
   trunk/tools/quickbook/src/block.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/block.hpp
   trunk/tools/quickbook/src/code_snippet.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/code_snippet.hpp
   trunk/tools/quickbook/src/collector.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/collector.cpp
   trunk/tools/quickbook/src/collector.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/collector.hpp
   trunk/tools/quickbook/src/doc_info.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/doc_info.hpp
   trunk/tools/quickbook/src/input_path.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/input_path.cpp
   trunk/tools/quickbook/src/input_path.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/input_path.hpp
   trunk/tools/quickbook/src/markups.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/markups.cpp
   trunk/tools/quickbook/src/markups.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/markups.hpp
   trunk/tools/quickbook/src/phrase.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/phrase.hpp
   trunk/tools/quickbook/src/post_process.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/post_process.cpp
   trunk/tools/quickbook/src/post_process.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/post_process.hpp
   trunk/tools/quickbook/src/quickbook.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/quickbook.cpp
   trunk/tools/quickbook/src/quickbook.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/quickbook.hpp
   trunk/tools/quickbook/src/syntax_highlight.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/syntax_highlight.cpp
   trunk/tools/quickbook/src/syntax_highlight.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/syntax_highlight.hpp
   trunk/tools/quickbook/src/template_stack.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/template_stack.cpp
   trunk/tools/quickbook/src/template_stack.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/template_stack.hpp
   trunk/tools/quickbook/src/utils.cpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/utils.cpp
   trunk/tools/quickbook/src/utils.hpp (contents, props changed)
      - copied, changed from r65029, /trunk/tools/quickbook/detail/utils.hpp
Removed:
   trunk/tools/quickbook/block.hpp
   trunk/tools/quickbook/code_snippet.hpp
   trunk/tools/quickbook/detail/actions.cpp
   trunk/tools/quickbook/detail/actions.hpp
   trunk/tools/quickbook/detail/actions_class.cpp
   trunk/tools/quickbook/detail/actions_class.hpp
   trunk/tools/quickbook/detail/collector.cpp
   trunk/tools/quickbook/detail/collector.hpp
   trunk/tools/quickbook/detail/input_path.cpp
   trunk/tools/quickbook/detail/input_path.hpp
   trunk/tools/quickbook/detail/markups.cpp
   trunk/tools/quickbook/detail/markups.hpp
   trunk/tools/quickbook/detail/post_process.cpp
   trunk/tools/quickbook/detail/post_process.hpp
   trunk/tools/quickbook/detail/quickbook.cpp
   trunk/tools/quickbook/detail/quickbook.hpp
   trunk/tools/quickbook/detail/syntax_highlight.cpp
   trunk/tools/quickbook/detail/template_stack.cpp
   trunk/tools/quickbook/detail/template_stack.hpp
   trunk/tools/quickbook/detail/utils.cpp
   trunk/tools/quickbook/detail/utils.hpp
   trunk/tools/quickbook/doc_info.hpp
   trunk/tools/quickbook/phrase.hpp
   trunk/tools/quickbook/syntax_highlight.hpp
Text files modified:
   trunk/tools/quickbook/Jamfile.v2 | 37 ++-----------------------------------
   trunk/tools/quickbook/src/Jamfile.v2 | 40 ++++++++++------------------------------
   trunk/tools/quickbook/src/actions.cpp | 6 +++---
   trunk/tools/quickbook/src/block.hpp | 4 ++--
   trunk/tools/quickbook/src/code_snippet.hpp | 4 ++--
   trunk/tools/quickbook/src/doc_info.hpp | 2 +-
   trunk/tools/quickbook/src/phrase.hpp | 6 +++---
   trunk/tools/quickbook/src/quickbook.cpp | 4 ++--
   trunk/tools/quickbook/src/syntax_highlight.cpp | 2 +-
   trunk/tools/quickbook/test/quickbook-testing.jam | 4 ++--
   10 files changed, 28 insertions(+), 81 deletions(-)

Modified: trunk/tools/quickbook/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/Jamfile.v2 (original)
+++ trunk/tools/quickbook/Jamfile.v2 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -8,41 +8,8 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 #==============================================================================
 
-project quickbook
- : requirements
- <toolset>gcc:<c++-template-depth>300
- <toolset>darwin:<c++-template-depth>300
- <toolset>gcc:<cflags>-g0
- <toolset>darwin:<cflags>-g0
- ;
-
-exe quickbook
- :
- detail/quickbook.cpp
- detail/actions.cpp
- detail/actions_class.cpp
- detail/utils.cpp
- detail/input_path.cpp
- detail/post_process.cpp
- detail/collector.cpp
- detail/template_stack.cpp
- detail/markups.cpp
- detail/syntax_highlight.cpp
- /boost//program_options
- /boost//filesystem
- : #<define>QUICKBOOK_NO_DATES
- # Still using 'normalize' which has been deprecated.
- #<define>BOOST_FILESYSTEM_NO_DEPRECATED
- <toolset>msvc:<cxxflags>/wd4355
- <toolset>msvc:<cxxflags>/wd4511
- <toolset>msvc:<cxxflags>/wd4512
- <toolset>msvc:<cxxflags>/wd4701
- <toolset>msvc:<cxxflags>/wd4702
- <toolset>msvc:<cxxflags>/wd4244
- <toolset>msvc:<cxxflags>/wd4267
- <toolset>msvc:<cxxflags>/wd4800
- <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
- <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
+alias quickbook
+ : src//quickbook
     ;
 
 install dist-bin

Deleted: trunk/tools/quickbook/block.hpp
==============================================================================
--- trunk/tools/quickbook/block.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,481 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_BLOCK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
-
-#include "./detail/quickbook.hpp"
-#include "./detail/utils.hpp"
-#include "./phrase.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/spirit/include/classic_chset.hpp>
-#include <boost/spirit/include/classic_assign_actor.hpp>
-#include <boost/spirit/include/classic_if.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
-
- struct block_grammar : grammar<block_grammar>
- {
- block_grammar(quickbook::actions& actions_, bool skip_initial_spaces = false)
- : actions(actions_), skip_initial_spaces(skip_initial_spaces) { }
-
- template <typename Scanner>
- struct definition
- {
- definition(block_grammar const& self)
- : no_eols(true)
- , common(self.actions, no_eols)
- {
- using detail::var;
- quickbook::actions& actions = self.actions;
-
- if (self.skip_initial_spaces)
- {
- start_ =
- *(blank_p | comment) >> blocks >> blank
- ;
- }
- else
- {
- start_ =
- blocks >> blank
- ;
- }
-
- blocks =
- *( block_markup
- | code
- | list [actions.list]
- | hr [actions.hr]
- | +eol
- | paragraph [actions.inside_paragraph]
- [actions.write_paragraphs]
- )
- ;
-
- space =
- *(space_p | comment)
- ;
-
- blank =
- *(blank_p | comment)
- ;
-
- eol = blank >> eol_p
- ;
-
- phrase_end =
- ']' |
- if_p(var(no_eols))
- [
- eol >> *blank_p >> eol_p
- // Make sure that we don't go
- ] // past a single block, except
- ; // when preformatted.
-
- hard_space =
- (eps_p - (alnum_p | '_')) >> space // must not be preceded by
- ; // alpha-numeric or underscore
-
- comment =
- "[/" >> *(dummy_block | (anychar_p - ']')) >> ']'
- ;
-
- dummy_block =
- '[' >> *(dummy_block | (anychar_p - ']')) >> ']'
- ;
-
- hr =
- str_p("----")
- >> *(anychar_p - eol)
- >> +eol
- ;
-
- block_markup =
- '[' >> space
- >> ( begin_section
- | end_section
- | headings
- | blurb
- | blockquote
- | admonition
- | preformatted
- | def_macro
- | table
- | variablelist
- | xinclude
- | include
- | import
- | template_
- )
- >> ( (space >> ']' >> +eol)
- | eps_p [actions.error]
- )
- ;
-
- element_id =
- ':'
- >>
- (
- if_p(qbk_since(105u)) [space]
- >> (+(alnum_p | '_')) [assign_a(actions.element_id)]
- | eps_p [actions.element_id_warning]
- [assign_a(actions.element_id)]
- )
- | eps_p [assign_a(actions.element_id)]
- ;
-
- element_id_1_5 =
- if_p(qbk_since(105u)) [
- element_id
- ]
- .else_p [
- eps_p [assign_a(actions.element_id)]
- ]
- ;
-
- element_id_1_6 =
- if_p(qbk_since(106u)) [
- element_id
- ]
- .else_p [
- eps_p [assign_a(actions.element_id)]
- ]
- ;
-
- begin_section =
- "section"
- >> hard_space
- >> element_id
- >> space
- >> phrase [actions.begin_section]
- ;
-
- end_section =
- str_p("endsect") [actions.end_section]
- ;
-
- headings =
- h1 | h2 | h3 | h4 | h5 | h6 | h
- ;
-
- h = "heading" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h];
- h1 = "h1" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h1];
- h2 = "h2" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h2];
- h3 = "h3" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h3];
- h4 = "h4" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h4];
- h5 = "h5" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h5];
- h6 = "h6" >> hard_space >> element_id_1_6 >> space >> phrase [actions.h6];
-
- static const bool true_ = true;
- static const bool false_ = false;
-
- inside_paragraph =
- phrase [actions.inside_paragraph]
- >> *(
- +eol >> phrase [actions.inside_paragraph]
- )
- ;
-
- blurb =
- "blurb" >> hard_space
- >> inside_paragraph [actions.blurb]
- >> eps_p
- ;
-
- blockquote =
- ':' >> blank >>
- inside_paragraph [actions.blockquote]
- ;
-
- admonition =
- "warning" >> blank >>
- inside_paragraph [actions.warning]
- |
- "caution" >> blank >>
- inside_paragraph [actions.caution]
- |
- "important" >> blank >>
- inside_paragraph [actions.important]
- |
- "note" >> blank >>
- inside_paragraph [actions.note]
- |
- "tip" >> blank >>
- inside_paragraph [actions.tip]
- ;
-
- preformatted =
- "pre" >> hard_space [assign_a(no_eols, false_)]
- >> !eol >> phrase [actions.preformatted]
- >> eps_p [assign_a(no_eols, true_)]
- ;
-
- macro_identifier =
- +(anychar_p - (space_p | ']'))
- ;
-
- def_macro =
- "def" >> hard_space
- >> macro_identifier [actions.macro_identifier]
- >> blank >> phrase [actions.macro_definition]
- ;
-
- identifier =
- (alpha_p | '_') >> *(alnum_p | '_')
- ;
-
- template_id =
- identifier | (punct_p - (ch_p('[') | ']'))
- ;
-
- template_ =
- "template"
- >> hard_space
- >> template_id [assign_a(actions.template_identifier)]
- [clear_a(actions.template_info)]
- >>
- !(
- space >> '['
- >> *(
- space >> template_id [push_back_a(actions.template_info)]
- )
- >> space >> ']'
- )
- >> ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)]
- | eps_p [assign_a(actions.template_block, false_)]
- )
- >> template_body [actions.template_body]
- ;
-
- template_body =
- *(('[' >> template_body >> ']') | (anychar_p - ']'))
- >> eps_p(space >> ']')
- >> space
- ;
-
- variablelist =
- "variablelist"
- >> (eps_p(*blank_p >> eol_p) | hard_space)
- >> (*(anychar_p - eol)) [assign_a(actions.table_title)]
- >> +eol
- >> *varlistentry
- >> eps_p [actions.variablelist]
- ;
-
- varlistentry =
- space
- >> ch_p('[') [actions.start_varlistentry]
- >>
- (
- (
- varlistterm [actions.start_varlistitem]
- >> ( +varlistitem
- | eps_p [actions.error]
- ) [actions.end_varlistitem]
- >> ch_p(']') [actions.end_varlistentry]
- >> space
- )
- | eps_p [actions.error]
- )
- ;
-
- varlistterm =
- space
- >> ch_p('[') [actions.start_varlistterm]
- >>
- (
- (
- phrase
- >> ch_p(']') [actions.end_varlistterm]
- >> space
- )
- | eps_p [actions.error]
- )
- ;
-
- varlistitem =
- space
- >> ch_p('[')
- >>
- (
- (
- inside_paragraph
- >> ch_p(']')
- >> space
- )
- | eps_p [actions.error]
- )
- ;
-
- table =
- "table"
- >> (eps_p(*blank_p >> eol_p) | hard_space)
- >> element_id_1_5
- >> (eps_p(*blank_p >> eol_p) | space)
- >> (*(anychar_p - eol)) [assign_a(actions.table_title)]
- >> +eol
- >> *table_row
- >> eps_p [actions.table]
- ;
-
- table_row =
- space
- >> ch_p('[') [actions.start_row]
- >>
- (
- (
- *table_cell
- >> ch_p(']') [actions.end_row]
- >> space
- )
- | eps_p [actions.error]
- )
- ;
-
- table_cell =
- space
- >> ch_p('[') [actions.start_cell]
- >>
- (
- (
- inside_paragraph
- >> ch_p(']') [actions.end_cell]
- >> space
- )
- | eps_p [actions.error]
- )
- ;
-
- xinclude =
- "xinclude"
- >> hard_space
- >> (*(anychar_p -
- phrase_end)) [actions.xinclude]
- ;
-
- import =
- "import"
- >> hard_space
- >> (*(anychar_p -
- phrase_end)) [actions.import]
- ;
-
- include =
- "include"
- >> hard_space
- >>
- !(
- ':'
- >> (*((alnum_p | '_') - space_p))[assign_a(actions.include_doc_id)]
- >> space
- )
- >> (*(anychar_p -
- phrase_end)) [actions.include]
- ;
-
- code =
- (
- code_line
- >> *(*blank_line >> code_line)
- ) [actions.code]
- >> *eol
- ;
-
- code_line =
- blank_p >> *(anychar_p - eol_p) >> eol_p
- ;
-
- blank_line =
- *blank_p >> eol_p
- ;
-
- list =
- eps_p(ch_p('*') | '#') >>
- +(
- (*blank_p
- >> (ch_p('*') | '#')) [actions.list_format]
- >> *blank_p
- >> list_item
- ) [actions.list_item]
- ;
-
- list_item =
- *( common
- | (anychar_p -
- ( eol_p >> *blank_p >> eps_p(ch_p('*') | '#')
- | (eol >> eol)
- )
- ) [actions.plain_char]
- )
- >> +eol
- ;
-
- paragraph_end_markups =
- "section", "endsect", "h1", "h2", "h3", "h4", "h5", "h6",
- "blurb", ":", "pre", "def", "table", "include", "xinclude",
- "variablelist", "import", "template", "warning", "caution",
- "important", "note", "tip", ":"
- ;
-
- paragraph_end =
- '[' >> space >> paragraph_end_markups >> hard_space | eol >> *blank_p >> eol_p
- ;
-
- paragraph =
- +( common
- | (anychar_p - // Make sure we don't go past
- paragraph_end // a single block.
- ) [actions.plain_char]
- )
- >> (eps_p('[') | +eol)
- ;
-
- phrase =
- *( common
- | comment
- | (anychar_p -
- phrase_end) [actions.plain_char]
- )
- ;
- }
-
- bool no_eols;
-
- rule<Scanner> start_, blocks, block_markup, code, code_line, blank_line,
- paragraph, space, blank, comment, headings, h, h1, h2,
- h3, h4, h5, h6, hr, blurb, blockquote, admonition,
- phrase, list, phrase_end, ordered_list, def_macro,
- macro_identifier, table, table_row, variablelist,
- varlistentry, varlistterm, varlistitem, table_cell,
- preformatted, list_item, begin_section, end_section,
- xinclude, include, hard_space, eol, paragraph_end,
- template_, template_id, template_formal_arg,
- template_body, identifier, dummy_block, import,
- inside_paragraph,
- element_id, element_id_1_5, element_id_1_6;
-
- symbols<> paragraph_end_markups;
-
- phrase_grammar common;
-
- rule<Scanner> const&
- start() const { return start_; }
- };
-
- quickbook::actions& actions;
- bool const skip_initial_spaces;
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP

Deleted: trunk/tools/quickbook/code_snippet.hpp
==============================================================================
--- trunk/tools/quickbook/code_snippet.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,238 +0,0 @@
-/*=============================================================================
- Copyright (c) 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_CODE_SNIPPET_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_HPP
-
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_actor.hpp>
-#include <boost/bind.hpp>
-#include "./detail/template_stack.hpp"
-#include "./detail/actions.hpp"
-
-namespace quickbook
-{
- struct code_snippet_actions
- {
- code_snippet_actions(std::vector<template_symbol>& storage,
- std::string const& doc_id,
- char const* source_type)
- : callout_id(0)
- , storage(storage)
- , doc_id(doc_id)
- , source_type(source_type)
- {}
-
- void pass_thru_char(char);
- void pass_thru(iterator first, iterator last);
- void escaped_comment(iterator first, iterator last);
- void start_snippet(iterator first, iterator last);
- void end_snippet(iterator first, iterator last);
- void callout(iterator first, iterator last);
-
- void append_code();
- void close_code();
-
- struct snippet_data
- {
- snippet_data(std::string const& id, int callout_base_id)
- : id(id)
- , callout_base_id(callout_base_id)
- , content()
- , start_code(false)
- , end_code(false)
- {}
-
- std::string id;
- int callout_base_id;
- std::string content;
- bool start_code;
- bool end_code;
- std::vector<template_body> callouts;
- };
-
- int callout_id;
- std::stack<snippet_data> snippet_stack;
- std::string code;
- std::string id;
- std::vector<template_symbol>& storage;
- std::string const doc_id;
- char const* const source_type;
- };
-
- struct python_code_snippet_grammar
- : grammar<python_code_snippet_grammar>
- {
- typedef code_snippet_actions actions_type;
-
- python_code_snippet_grammar(actions_type & actions)
- : actions(actions)
- {}
-
- template <typename Scanner>
- struct definition
- {
- typedef code_snippet_actions actions_type;
-
- definition(python_code_snippet_grammar const& self)
- {
-
- actions_type& actions = self.actions;
-
- start_ = *code_elements;
-
- identifier =
- (alpha_p | '_') >> *(alnum_p | '_')
- ;
-
- code_elements =
- start_snippet [boost::bind(&actions_type::start_snippet, &actions, _1, _2)]
- | end_snippet [boost::bind(&actions_type::end_snippet, &actions, _1, _2)]
- | escaped_comment
- | ignore
- | anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)]
- ;
-
- start_snippet =
- "#[" >> *space_p
- >> identifier [assign_a(actions.id)]
- ;
-
- end_snippet =
- str_p("#]")
- ;
-
- ignore =
- *blank_p >> "#<-"
- >> (*(anychar_p - "#->"))
- >> "#->" >> *blank_p >> eol_p
- | "\"\"\"<-\"\"\""
- >> (*(anychar_p - "\"\"\"->\"\"\""))
- >> "\"\"\"->\"\"\""
- | "\"\"\"<-"
- >> (*(anychar_p - "->\"\"\""))
- >> "->\"\"\""
- ;
-
- escaped_comment =
- *space_p >> "#`"
- >> ((*(anychar_p - eol_p))
- >> eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- | *space_p >> "\"\"\"`"
- >> (*(anychar_p - "\"\"\"")) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- >> "\"\"\""
- ;
- }
-
- rule<Scanner>
- start_, identifier, code_elements, start_snippet, end_snippet,
- escaped_comment, ignore;
-
- rule<Scanner> const&
- start() const { return start_; }
- };
-
- actions_type& actions;
- };
-
- struct cpp_code_snippet_grammar
- : grammar<cpp_code_snippet_grammar>
- {
- typedef code_snippet_actions actions_type;
-
- cpp_code_snippet_grammar(actions_type & actions)
- : actions(actions)
- {}
-
- template <typename Scanner>
- struct definition
- {
- definition(cpp_code_snippet_grammar const& self)
- {
- actions_type& actions = self.actions;
-
- start_ = *code_elements;
-
- identifier =
- (alpha_p | '_') >> *(alnum_p | '_')
- ;
-
- code_elements =
- start_snippet [boost::bind(&actions_type::start_snippet, &actions, _1, _2)]
- | end_snippet [boost::bind(&actions_type::end_snippet, &actions, _1, _2)]
- | escaped_comment
- | ignore
- | line_callout
- | inline_callout
- | anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)]
- ;
-
- start_snippet =
- "//[" >> *space_p
- >> identifier [assign_a(actions.id)]
- |
- "/*[" >> *space_p
- >> identifier [assign_a(actions.id)]
- >> *space_p >> "*/"
- ;
-
- end_snippet =
- str_p("//]") | "/*]*/"
- ;
-
- inline_callout =
- "/*<"
- >> *space_p
- >> (*(anychar_p - ">*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)]
- >> ">*/"
- ;
-
- line_callout =
- "/*<<"
- >> *space_p
- >> (*(anychar_p - ">>*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)]
- >> ">>*/"
- >> *space_p
- ;
-
- ignore =
- *blank_p >> "//<-"
- >> (*(anychar_p - "//->"))
- >> "//->" >> *blank_p >> eol_p
- | "/*<-*/"
- >> (*(anychar_p - "/*->*/"))
- >> "/*->*/"
- | "/*<-"
- >> (*(anychar_p - "->*/"))
- >> "->*/"
- ;
-
- escaped_comment =
- *space_p >> "//`"
- >> ((*(anychar_p - eol_p))
- >> eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- | *space_p >> "/*`"
- >> (*(anychar_p - "*/")) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- >> "*/"
- ;
- }
-
- rule<Scanner>
- start_, identifier, code_elements, start_snippet, end_snippet,
- escaped_comment, inline_callout, line_callout, ignore;
-
- rule<Scanner> const&
- start() const { return start_; }
- };
-
- actions_type& actions;
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_HPP
-

Deleted: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,1839 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2005 Thomas Guest
- http://spirit.sourceforge.net/
-
- 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 <sstream>
-#include <numeric>
-#include <functional>
-#include <algorithm>
-#include <boost/bind.hpp>
-#include <boost/filesystem/v2/convenience.hpp>
-#include <boost/filesystem/v2/fstream.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/algorithm/string/join.hpp>
-#include "./quickbook.hpp"
-#include "./actions.hpp"
-#include "./utils.hpp"
-#include "./markups.hpp"
-#include "./actions_class.hpp"
-#include "../block.hpp"
-#include "../phrase.hpp"
-#include "../code_snippet.hpp"
-
-namespace quickbook
-{
- char const* quickbook_get_date = "__quickbook_get_date__";
- char const* quickbook_get_time = "__quickbook_get_time__";
-
- namespace {
- std::string fully_qualified_id(std::string const& library_id,
- std::string const& qualified_section_id,
- std::string const& section_id)
- {
- std::string id = library_id;
- if(!id.empty() && !qualified_section_id.empty()) id += '.';
- id += qualified_section_id;
- if(!id.empty() && !section_id.empty()) id += '.';
- id += section_id;
- return id;
- }
- }
-
- // Handles line-breaks (DEPRECATED!!!)
- void break_action::operator()(iterator first, iterator) const
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outwarn(pos.file,pos.line) << "in column:" << pos.column << ", "
- << "[br] and \\n are deprecated" << ".\n";
- phrase << break_mark;
- }
-
- void error_action::operator()(iterator first, iterator /*last*/) const
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Syntax Error near column " << pos.column << ".\n";
- ++error_count;
- }
-
- void phrase_action::operator()(iterator first, iterator last) const
- {
- std::string str;
- phrase.swap(str);
- out << pre << str << post;
- }
-
- void implicit_paragraph_action::operator()() const
- {
- std::string str;
- phrase.swap(str);
-
- // TODO: Use spirit to do this?
-
- std::string::const_iterator
- pos = str.begin(),
- end = str.end();
-
- while(pos != end && (
- *pos == ' ' || *pos == '\t' || *pos == '\n' || *pos == '\r'))
- {
- ++pos;
- }
-
- if(pos != end) {
- out << pre << str << post;
- }
- }
-
- void header_action::operator()(iterator first, iterator last) const
- {
- std::string str;
- phrase.swap(str);
-
- if (qbk_version_n < 103) // version 1.2 and below
- {
- out << "<anchor id=\""
- << section_id << '.'
- << detail::make_identifier(str.begin(), str.end())
- << "\" />"
- << pre << str << post
- ;
- }
- else // version 1.3 and above
- {
- std::string id =
- !element_id.empty() ? element_id :
- qbk_version_n >= 106 ? detail::make_identifier(first, last) :
- detail::make_identifier(str.begin(), str.end());
-
- std::string anchor =
- fully_qualified_id(library_id, qualified_section_id, id);
-
- out << "<anchor id=\"" << anchor << "\"/>"
- << pre
- << "<link linkend=\"" << anchor << "\">"
- << str
- << "</link>"
- << post
- ;
- }
- }
-
- void generic_header_action::operator()(iterator first, iterator last) const
- {
- int level_ = section_level + 2; // section_level is zero-based. We need to use a
- // 0ne-based heading which is one greater
- // than the current. Thus: section_level + 2.
- if (level_ > 6) // The max is h6, clip it if it goes
- level_ = 6; // further than that
- std::string str;
- phrase.swap(str);
-
- std::string id =
- !element_id.empty() ? element_id :
- qbk_version_n >= 106 ? detail::make_identifier(first, last) :
- detail::make_identifier(str.begin(), str.end());
-
- std::string anchor =
- fully_qualified_id(library_id, qualified_section_id, id);
-
- out
- << "<anchor id=\"" << anchor << "\"/>"
- << "<bridgehead renderas=\"sect" << level_ << "\">"
- << "<link linkend=\"" << anchor << "\">"
- << str
- << "</link>"
- << "</bridgehead>"
- ;
- }
-
- void simple_phrase_action::operator()(iterator first, iterator last) const
- {
- out << pre;
- std::string str(first, last);
- if (std::string const* ptr = find(macro, str.c_str()))
- {
- out << *ptr;
- }
- else
- {
- while (first != last)
- detail::print_char(*first++, out.get());
- }
- out << post;
- }
-
- void cond_phrase_action_pre::operator()(iterator first, iterator last) const
- {
- std::string str(first, last);
- conditions.push_back(find(macro, str.c_str()));
- out.push(); // save the stream
- }
-
- void cond_phrase_action_post::operator()(iterator first, iterator last) const
- {
- bool symbol_found = conditions.back();
- conditions.pop_back();
-
- if (first == last || !symbol_found)
- {
- out.pop(); // restore the stream
- }
- else
- {
- std::string save;
- out.swap(save);
- out.pop(); // restore the stream
- out << save; // print the body
- }
- }
-
- void list_action::operator()(iterator first, iterator last) const
- {
- BOOST_ASSERT(!list_marks.empty()); // there must be at least one item in the stack
- out << list_buffer.str();
- list_buffer.clear();
-
- while (!list_marks.empty())
- {
- char mark = list_marks.top().first;
- list_marks.pop();
- out << std::string((mark == '#') ? "\n</orderedlist>" : "\n</itemizedlist>");
- if (list_marks.size() >= 1)
- out << "</listitem>";
- }
-
- list_indent = -1; // reset
- }
-
- void list_format_action::operator()(iterator first, iterator last) const
- {
- int new_indent = 0;
- while (first != last && (*first == ' ' || *first == '\t'))
- {
- char mark = *first++;
- if (mark == ' ')
- {
- ++new_indent;
- }
- else // must be a tab
- {
- BOOST_ASSERT(mark == '\t');
- // hardcoded tab to 4 for now
- new_indent = ((new_indent + 4) / 4) * 4;
- }
- }
-
- char mark = *first;
- BOOST_ASSERT(mark == '#' || mark == '*'); // expecting a mark
-
- if (list_indent == -1) // the very start
- {
- BOOST_ASSERT(new_indent == 0);
- }
-
- if (new_indent > list_indent)
- {
- list_indent = new_indent;
- list_marks.push(mark_type(mark, list_indent));
- if (list_marks.size() > 1)
- {
- // Make this new list a child of the previous list.
- // The previous listelem has already ended so we erase
- // "</listitem>" to accomodate this sub-list. We'll close
- // the listelem later.
-
- std::string str;
- out.swap(str);
- std::string::size_type pos = str.rfind("</listitem>");
- BOOST_ASSERT(pos <= str.size());
- str.erase(str.begin()+pos, str.end());
- out << str;
- }
- out << std::string((mark == '#') ? "<orderedlist>\n" : "<itemizedlist>\n");
- }
-
- else if (new_indent < list_indent)
- {
- BOOST_ASSERT(!list_marks.empty());
- list_indent = new_indent;
-
- while (!list_marks.empty() && (list_indent < list_marks.top().second))
- {
- char mark = list_marks.top().first;
- list_marks.pop();
- out << std::string((mark == '#') ? "\n</orderedlist>" : "\n</itemizedlist>");
- if (list_marks.size() >= 1)
- out << "</listitem>";
- }
- }
-
- if (mark != list_marks.top().first) // new_indent == list_indent
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Illegal change of list style near column " << pos.column << ".\n";
- detail::outwarn(pos.file,pos.line)
- << "Ignoring change of list style" << std::endl;
- ++error_count;
- }
- }
-
- void span::operator()(iterator first, iterator last) const
- {
- out << "<phrase role=\"" << name << "\">";
- while (first != last)
- detail::print_char(*first++, out.get());
- out << "</phrase>";
- }
-
- void unexpected_char::operator()(iterator first, iterator last) const
- {
- boost::spirit::classic::file_position const pos = first.get_position();
-
- detail::outwarn(pos.file, pos.line)
- << "in column:" << pos.column
- << ", unexpected character: " << std::string(first, last)
- << "\n";
-
- // print out an unexpected character
- out << "<phrase role=\"error\">";
- while (first != last)
- detail::print_char(*first++, out.get());
- out << "</phrase>";
- }
-
- void anchor_action::operator()(iterator first, iterator last) const
- {
- out << "<anchor id=\"";
- while (first != last)
- detail::print_char(*first++, out.get());
- out << "\" />\n";
- }
-
- void do_macro_action::operator()(std::string const& str) const
- {
- if (str == quickbook_get_date)
- {
- char strdate[64];
- strftime(strdate, sizeof(strdate), "%Y-%b-%d", current_time);
- phrase << strdate;
- }
- else if (str == quickbook_get_time)
- {
- char strdate[64];
- strftime(strdate, sizeof(strdate), "%I:%M:%S %p", current_time);
- phrase << strdate;
- }
- else
- {
- phrase << str;
- }
- }
-
- void space::operator()(char ch) const
- {
-
- detail::print_space(ch, out.get());
- }
-
- void space::operator()(iterator first, iterator last) const
- {
- while (first != last)
- detail::print_space(*first++, out.get());
- }
-
- void pre_escape_back::operator()(iterator first, iterator last) const
- {
- escape_actions.phrase.push(); // save the stream
- }
-
- void post_escape_back::operator()(iterator first, iterator last) const
- {
- out << escape_actions.phrase.str();
- escape_actions.phrase.pop(); // restore the stream
- }
-
- void code_action::operator()(iterator first, iterator last) const
- {
- // preprocess the code section to remove the initial indentation
- std::string program(first, last);
- detail::unindent(program);
- if (program.size() == 0)
- return; // Nothing left to do here. The program is empty.
-
- iterator first_(program.begin(), program.end());
- iterator last_(program.end(), program.end());
- first_.set_position(first.get_position());
-
- std::string save;
- phrase.swap(save);
-
- // print the code with syntax coloring
- std::string str = syntax_p(first_, last_);
-
- phrase.swap(save);
-
- //
- // We must not place a \n after the <programlisting> tag
- // otherwise PDF output starts code blocks with a blank line:
- //
- out << "<programlisting>";
- out << str;
- out << "</programlisting>\n";
- }
-
- void inline_code_action::operator()(iterator first, iterator last) const
- {
- std::string save;
- out.swap(save);
-
- // print the code with syntax coloring
- std::string str = syntax_p(first, last);
-
- out.swap(save);
-
- out << "<code>";
- out << str;
- out << "</code>";
- }
-
- void raw_char_action::operator()(char ch) const
- {
- phrase << ch;
- }
-
- void raw_char_action::operator()(iterator first, iterator /*last*/) const
- {
- phrase << *first;
- }
-
- void plain_char_action::operator()(char ch) const
- {
- detail::print_char(ch, phrase.get());
- }
-
- void plain_char_action::operator()(iterator first, iterator /*last*/) const
- {
- detail::print_char(*first, phrase.get());
- }
-
- void escape_unicode_action::operator()(iterator first, iterator last) const
- {
- while(first != last && *first == '0') ++first;
-
- // Just ignore \u0000
- // Maybe I should issue a warning?
- if(first == last) return;
-
- std::string hex_digits(first, last);
-
- if(hex_digits.size() == 2 && *first > '0' && *first <= '7') {
- using namespace std;
- detail::print_char(strtol(hex_digits.c_str(), 0, 16), phrase.get());
- }
- else {
- phrase << "&#x" << hex_digits << ";";
- }
- }
-
- void attribute_action::operator()(iterator first, iterator last) const
- {
- boost::spirit::classic::file_position const pos = first.get_position();
-
- if (!attributes.insert(
- attribute_map::value_type(attribute_name, std::string(first, last))
- ).second)
- {
- detail::outwarn(pos.file,pos.line)
- << "Repeated attribute: " << attribute_name << ".\n";
- }
- }
-
- void image_action::operator()(iterator, iterator) const
- {
- fs::path const img_path(image_fileref);
-
- attribute_map::iterator it = attributes.find("alt");
- std::string alt_text = it != attributes.end() ? it->second : img_path.stem();
- attributes.erase("alt");
-
- attributes.insert(attribute_map::value_type("fileref", image_fileref));
-
- if(img_path.extension() == ".svg")
- {
- //
- // SVG's need special handling:
- //
- // 1) We must set the "format" attribute, otherwise
- // HTML generation produces code that will not display
- // the image at all.
- // 2) We need to set the "contentwidth" and "contentdepth"
- // attributes, otherwise the image will be displayed inside
- // a tiny box with scrollbars (Firefox), or else cropped to
- // fit in a tiny box (IE7).
- //
- attributes.insert(attribute_map::value_type("format", "SVG"));
- //
- // Image paths are relative to the html subdirectory:
- //
- fs::path img;
- if(img_path.root_path().empty())
- img = "html" / img_path; // relative path
- else
- img = img_path; // absolute path
- //
- // Now load the SVG file:
- //
- std::string svg_text;
- fs::ifstream fs(img);
- char c;
- while(fs.get(c) && fs.good())
- svg_text.push_back(c);
- //
- // Extract the svg header from the file:
- //
- std::string::size_type a, b;
- a = svg_text.find("<svg");
- b = svg_text.find('>', a);
- svg_text = (a == std::string::npos) ? "" : svg_text.substr(a, b - a);
- //
- // Now locate the "width" and "height" attributes
- // and borrow their values:
- //
- a = svg_text.find("width");
- a = svg_text.find('=', a);
- a = svg_text.find('\"', a);
- b = svg_text.find('\"', a + 1);
- if(a != std::string::npos)
- {
- attributes.insert(attribute_map::value_type("contentwidth",
- std::string(svg_text.begin() + a + 1, svg_text.begin() + b)));
- }
- a = svg_text.find("height");
- a = svg_text.find('=', a);
- a = svg_text.find('\"', a);
- b = svg_text.find('\"', a + 1);
- if(a != std::string::npos)
- {
- attributes.insert(attribute_map::value_type("contentdepth",
- std::string(svg_text.begin() + a + 1, svg_text.begin() + b)));
- }
- }
-
- phrase << "<inlinemediaobject>";
-
- phrase << "<imageobject><imagedata";
-
- for(attribute_map::const_iterator
- attr_first = attributes.begin(), attr_last = attributes.end();
- attr_first != attr_last; ++attr_first)
- {
- phrase << " " << attr_first->first << "=\"";
-
- for(std::string::const_iterator
- first = attr_first->second.begin(),
- last = attr_first->second.end();
- first != last; ++first)
- {
- if (*first == '\\' && ++first == last) break;
- detail::print_char(*first, phrase.get());
- }
-
- phrase << "\"";
- }
-
- phrase << "></imagedata></imageobject>";
-
- // Also add a textobject -- use the basename of the image file.
- // This will mean we get "alt" attributes of the HTML img.
- phrase << "<textobject><phrase>";
- detail::print_string(alt_text, phrase.get());
- phrase << "</phrase></textobject>";
-
- phrase << "</inlinemediaobject>";
- }
-
- void macro_identifier_action::operator()(iterator first, iterator last) const
- {
- actions.macro_id.assign(first, last);
- actions.phrase.push(); // save the phrase
- }
-
- void macro_definition_action::operator()(iterator first, iterator last) const
- {
- actions.macro.add(
- actions.macro_id.begin()
- , actions.macro_id.end()
- , actions.phrase.str());
- actions.phrase.pop(); // restore the phrase
- }
-
- void template_body_action::operator()(iterator first, iterator last) const
- {
- if (!actions.templates.add(
- template_symbol(actions.template_identifier, actions.template_info,
- std::string(first, last), first.get_position(),
- actions.template_block, &actions.templates.top_scope())))
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Template Redefinition: " << actions.template_identifier << std::endl;
- ++actions.error_count;
- }
-
- actions.template_identifier.clear();
- actions.template_info.clear();
- }
-
- namespace
- {
- iterator find_bracket_end(iterator begin, iterator const& end)
- {
- unsigned int depth = 1;
-
- while(depth > 0) {
- char const* search_chars = "[]\\";
- begin = std::find_first_of(begin, end, search_chars, search_chars + 3);
- if(begin == end) return begin;
-
- if(*begin == '\\')
- {
- if(++begin == end) return begin;
- ++begin;
- }
- else
- {
- depth += (*begin == '[') ? 1 : -1;
- ++begin;
- }
- }
-
- return begin;
- }
-
- iterator find_first_seperator(iterator const& begin, iterator const& end)
- {
- if(qbk_version_n < 105) {
- char const* whitespace = " \t\r\n";
- return std::find_first_of(begin, end, whitespace, whitespace + 4);
- }
- else {
- iterator pos = begin;
-
- while(true)
- {
- char const* search_chars = " \t\r\n\\[";
- pos = std::find_first_of(pos, end, search_chars, search_chars + 6);
- if(pos == end) return pos;
-
- switch(*pos)
- {
- case '[':
- pos = find_bracket_end(++pos, end);
- break;
- case '\\':
- if(++pos == end) return pos;
- ++pos;
- break;
- default:
- return pos;
- }
- }
- }
- }
-
- bool break_arguments(
- std::vector<template_body>& args
- , std::vector<std::string> const& params
- , boost::spirit::classic::file_position const& pos
- )
- {
- // Quickbook 1.4-: If there aren't enough parameters seperated by
- // '..' then seperate the last parameter using
- // whitespace.
- // Quickbook 1.5+: If '..' isn't used to seperate the parameters
- // then use whitespace to separate them
- // (2 = template name + argument).
-
- if (qbk_version_n < 105 || args.size() == 1)
- {
-
- while (args.size() < params.size())
- {
- // Try to break the last argument at the first space found
- // and push it into the back of args. Do this
- // recursively until we have all the expected number of
- // arguments, or if there are no more spaces left.
-
- template_body& body = args.back();
- iterator begin(body.content.begin(), body.content.end(), body.position.file);
- iterator end(body.content.end(), body.content.end());
-
- iterator l_pos = find_first_seperator(begin, end);
- if (l_pos == end)
- break;
- char const* whitespace = " \t\r\n";
- char const* whitespace_end = whitespace + 4;
- iterator r_pos = l_pos;
- while(r_pos != end && std::find(whitespace, whitespace_end, *r_pos) != whitespace_end) ++r_pos;
- if (r_pos == end)
- break;
- template_body second(std::string(r_pos, end), begin.get_position(), false);
- body.content = std::string(begin, l_pos);
- args.push_back(second);
- }
- }
-
- if (args.size() != params.size())
- {
- detail::outerr(pos.file, pos.line)
- << "Invalid number of arguments passed. Expecting: "
- << params.size()
- << " argument(s), got: "
- << args.size()
- << " argument(s) instead."
- << std::endl;
- return false;
- }
- return true;
- }
-
- std::pair<bool, std::vector<std::string>::const_iterator>
- get_arguments(
- std::vector<template_body>& args
- , std::vector<std::string> const& params
- , template_scope const& scope
- , boost::spirit::classic::file_position const& pos
- , quickbook::actions& actions
- )
- {
- std::vector<template_body>::const_iterator arg = args.begin();
- std::vector<std::string>::const_iterator tpl = params.begin();
- std::vector<std::string> empty_params;
-
-
- // Store each of the argument passed in as local templates:
- while (arg != args.end())
- {
- if (!actions.templates.add(
- template_symbol(*tpl, empty_params, arg->content,
- arg->position, arg->is_block, &scope)))
- {
- detail::outerr(pos.file,pos.line)
- << "Duplicate Symbol Found" << std::endl;
- ++actions.error_count;
- return std::make_pair(false, tpl);
- }
- ++arg; ++tpl;
- }
- return std::make_pair(true, tpl);
- }
-
- bool parse_template(
- template_body const& body
- , bool escape
- , std::string& result
- , quickbook::actions& actions
- )
- {
- // How do we know if we are to parse the template as a block or
- // a phrase? We apply a simple heuristic: if the body starts with
- // a newline, then we regard it as a block, otherwise, we parse
- // it as a phrase.
- //
- // Note: this is now done in the grammar.
-
- if (escape)
- {
- // escape the body of the template
- // we just copy out the literal body
- result = body.content;
- return true;
- }
- else if (!body.is_block)
- {
- simple_phrase_grammar phrase_p(actions);
-
- // do a phrase level parse
- iterator first(body.content.begin(), body.content.end(), body.position);
- iterator last(body.content.end(), body.content.end());
- bool r = boost::spirit::classic::parse(first, last, phrase_p).full;
- actions.phrase.swap(result);
- return r;
- }
- else
- {
- block_grammar block_p(actions, true);
-
- // do a block level parse
- // ensure that we have enough trailing newlines to eliminate
- // the need to check for end of file in the grammar.
-
- std::string content = body.content + "\n\n";
- iterator first(content.begin(), content.end(), body.position);
- iterator last(content.end(), content.end());
- bool r = boost::spirit::classic::parse(first, last, block_p).full;
- actions.inside_paragraph();
- actions.out.swap(result);
- return r;
- }
- }
- }
-
- namespace detail
- {
- int callout_id = 0;
- }
-
- void template_arg_action::operator()(iterator first, iterator last) const
- {
- actions.template_args.push_back(
- template_body(
- std::string(first, last),
- first.get_position(),
- actions.template_block));
- }
-
- void do_template_action::operator()(iterator first, iterator) const
- {
- // Get the arguments and clear values stored in action.
-
- std::vector<template_body> args;
- std::string identifier;
- std::swap(args, actions.template_args);
- std::swap(identifier, actions.template_identifier);
- boost::spirit::classic::file_position const pos = first.get_position();
-
- ++actions.template_depth;
- if (actions.template_depth > actions.max_template_depth)
- {
- detail::outerr(pos.file,pos.line)
- << "Infinite loop detected" << std::endl;
- --actions.template_depth;
- ++actions.error_count;
- return;
- }
-
- // The template arguments should have the scope that the template was
- // called from, not the template's own scope.
- //
- // Note that for quickbook 1.4- this value is just ignored when the
- // arguments are expanded.
- template_scope const& call_scope = actions.templates.top_scope();
-
- template_symbol const* symbol = actions.templates.find(identifier);
- BOOST_ASSERT(symbol);
-
- std::string result;
- actions.push(); // scope the actions' states
- {
- // Store the current section level so that we can ensure that
- // [section] and [endsect] tags in the template are balanced.
- actions.min_section_level = actions.section_level;
-
- // Quickbook 1.4-: When expanding the tempalte continue to use the
- // current scope (the dynamic scope).
- // Quickbook 1.5+: Use the scope the template was defined in
- // (the static scope).
- if (qbk_version_n >= 105)
- actions.templates.set_parent_scope(*symbol->parent);
-
- ///////////////////////////////////
- // Initialise the arguments
-
- if (!symbol->callout)
- {
- // Break the arguments for a template
-
- if (!break_arguments(args, symbol->params, pos))
- {
- actions.pop(); // restore the actions' states
- --actions.template_depth;
- ++actions.error_count;
- return;
- }
- }
- else
- {
- if (!args.empty())
- {
- detail::outerr(pos.file, pos.line)
- << "Arguments for code snippet."
- <<std::endl;
- ++actions.error_count;
-
- args.clear();
- }
-
- unsigned int size = symbol->params.size();
-
- for(unsigned int i = 0; i < size; ++i)
- {
- std::string callout_id = actions.doc_id +
- boost::lexical_cast<std::string>(detail::callout_id + i);
-
- std::string code;
- code += "'''";
- code += "<co id=\"" + callout_id + "co\" ";
- code += "linkends=\"" + callout_id + "\" />";
- code += "'''";
-
- args.push_back(template_body(code, first.get_position(), false));
- }
- }
-
- ///////////////////////////////////
- // Prepare the arguments as local templates
- bool get_arg_result;
- std::vector<std::string>::const_iterator tpl;
- boost::tie(get_arg_result, tpl) =
- get_arguments(args, symbol->params,
- call_scope, pos, actions);
-
- if (!get_arg_result)
- {
- actions.pop(); // restore the actions' states
- --actions.template_depth;
- return;
- }
-
- ///////////////////////////////////
- // parse the template body:
-
- if (!parse_template(symbol->body, actions.template_escape, result, actions))
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Expanding "
- << (symbol->body.is_block ? "block" : "phrase")
- << " template: " << symbol->identifier << std::endl
- << std::endl
- << "------------------begin------------------" << std::endl
- << symbol->body.content
- << "------------------end--------------------" << std::endl
- << std::endl;
- actions.pop(); // restore the actions' states
- --actions.template_depth;
- ++actions.error_count;
- return;
- }
-
- if (actions.section_level != actions.min_section_level)
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Mismatched sections in template " << identifier << std::endl;
- actions.pop(); // restore the actions' states
- --actions.template_depth;
- ++actions.error_count;
- return;
- }
- }
-
- actions.pop(); // restore the actions' states
-
- if(symbol->callout && symbol->callouts.size() > 0)
- {
- result += "<calloutlist>";
- BOOST_FOREACH(template_body const& c, symbol->callouts)
- {
- std::string callout_id = actions.doc_id +
- boost::lexical_cast<std::string>(detail::callout_id++);
-
- std::string callout_value;
- actions.push();
- bool r = parse_template(c, false, callout_value, actions);
- actions.pop();
-
- if(!r)
- {
- detail::outerr(c.position.file, c.position.line)
- << "Expanding callout." << std::endl;
- ++actions.error_count;
- return;
- }
-
- result += "<callout arearefs=\"" + callout_id + "co\" ";
- result += "id=\"" + callout_id + "\">";
- result += callout_value;
- result += "</callout>";
- }
- result += "</calloutlist>";
- }
-
- if(symbol->body.is_block) {
- actions.inside_paragraph();
- actions.temp_para << result; // print it!!!
- }
- else {
- actions.phrase << result; // print it!!!
- }
- --actions.template_depth;
- }
-
- void link_action::operator()(iterator first, iterator last) const
- {
- iterator save = first;
- phrase << tag;
- while (first != last)
- detail::print_char(*first++, phrase.get());
- phrase << "\">";
-
- // Yes, it is safe to dereference last here. When we
- // reach here, *last is certainly valid. We test if
- // *last == ']'. In which case, the url is the text.
- // Example: [@http://spirit.sourceforge.net/]
-
- if (*last == ']')
- {
- first = save;
- while (first != last)
- detail::print_char(*first++, phrase.get());
- }
- }
-
- void variablelist_action::operator()(iterator, iterator) const
- {
- actions.out << "<variablelist>\n";
-
- actions.out << "<title>";
- std::string::iterator first = actions.table_title.begin();
- std::string::iterator last = actions.table_title.end();
- while (first != last)
- detail::print_char(*first++, actions.out.get());
- actions.out << "</title>\n";
-
- std::string str;
- actions.phrase.swap(str);
- actions.out << str;
-
- actions.out << "</variablelist>\n";
- actions.table_span = 0;
- actions.table_header.clear();
- actions.table_title.clear();
- }
-
- void start_varlistitem_action::operator()() const
- {
- phrase << start_varlistitem_;
- phrase.push();
- }
-
- void end_varlistitem_action::operator()() const
- {
- std::string str;
- temp_para.swap(str);
- phrase.pop();
- phrase << str << end_varlistitem_;
- }
-
- void table_action::operator()(iterator, iterator) const
- {
- std::string::iterator first = actions.table_title.begin();
- std::string::iterator last = actions.table_title.end();
- bool has_title = first != last;
-
- std::string table_id;
- if(qbk_version_n >= 105) {
- if(!actions.element_id.empty()) {
- table_id = fully_qualified_id(actions.doc_id,
- actions.qualified_section_id, actions.element_id);
- }
- else if(has_title) {
- table_id = fully_qualified_id(actions.doc_id,
- actions.qualified_section_id,
- detail::make_identifier(first, last));
- }
- }
-
- if (has_title)
- {
- actions.out << "<table frame=\"all\"";
- if(!table_id.empty())
- actions.out << " id=\"" << table_id << "\"";
- actions.out << ">\n";
- actions.out << "<title>";
- while (first != last)
- detail::print_char(*first++, actions.out.get());
- actions.out << "</title>";
- }
- else
- {
- actions.out << "<informaltable frame=\"all\"";
- if(!table_id.empty())
- actions.out << " id=\"" << table_id << "\"";
- actions.out << ">\n";
- }
-
- actions.out << "<tgroup cols=\"" << actions.table_span << "\">\n";
-
- if (!actions.table_header.empty())
- {
- actions.out << "<thead>" << actions.table_header << "</thead>\n";
- }
-
- actions.out << "<tbody>\n";
-
- std::string str;
- actions.phrase.swap(str);
- actions.out << str;
-
- actions.out << "</tbody>\n"
- << "</tgroup>\n";
-
- if (has_title)
- {
- actions.out << "</table>\n";
- }
- else
- {
- actions.out << "</informaltable>\n";
- }
-
- actions.table_span = 0;
- actions.table_header.clear();
- actions.table_title.clear();
- }
-
- void start_row_action::operator()(char) const
- {
- // the first row is the header
- if (header.empty() && !phrase.str().empty())
- {
- phrase.swap(header);
- }
-
- phrase << start_row_;
- span = 0;
- }
-
- void start_row_action::operator()(iterator f, iterator) const
- {
- (*this)(*f);
- }
-
- void start_col_action::operator()(char) const
- {
- phrase << start_cell_;
- phrase.push();
- ++span;
- }
-
- void end_col_action::operator()(char) const
- {
- std::string str;
- temp_para.swap(str);
- phrase.pop();
- phrase << str << end_cell_;
- }
-
- void begin_section_action::operator()(iterator first, iterator last) const
- {
- section_id = element_id.empty() ?
- detail::make_identifier(first, last) :
- element_id;
-
- if (section_level != 0)
- qualified_section_id += '.';
- else
- BOOST_ASSERT(qualified_section_id.empty());
- qualified_section_id += section_id;
- ++section_level;
-
- if (qbk_version_n < 103) // version 1.2 and below
- {
- out << "\n<section id=\""
- << library_id << "." << section_id << "\">\n";
- }
- else // version 1.3 and above
- {
- out << "\n<section id=\"" << library_id
- << "." << qualified_section_id << "\">\n";
- }
- std::string str;
- phrase.swap(str);
-
- if (qbk_version_n < 103) // version 1.2 and below
- {
- out << "<title>" << str << "</title>\n";
- }
- else // version 1.3 and above
- {
- out << "<title>"
- << "<link linkend=\"" << library_id
- << "." << qualified_section_id << "\">"
- << str
- << "</link>"
- << "</title>\n"
- ;
- }
- }
-
- void end_section_action::operator()(iterator first, iterator last) const
- {
- if (section_level <= min_section_level)
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Mismatched [endsect] near column " << pos.column << ".\n";
- ++error_count;
-
- return;
- }
-
- --section_level;
- out << "</section>";
-
- if (section_level == 0)
- {
- 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);
- }
- }
-
- void element_id_warning_action::operator()(iterator first, iterator) const
- {
- boost::spirit::classic::file_position const pos = first.get_position();
- detail::outwarn(pos.file,pos.line) << "Empty id.\n";
- }
-
- fs::path path_difference(fs::path const& outdir, fs::path const& path)
- {
- fs::path outtmp, temp;
- fs::path::iterator out = outdir.begin(), file = path.begin();
- for(; out != outdir.end() && file != path.end(); ++out, ++file)
- {
- if(!fs::equivalent(outtmp /= *out, temp /= *file))
- break;
- }
- out = (out == outdir.begin()) ? outdir.end() : out;
-
- fs::path result = fs::path();
- for(; out != outdir.end(); ++out)
- if(*out != ".") result /= "..";
- std::divides<fs::path> concat;
- return std::accumulate(file, path.end(), result, concat);
- }
-
- fs::path calculate_relative_path(
- iterator first, iterator last, quickbook::actions& actions)
- {
- // Given a source file and the current filename, calculate the
- // path to the source file relative to the output directory.
- fs::path path(std::string(first, last));
- if (!path.is_complete())
- {
- fs::path infile = fs::complete(actions.filename).normalize();
- path = (infile.parent_path() / path).normalize();
- fs::path outdir = fs::complete(actions.outdir).normalize();
- path = path_difference(outdir, path);
- }
- return path;
- }
-
- void xinclude_action::operator()(iterator first, iterator last) const
- {
- fs::path path = calculate_relative_path(first, last, actions);
- out << "\n<xi:include href=\"";
- detail::print_string(detail::escape_uri(path.string()), out.get());
- out << "\" />\n";
- }
-
- void code_snippet_actions::append_code()
- {
- if(snippet_stack.empty()) return;
- snippet_data& snippet = snippet_stack.top();
-
- if (!code.empty())
- {
- detail::unindent(code); // remove all indents
-
- if(snippet.content.empty())
- {
- snippet.start_code = true;
- }
- else if(!snippet.end_code)
- {
- snippet.content += "\n\n";
- snippet.content += source_type;
- snippet.content += "```\n";
- }
-
- snippet.content += code;
- snippet.end_code = true;
-
- code.clear();
- }
- }
-
- void code_snippet_actions::close_code()
- {
- if(snippet_stack.empty()) return;
- snippet_data& snippet = snippet_stack.top();
-
- if(snippet.end_code)
- {
- snippet.content += "```\n\n";
- snippet.end_code = false;
- }
- }
-
- void code_snippet_actions::pass_thru(iterator first, iterator last)
- {
- if(snippet_stack.empty()) return;
- code += *first;
- }
-
- void code_snippet_actions::pass_thru_char(char c)
- {
- if(snippet_stack.empty()) return;
- code += c;
- }
-
- void code_snippet_actions::callout(iterator first, iterator last)
- {
- if(snippet_stack.empty()) return;
- code += "``[[callout" + boost::lexical_cast<std::string>(callout_id) + "]]``";
-
- snippet_stack.top().callouts.push_back(
- template_body(std::string(first, last), first.get_position(), true));
- ++callout_id;
- }
-
- void code_snippet_actions::escaped_comment(iterator first, iterator last)
- {
- if(snippet_stack.empty()) return;
- snippet_data& snippet = snippet_stack.top();
- append_code();
- close_code();
-
- std::string temp(first, last);
- detail::unindent(temp); // remove all indents
- if (temp.size() != 0)
- {
- snippet.content += "\n" + temp; // add a linebreak to allow block markups
- }
- }
-
- void code_snippet_actions::start_snippet(iterator first, iterator last)
- {
- append_code();
- snippet_stack.push(snippet_data(id, callout_id));
- id.clear();
- }
-
- void code_snippet_actions::end_snippet(iterator first, iterator last)
- {
- // TODO: Error?
- if(snippet_stack.empty()) return;
-
- append_code();
-
- snippet_data snippet = snippet_stack.top();
- snippet_stack.pop();
-
- std::string body;
- if(snippet.start_code) {
- body += "\n\n";
- body += source_type;
- body += "```\n";
- }
- body += snippet.content;
- if(snippet.end_code) {
- body += "```\n\n";
- }
-
- std::vector<std::string> params;
- for (size_t i = 0; i < snippet.callouts.size(); ++i)
- {
- params.push_back("[callout" + boost::lexical_cast<std::string>(snippet.callout_base_id + i) + "]");
- }
-
- // TODO: Save position in start_snippet
- template_symbol symbol(snippet.id, params, body, first.get_position(), true);
- symbol.callout = true;
- symbol.callouts = snippet.callouts;
- storage.push_back(symbol);
-
- // Merge the snippet into its parent
-
- if(!snippet_stack.empty())
- {
- snippet_data& next = snippet_stack.top();
- if(!snippet.content.empty()) {
- if(!snippet.start_code) {
- close_code();
- }
- else if(!next.end_code) {
- next.content += "\n\n";
- next.content += source_type;
- next.content += "```\n";
- }
-
- next.content += snippet.content;
- next.end_code = snippet.end_code;
- }
-
- next.callouts.insert(next.callouts.end(), snippet.callouts.begin(), snippet.callouts.end());
- }
- }
-
- int load_snippets(
- std::string const& file
- , std::vector<template_symbol>& storage // snippets are stored in a
- // vector of template_symbols
- , 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
-
- typedef position_iterator<std::string::const_iterator> iterator_type;
- iterator_type first(code.begin(), code.end(), file);
- iterator_type 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) {
- boost::spirit::classic::parse(first, last, python_code_snippet_grammar(a));
- }
- else {
- boost::spirit::classic::parse(first, last, cpp_code_snippet_grammar(a));
- }
-
- return 0;
- }
-
- namespace
- {
- fs::path include_search(fs::path const & current, std::string const & name)
- {
- fs::path path(name);
-
- // If the path is relative, try and resolve it.
- if (!path.is_complete())
- {
- // See if it can be found locally first.
- if (fs::exists(current / path))
- {
- return current / path;
- }
-
- // Search in each of the include path locations.
- BOOST_FOREACH(std::string const & p, include_path)
- {
- fs::path full(p);
- full /= path;
- if (fs::exists(full))
- {
- return full;
- }
- }
- }
-
- return path;
- }
- }
-
- void import_action::operator()(iterator first, iterator last) const
- {
- fs::path path = include_search(actions.filename.parent_path(), std::string(first,last));
- std::string ext = path.extension();
- std::vector<template_symbol> storage;
- actions.error_count +=
- load_snippets(path.string(), storage, ext, actions.doc_id);
-
- BOOST_FOREACH(template_symbol& ts, storage)
- {
- std::string tname = ts.identifier;
- ts.parent = &actions.templates.top_scope();
- if (!actions.templates.add(ts))
- {
- boost::spirit::classic::file_position const pos = ts.body.position;
- detail::outerr(pos.file, pos.line)
- << "Template Redefinition: " << tname << std::endl;
- ++actions.error_count;
- }
- }
- }
-
- void include_action::operator()(iterator first, iterator last) const
- {
- fs::path filein = include_search(actions.filename.parent_path(), std::string(first,last));
- std::string doc_type, doc_id;
- docinfo_string doc_dirname, doc_last_revision;
-
- // swap the filenames
- std::swap(actions.filename, filein);
-
- // save the doc info strings
- if(qbk_version_n >= 106) {
- doc_type = actions.doc_type;
- doc_id = actions.doc_id;
- doc_dirname = actions.doc_dirname;
- doc_last_revision = actions.doc_last_revision;
- }
- else {
- actions.doc_type.swap(doc_type);
- actions.doc_id.swap(doc_id);
- actions.doc_dirname.swap(doc_dirname);
- actions.doc_last_revision.swap(doc_last_revision);
- }
-
- // save the version info
- unsigned qbk_major_version_store = qbk_major_version;
- unsigned qbk_minor_version_store = qbk_minor_version;
- unsigned qbk_version_n_store = qbk_version_n;
-
- // scope the macros
- string_symbols macro = actions.macro;
- // scope the templates
- //~ template_symbols templates = actions.templates; $$$ fixme $$$
-
- // if an id is specified in this include (as in [include:id foo.qbk])
- // then use it as the doc_id.
- if (!actions.include_doc_id.empty())
- {
- actions.doc_id = actions.include_doc_id;
- actions.include_doc_id.clear();
- }
-
- // update the __FILENAME__ macro
- *boost::spirit::classic::find(actions.macro, "__FILENAME__") = actions.filename.file_string();
-
- // parse the file
- quickbook::parse_file(actions.filename.file_string().c_str(), actions, true);
-
- // restore the values
- std::swap(actions.filename, filein);
-
- actions.doc_type.swap(doc_type);
- actions.doc_id.swap(doc_id);
- actions.doc_dirname.swap(doc_dirname);
- actions.doc_last_revision.swap(doc_last_revision);
-
- if(qbk_version_n >= 106 || qbk_version_n_store >= 106)
- {
- qbk_major_version = qbk_major_version_store;
- qbk_minor_version = qbk_minor_version_store;
- qbk_version_n = qbk_version_n_store;
- }
-
- // restore the macros
- actions.macro = macro;
- // restore the templates
- //~ actions.templates = templates; $$$ fixme $$$
- }
-
- std::string const& docinfo_string::get(unsigned version) const
- {
- return (qbk_version_n < version) ? raw : encoded;
- }
-
- static void write_document_title(collector& out, quickbook::actions& actions);
- static void write_document_info(collector& out, quickbook::actions& actions);
-
- void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo)
- {
- // The doc_info in the file has been parsed. Here's what we'll do
- // *before* anything else.
-
- if (!actions.doc_id_tmp.empty())
- actions.doc_id = actions.doc_id_tmp.get(103);
-
- if (actions.doc_id.empty())
- actions.doc_id = detail::make_identifier(
- actions.doc_title.raw.begin(),actions.doc_title.raw.end());
-
- if (actions.doc_dirname.empty() && actions.doc_type == "library") {
- if (!actions.doc_id_tmp.empty()) {
- actions.doc_dirname = actions.doc_id_tmp;
- }
- else {
- actions.doc_dirname.raw = actions.doc_dirname.encoded = actions.doc_id;
- }
- }
-
- actions.doc_id_tmp.clear();
-
- if (actions.doc_last_revision.empty())
- {
- // default value for last-revision is now
-
- char strdate[64];
- strftime(
- strdate, sizeof(strdate),
- (debug_mode ?
- "DEBUG MODE Date: %Y/%m/%d %H:%M:%S $" :
- "$" /* prevent CVS substitution */ "Date: %Y/%m/%d %H:%M:%S $"),
- current_gm_time
- );
- actions.doc_last_revision.raw = actions.doc_last_revision.encoded = strdate;
- }
-
- // if we're ignoring the document info, we're done.
- if (ignore_docinfo)
- {
- return;
- }
-
- // Quickbook version
-
- if (qbk_major_version == -1)
- {
- // hard code quickbook version to v1.1
- qbk_major_version = 1;
- qbk_minor_version = 1;
- qbk_version_n = 101;
- detail::outwarn(actions.filename.file_string(),1)
- << "Warning: Quickbook version undefined. "
- "Version 1.1 is assumed" << std::endl;
- }
- else
- {
- qbk_version_n = ((unsigned) qbk_major_version * 100) +
- (unsigned) qbk_minor_version;
- }
-
- if (qbk_version_n == 106)
- {
- detail::outwarn(actions.filename.file_string(),1)
- << "Quickbook 1.6 is still under development and is "
- "likely to change in the future." << std::endl;
- }
- else if(qbk_version_n < 100 || qbk_version_n > 106)
- {
- detail::outerr(actions.filename.file_string(),1)
- << "Unknown version of quickbook: quickbook "
- << qbk_major_version
- << "."
- << qbk_minor_version
- << std::endl;
- ++actions.error_count;
- }
-
- // Warn about invalid fields
-
- if (actions.doc_type != "library")
- {
- std::vector<std::string> invalid_attributes;
-
- if (!actions.doc_purpose.empty())
- invalid_attributes.push_back("purpose");
-
- if (!actions.doc_categories.empty())
- invalid_attributes.push_back("category");
-
- if (!actions.doc_dirname.empty())
- invalid_attributes.push_back("dirname");
-
- if(!invalid_attributes.empty())
- {
- detail::outwarn(actions.filename.file_string(),1)
- << (invalid_attributes.size() > 1 ?
- "Invalid attributes" : "Invalid attribute")
- << " for '" << actions.doc_type << " document info': "
- << boost::algorithm::join(invalid_attributes, ", ")
- << "\n"
- ;
- }
- }
-
- // Write out header
-
- out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<!DOCTYPE "
- << actions.doc_type
- << " PUBLIC \"-//Boost//DTD BoostBook XML V1.0//EN\"\n"
- << " \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">\n"
- << '<' << actions.doc_type << "\n"
- << " id=\""
- << actions.doc_id
- << "\"\n";
-
- if(actions.doc_type == "library")
- {
- out << " name=\"" << actions.doc_title.get(103) << "\"\n";
- }
-
- if(!actions.doc_dirname.empty())
- {
- out << " dirname=\""
- << actions.doc_dirname.get(103)
- << "\"\n";
- }
-
- out << " last-revision=\""
- << actions.doc_last_revision.get(103)
- << "\" \n"
- << " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n";
-
- if(actions.doc_type == "library") {
- write_document_info(out, actions);
- write_document_title(out, actions);
- }
- else {
- write_document_title(out, actions);
- write_document_info(out, actions);
- }
- }
-
- void post(collector& out, quickbook::actions& actions, bool ignore_docinfo)
- {
- // if we're ignoring the document info, do nothing.
- if (ignore_docinfo)
- {
- return;
- }
-
- // We've finished generating our output. Here's what we'll do
- // *after* everything else.
- out << "\n</" << actions.doc_type << ">\n\n";
- }
-
- void write_document_title(collector& out, quickbook::actions& actions)
- {
- if (!actions.doc_title.empty())
- {
- out << " <title>"
- << actions.doc_title.get(103);
- if (!actions.doc_version.empty()) {
- out << ' ' << actions.doc_version.get(103);
- }
- out<< "</title>\n\n\n";
- }
- }
-
- void write_document_info(collector& out, quickbook::actions& actions)
- {
- std::ostringstream tmp;
-
- if(!actions.doc_authors.empty())
- {
- tmp << " <authorgroup>\n";
- for(actions::author_list::const_iterator
- it = actions.doc_authors.begin(),
- end = actions.doc_authors.end();
- it != end; ++it)
- {
- tmp << " <author>\n"
- << " <firstname>"
- << it->first.get(103)
- << "</firstname>\n"
- << " <surname>"
- << it->second.get(103)
- << "</surname>\n"
- << " </author>\n";
- }
- tmp << " </authorgroup>\n";
- }
-
- if (!actions.doc_copyrights.empty())
- {
- for(actions::copyright_list::const_iterator
- it = actions.doc_copyrights.begin(),
- end = actions.doc_copyrights.end();
- it != end; ++it)
- {
- tmp << "\n" << " <copyright>\n";
-
- for(actions::string_list::const_iterator
- it2 = it->first.begin(),
- end = it->first.end();
- it2 != end; ++it2)
- {
- tmp << " <year>" << *it2 << "</year>\n";
- }
-
- tmp << " <holder>"
- << it->second.get(103)
- << "</holder>\n"
- << " </copyright>\n"
- << "\n"
- ;
- }
- }
-
- if (!actions.doc_license.empty())
- {
- tmp << " <legalnotice>\n"
- << " <para>\n"
- << " " << actions.doc_license.get(103) << "\n"
- << " </para>\n"
- << " </legalnotice>\n"
- << "\n"
- ;
- }
-
- if (!actions.doc_purpose.empty())
- {
- tmp << " <" << actions.doc_type << "purpose>\n"
- << " " << actions.doc_purpose.get(103)
- << " </" << actions.doc_type << "purpose>\n"
- << "\n"
- ;
- }
-
- if (!actions.doc_categories.empty())
- {
- for(actions::docinfo_list::const_iterator
- it = actions.doc_categories.begin(),
- end = actions.doc_categories.end();
- it != end; ++it)
- {
- tmp << " <" << actions.doc_type << "category name=\"category:"
- << it->get(103)
- << "\"></" << actions.doc_type << "category>\n"
- << "\n"
- ;
- }
- }
-
- std::string value = tmp.str();
- if(!value.empty())
- {
- out << " <" << actions.doc_type << "info>\n"
- << value
- << " </" << actions.doc_type << "info>\n"
- << "\n"
- ;
- }
- }
-
- void phrase_to_string_action::operator()(iterator first, iterator last) const
- {
- out.clear();
- phrase.swap(out);
- }
-
- void phrase_to_docinfo_action::operator()(iterator first, iterator last) const
- {
- out.encoded.clear();
- phrase.swap(out.encoded);
- out.raw = std::string(first, last);
- }
-
- void copy_stream_action::operator()(iterator first, iterator last) const
- {
- std::string str;
- phrase.swap(str);
- out << str;
- }
-}

Deleted: trunk/tools/quickbook/detail/actions.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,873 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_ACTIONS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP
-
-#include <time.h>
-#include <map>
-#include <string>
-#include <vector>
-#include <stack>
-#include <algorithm>
-#include <boost/spirit/include/classic_iterator.hpp>
-#include <boost/filesystem/v2/operations.hpp>
-#include <boost/foreach.hpp>
-#include <boost/tuple/tuple.hpp>
-#include "./collector.hpp"
-#include "./template_stack.hpp"
-#include "./utils.hpp"
-
-#ifdef BOOST_MSVC
-// disable copy/assignment could not be generated, unreferenced formal params
-#pragma warning (push)
-#pragma warning(disable : 4511 4512 4100)
-#endif
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
-
- namespace fs = boost::filesystem;
- typedef position_iterator<std::string::const_iterator> iterator;
- typedef symbols<std::string> string_symbols;
- typedef std::map<std::string, std::string> attribute_map;
-
- struct actions;
- extern tm* current_time; // the current time
- extern tm* current_gm_time; // the current UTC time
- extern bool debug_mode;
- extern std::vector<std::string> include_path;
- extern std::vector<std::string> preset_defines;
-
- // forward declarations
- struct actions;
- int parse_file(char const* filein_, actions& actor, bool ignore_docinfo = false);
-
- struct error_action
- {
- // Prints an error message to std::cerr
-
- error_action(
- int& error_count)
- : error_count(error_count) {}
-
- void operator()(iterator first, iterator /*last*/) const;
-
- int& error_count;
- };
-
- struct phrase_action
- {
- // blurb, blockquote, preformatted, list_item,
- // unordered_list, ordered_list
-
- phrase_action(
- collector& out,
- collector& phrase,
- std::string const& pre,
- std::string const& post)
- : out(out)
- , phrase(phrase)
- , pre(pre)
- , post(post) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& phrase;
- std::string pre;
- std::string post;
- };
-
- struct implicit_paragraph_action
- {
- // implicit paragraphs
- // doesn't output the paragraph if it's only whitespace.
-
- implicit_paragraph_action(
- collector& out,
- collector& phrase,
- std::string const& pre,
- std::string const& post)
- : out(out)
- , phrase(phrase)
- , pre(pre)
- , post(post) {}
-
- void operator()() const;
- void operator()(iterator first, iterator last) const { (*this)(); }
-
- collector& out;
- collector& phrase;
- std::string pre;
- std::string post;
- };
-
- struct header_action
- {
- // Handles paragraph, h1, h2, h3, h4, h5, h6,
-
- header_action(
- collector& out,
- collector& phrase,
- std::string const& element_id,
- std::string const& library_id,
- std::string const& section_id,
- std::string const& qualified_section_id,
- std::string const& pre,
- std::string const& post)
- : out(out)
- , phrase(phrase)
- , element_id(element_id)
- , library_id(library_id)
- , section_id(section_id)
- , qualified_section_id(qualified_section_id)
- , pre(pre)
- , post(post) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& phrase;
- std::string const& element_id;
- std::string const& library_id;
- std::string const& section_id;
- std::string const& qualified_section_id;
- std::string pre;
- std::string post;
- };
-
- struct generic_header_action
- {
- // Handles h
-
- generic_header_action(
- collector& out,
- collector& phrase,
- std::string const& element_id,
- std::string const& library_id,
- std::string const& section_id,
- std::string const& qualified_section_id,
- int const& section_level)
- : out(out)
- , phrase(phrase)
- , element_id(element_id)
- , library_id(library_id)
- , section_id(section_id)
- , qualified_section_id(qualified_section_id)
- , section_level(section_level) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& phrase;
- std::string const& element_id;
- std::string const& library_id;
- std::string const& section_id;
- std::string const& qualified_section_id;
- int const& section_level;
- };
-
- struct simple_phrase_action
- {
- // Handles simple text formats
-
- simple_phrase_action(
- collector& out
- , std::string const& pre
- , std::string const& post
- , string_symbols const& macro)
- : out(out)
- , pre(pre)
- , post(post)
- , macro(macro) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- std::string pre;
- std::string post;
- string_symbols const& macro;
- };
-
- struct cond_phrase_action_pre
- {
- // Handles conditional phrases
-
- cond_phrase_action_pre(
- collector& out
- , std::vector<bool>& conditions
- , string_symbols const& macro)
- : out(out)
- , conditions(conditions)
- , macro(macro) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- std::vector<bool>& conditions;
- string_symbols const& macro;
- };
-
- struct cond_phrase_action_post
- {
- // Handles conditional phrases
-
- cond_phrase_action_post(
- collector& out
- , std::vector<bool>& conditions
- , string_symbols const& macro)
- : out(out)
- , conditions(conditions)
- , macro(macro) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- std::vector<bool>& conditions;
- string_symbols const& macro;
- };
-
- struct list_action
- {
- // Handles lists
-
- typedef std::pair<char, int> mark_type;
- list_action(
- collector& out
- , collector& list_buffer
- , int& list_indent
- , std::stack<mark_type>& list_marks)
- : out(out)
- , list_buffer(list_buffer)
- , list_indent(list_indent)
- , list_marks(list_marks) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& list_buffer;
- int& list_indent;
- std::stack<mark_type>& list_marks;
- };
-
- struct list_format_action
- {
- // Handles list formatting and hierarchy
-
- typedef std::pair<char, int> mark_type;
- list_format_action(
- collector& out
- , int& list_indent
- , std::stack<mark_type>& list_marks
- , int& error_count)
- : out(out)
- , list_indent(list_indent)
- , list_marks(list_marks)
- , error_count(error_count) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- int& list_indent;
- std::stack<mark_type>& list_marks;
- int& error_count;
- };
-
- struct span
- {
- // Decorates c++ code fragments
-
- span(char const* name, collector& out)
- : name(name), out(out) {}
-
- void operator()(iterator first, iterator last) const;
-
- char const* name;
- collector& out;
- };
-
- struct unexpected_char
- {
- // Handles unexpected chars in c++ syntax
-
- unexpected_char(collector& out)
- : out(out) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- };
-
- struct anchor_action
- {
- // Handles anchors
-
- anchor_action(collector& out)
- : out(out) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- };
-
- extern char const* quickbook_get_date;
- extern char const* quickbook_get_time;
-
- struct do_macro_action
- {
- // Handles macro substitutions
-
- do_macro_action(collector& phrase)
- : phrase(phrase) {}
-
- void operator()(std::string const& str) const;
- collector& phrase;
- };
-
- struct space
- {
- // Prints a space
-
- space(collector& out)
- : out(out) {}
-
- void operator()(iterator first, iterator last) const;
- void operator()(char ch) const;
-
- collector& out;
- };
-
- struct pre_escape_back
- {
- // Escapes back from code to quickbook (Pre)
-
- pre_escape_back(actions& escape_actions, std::string& save)
- : escape_actions(escape_actions), save(save) {}
-
- void operator()(iterator first, iterator last) const;
-
- actions& escape_actions;
- std::string& save;
- };
-
- struct post_escape_back
- {
- // Escapes back from code to quickbook (Post)
-
- post_escape_back(collector& out, actions& escape_actions, std::string& save)
- : out(out), escape_actions(escape_actions), save(save) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- actions& escape_actions;
- std::string& save;
- };
-
- struct raw_char_action
- {
- // Prints a single raw (unprocessed) char.
- // Allows '<', '>'... etc.
-
- raw_char_action(collector& phrase)
- : phrase(phrase) {}
-
- void operator()(char ch) const;
- void operator()(iterator first, iterator /*last*/) const;
-
- collector& phrase;
- };
-
- struct plain_char_action
- {
- // Prints a single plain char.
- // Converts '<' to "&lt;"... etc See utils.hpp
-
- plain_char_action(collector& phrase)
- : phrase(phrase) {}
-
- void operator()(char ch) const;
- void operator()(iterator first, iterator /*last*/) const;
-
- collector& phrase;
- };
-
- struct escape_unicode_action
- {
- escape_unicode_action(collector& phrase) : phrase(phrase) {}
- void operator()(iterator first, iterator last) const;
-
- collector& phrase;
- };
-
- struct attribute_action
- {
- // Handle image attributes
-
- attribute_action(
- attribute_map& attributes
- , std::string& attribute_name
- , int& error_count)
- : attributes(attributes)
- , attribute_name(attribute_name)
- , error_count(error_count) {}
-
- void operator()(iterator first, iterator last) const;
-
- attribute_map& attributes;
- std::string& attribute_name;
- int& error_count;
- };
-
- struct image_action
- {
- // Handles inline images
-
- image_action(
- collector& phrase
- , attribute_map& attributes
- , std::string& image_fileref)
- : phrase(phrase)
- , attributes(attributes)
- , image_fileref(image_fileref) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& phrase;
- attribute_map& attributes;
- std::string& image_fileref;
- };
-
- struct markup_action
- {
- // A generic markup action
-
- markup_action(collector& phrase, std::string const& str)
- : phrase(phrase), str(str) {}
-
- template <typename T>
- void operator()(T const&) const
- {
- phrase << str;
- }
-
- template <typename T>
- void operator()(T const&, T const&) const
- {
- phrase << str;
- }
-
- collector& phrase;
- std::string str;
- };
-
- struct syntax_highlight
- {
- syntax_highlight(
- collector& temp
- , std::string const& source_mode
- , string_symbols const& macro
- , actions& escape_actions)
- : temp(temp)
- , source_mode(source_mode)
- , macro(macro)
- , escape_actions(escape_actions)
- {
- }
-
- std::string operator()(iterator begin, iterator end) const;
-
- collector& temp;
- std::string const& source_mode;
- string_symbols const& macro;
- actions& escape_actions;
- };
-
-
- struct code_action
- {
- // Does the actual syntax highlighing of code
-
- code_action(
- collector& out
- , collector& phrase
- , syntax_highlight& syntax_p)
- : out(out)
- , phrase(phrase)
- , syntax_p(syntax_p)
- {
- }
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& phrase;
- syntax_highlight& syntax_p;
- };
-
- struct inline_code_action
- {
- // Does the actual syntax highlighing of code inlined in text
-
- inline_code_action(
- collector& out
- , syntax_highlight& syntax_p)
- : out(out)
- , syntax_p(syntax_p)
- {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- syntax_highlight& syntax_p;
- };
-
- struct start_varlistitem_action
- {
- start_varlistitem_action(collector& phrase)
- : phrase(phrase) {}
-
- void operator()() const;
-
- template <typename T1>
- void operator()(T1 const&) const { return (*this)(); }
- template <typename T1, typename T2>
- void operator()(T1 const&, T2 const&) const { return (*this)(); }
-
- collector& phrase;
- };
-
- struct end_varlistitem_action
- {
- end_varlistitem_action(collector& phrase, collector& temp_para)
- : phrase(phrase), temp_para(temp_para) {}
-
- void operator()() const;
-
- template <typename T1>
- void operator()(T1 const&) const { return (*this)(); }
- template <typename T1, typename T2>
- void operator()(T1 const&, T2 const&) const { return (*this)(); }
-
- collector& phrase;
- collector& temp_para;
- };
-
- struct break_action
- {
- // Handles line-breaks (DEPRECATED!!!)
-
- break_action(collector& phrase)
- : phrase(phrase) {}
-
- void operator()(iterator f, iterator) const;
-
- collector& phrase;
- };
-
- struct macro_identifier_action
- {
- // Handles macro identifiers
-
- macro_identifier_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator first, iterator last) const;
-
- quickbook::actions& actions;
- };
-
- struct macro_definition_action
- {
- // Handles macro definitions
-
- macro_definition_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator first, iterator last) const;
-
- quickbook::actions& actions;
- };
-
- struct template_body_action
- {
- // Handles template definitions
-
- template_body_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator first, iterator last) const;
-
- quickbook::actions& actions;
- };
-
- struct template_arg_action
- {
- // Handles a template argument
-
- template_arg_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator first, iterator last) const;
-
- quickbook::actions& actions;
- };
-
- struct do_template_action
- {
- // Handles template substitutions
-
- do_template_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator first, iterator last) const;
-
- quickbook::actions& actions;
- };
-
- struct link_action
- {
- // Handles links (URL, XML refentry, function, class, member)
-
- link_action(collector& phrase, char const* tag)
- : phrase(phrase), tag(tag) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& phrase;
- char const* tag;
- };
-
- struct variablelist_action
- {
- // Handles variable lists
-
- variablelist_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator, iterator) const;
-
- quickbook::actions& actions;
- };
-
- struct table_action
- {
- // Handles tables
-
- table_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator, iterator) const;
-
- quickbook::actions& actions;
- };
-
- struct start_row_action
- {
- // Handles table rows
-
- start_row_action(collector& phrase, unsigned& span, std::string& header)
- : phrase(phrase), span(span), header(header) {}
-
- void operator()(char) const;
- void operator()(iterator f, iterator) const;
-
- collector& phrase;
- unsigned& span;
- std::string& header;
- };
-
- struct start_col_action
- {
- // Handles table columns
-
- start_col_action(collector& phrase, unsigned& span)
- : phrase(phrase), span(span) {}
-
- void operator()(char) const;
-
- collector& phrase;
- unsigned& span;
- };
-
- struct end_col_action
- {
- end_col_action(collector& phrase, collector& temp_para)
- : phrase(phrase), temp_para(temp_para) {}
-
- void operator()(char) const;
-
- collector& phrase;
- collector& temp_para;
- };
-
- 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
- , std::string& element_id)
- : out(out)
- , phrase(phrase)
- , library_id(library_id)
- , section_id(section_id)
- , section_level(section_level)
- , qualified_section_id(qualified_section_id)
- , element_id(element_id) {}
-
- 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;
- std::string& element_id;
- };
-
- struct end_section_action
- {
- end_section_action(
- collector& out
- , int& section_level
- , int& min_section_level
- , std::string& qualified_section_id
- , int& error_count)
- : out(out)
- , section_level(section_level)
- , min_section_level(min_section_level)
- , qualified_section_id(qualified_section_id)
- , error_count(error_count) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- int& section_level;
- int& min_section_level;
- std::string& qualified_section_id;
- int& error_count;
- };
-
- struct element_id_warning_action
- {
- void operator()(iterator first, iterator last) const;
- };
-
- struct xinclude_action
- {
- // Handles XML includes
- xinclude_action(collector& out_, quickbook::actions& actions_)
- : out(out_), actions(actions_) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- quickbook::actions& actions;
- };
-
- struct include_action
- {
- // Handles QBK includes
-
- include_action(quickbook::actions& actions_)
- : actions(actions_) {}
-
- void operator()(iterator first, iterator last) const;
-
- quickbook::actions& actions;
- };
-
- struct import_action
- {
- // Handles import of source code files (e.g. *.cpp *.py)
- import_action(collector& out_, quickbook::actions& actions_)
- : out(out_), actions(actions_) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- quickbook::actions& actions;
- };
-
- struct docinfo_string {
- std::string raw;
- std::string encoded;
-
- docinfo_string() : raw(), encoded() {}
-
- void swap(docinfo_string& x) {
- raw.swap(x.raw);
- encoded.swap(x.encoded);
- }
-
- void clear() {
- raw.clear();
- encoded.clear();
- }
-
- bool empty() const {
- return raw.empty();
- }
-
- std::string const& get(unsigned version) const;
- };
-
- void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo = false);
- void post(collector& out, quickbook::actions& actions, bool ignore_docinfo = false);
-
- struct phrase_to_string_action
- {
- phrase_to_string_action(std::string& out, collector& phrase)
- : out(out) , phrase(phrase) {}
-
- void operator()(iterator first, iterator last) const;
-
- std::string& out;
- collector& phrase;
- };
-
- struct phrase_to_docinfo_action
- {
- phrase_to_docinfo_action(docinfo_string& out, collector& phrase)
- : out(out)
- , phrase(phrase) {}
-
- void operator()(iterator first, iterator last) const;
-
- docinfo_string& out;
- collector& phrase;
- };
-
- struct copy_stream_action
- {
- copy_stream_action(collector& out, collector& phrase)
- : out(out) , phrase(phrase) {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& phrase;
- };
-}
-
-#ifdef BOOST_MSVC
-#pragma warning (pop)
-#endif
-
-#endif // BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP
-

Deleted: trunk/tools/quickbook/detail/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,250 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2005 Thomas Guest
- http://spirit.sourceforge.net/
-
- 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 "./actions_class.hpp"
-#include "./markups.hpp"
-
-#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
-#pragma warning(disable:4355)
-#endif
-
-namespace quickbook
-{
- actions::actions(char const* filein_, fs::path const& outdir_, string_stream& out_)
- // header info
- : doc_type()
- , doc_title()
- , doc_version()
- , doc_id()
- , doc_dirname()
- , doc_copyrights()
- , doc_purpose()
- , doc_categories()
- , doc_authors()
- , doc_license()
- , doc_last_revision()
- , include_doc_id()
-
- // main output stream
- , out(out_)
-
- // auxilliary streams
- , phrase()
- , temp()
- , list_buffer()
-
- // state
- , filename(fs::complete(fs::path(filein_)))
- , outdir(outdir_)
- , macro()
- , section_level(0)
- , min_section_level(0)
- , section_id()
- , qualified_section_id()
- , source_mode("c++")
-
- // temporary or global state
- , element_id()
- , table_title()
- , table_span(0)
- , table_header()
- , macro_id()
- , list_marks()
- , list_indent(-1)
- , template_identifier()
- , template_info()
- , template_depth(0)
- , template_escape(false)
- , templates()
- , error_count(0)
- , image_fileref()
- , attribute_name()
- , attributes()
-
- // actions
- , error(error_count)
- , extract_doc_title(doc_title, phrase)
- , extract_doc_license(doc_license, phrase)
- , extract_doc_purpose(doc_purpose, phrase)
- , extract_doc_version(doc_version, phrase)
- , extract_doc_id(doc_id_tmp, phrase)
- , extract_doc_dirname(doc_dirname, phrase)
- , extract_copyright_second(copyright.second, phrase)
- , extract_name_second(name.second, phrase)
- , extract_name_first(name.first, phrase)
- , extract_doc_last_revision(doc_last_revision, phrase)
- , extract_doc_category(doc_category, phrase)
- , syntax_p(temp, source_mode, macro, *this)
- , code(out, phrase, syntax_p)
- , code_block(phrase, phrase, syntax_p)
- , inline_code(phrase, syntax_p)
- , inside_paragraph(temp_para, phrase, paragraph_pre, paragraph_post)
- , write_paragraphs(out, temp_para)
- , h(out, phrase, element_id, doc_id, section_id, qualified_section_id, section_level)
- , h1(out, phrase, element_id, doc_id, section_id, qualified_section_id, h1_pre, h1_post)
- , h2(out, phrase, element_id, doc_id, section_id, qualified_section_id, h2_pre, h2_post)
- , h3(out, phrase, element_id, doc_id, section_id, qualified_section_id, h3_pre, h3_post)
- , h4(out, phrase, element_id, doc_id, section_id, qualified_section_id, h4_pre, h4_post)
- , h5(out, phrase, element_id, doc_id, section_id, qualified_section_id, h5_pre, h5_post)
- , h6(out, phrase, element_id, doc_id, section_id, qualified_section_id, h6_pre, h6_post)
- , hr(out, hr_)
- , blurb(out, temp_para, blurb_pre, blurb_post)
- , blockquote(out, temp_para, blockquote_pre, blockquote_post)
- , preformatted(out, phrase, preformatted_pre, preformatted_post)
- , warning(out, temp_para, warning_pre, warning_post)
- , caution(out, temp_para, caution_pre, caution_post)
- , important(out, temp_para, important_pre, important_post)
- , note(out, temp_para, note_pre, note_post)
- , tip(out, temp_para, tip_pre, tip_post)
- , plain_char(phrase)
- , raw_char(phrase)
- , escape_unicode(phrase)
- , attribute(attributes, attribute_name, error_count)
- , image(phrase, attributes, image_fileref)
- , cond_phrase_pre(phrase, conditions, macro)
- , cond_phrase_post(phrase, conditions, macro)
-
- , list(out, list_buffer, list_indent, list_marks)
- , list_format(list_buffer, list_indent, list_marks, error_count)
- , list_item(list_buffer, phrase, list_item_pre, list_item_post)
-
- , funcref_pre(phrase, funcref_pre_)
- , funcref_post(phrase, funcref_post_)
- , classref_pre(phrase, classref_pre_)
- , classref_post(phrase, classref_post_)
- , memberref_pre(phrase, memberref_pre_)
- , memberref_post(phrase, memberref_post_)
- , enumref_pre(phrase, enumref_pre_)
- , enumref_post(phrase, enumref_post_)
- , macroref_pre(phrase, macroref_pre_)
- , macroref_post(phrase, macroref_post_)
- , headerref_pre(phrase, headerref_pre_)
- , headerref_post(phrase, headerref_post_)
- , conceptref_pre(phrase, conceptref_pre_)
- , conceptref_post(phrase, conceptref_post_)
- , globalref_pre(phrase, globalref_pre_)
- , globalref_post(phrase, globalref_post_)
-
- , bold_pre(phrase, bold_pre_)
- , bold_post(phrase, bold_post_)
- , italic_pre(phrase, italic_pre_)
- , italic_post(phrase, italic_post_)
- , underline_pre(phrase, underline_pre_)
- , underline_post(phrase, underline_post_)
- , teletype_pre(phrase, teletype_pre_)
- , teletype_post(phrase, teletype_post_)
- , strikethrough_pre(phrase, strikethrough_pre_)
- , strikethrough_post(phrase, strikethrough_post_)
- , quote_pre(phrase, quote_pre_)
- , quote_post(phrase, quote_post_)
- , replaceable_pre(phrase, replaceable_pre_)
- , replaceable_post(phrase, replaceable_post_)
- , footnote_pre(phrase, footnote_pre_)
- , footnote_post(phrase, footnote_post_)
-
- , simple_bold(phrase, bold_pre_, bold_post_, macro)
- , simple_italic(phrase, italic_pre_, italic_post_, macro)
- , simple_underline(phrase, underline_pre_, underline_post_, macro)
- , simple_teletype(phrase, teletype_pre_, teletype_post_, macro)
- , simple_strikethrough(phrase, strikethrough_pre_, strikethrough_post_, macro)
-
- , variablelist(*this)
- , start_varlistentry(phrase, start_varlistentry_)
- , end_varlistentry(phrase, end_varlistentry_)
- , start_varlistterm(phrase, start_varlistterm_)
- , end_varlistterm(phrase, end_varlistterm_)
- , start_varlistitem(phrase)
- , end_varlistitem(phrase, temp_para)
-
- , break_(phrase)
- , macro_identifier(*this)
- , macro_definition(*this)
- , do_macro(phrase)
- , template_body(*this)
- , template_arg(*this)
- , do_template(*this)
- , url_pre(phrase, url_pre_)
- , url_post(phrase, url_post_)
- , link_pre(phrase, link_pre_)
- , link_post(phrase, link_post_)
- , table(*this)
- , start_row(phrase, table_span, table_header)
- , end_row(phrase, end_row_)
- , start_cell(phrase, table_span)
- , end_cell(phrase, temp_para)
- , anchor(out)
-
- , begin_section(out, phrase, doc_id, section_id, section_level, qualified_section_id, element_id)
- , end_section(out, section_level, min_section_level, qualified_section_id, error_count)
- , xinclude(out, *this)
- , include(*this)
- , import(out, *this)
-
- , escape_pre(phrase, escape_pre_)
- , escape_post(phrase, escape_post_)
- {
- // turn off __FILENAME__ macro on debug mode = true
- std::string filename_str = debug_mode ?
- std::string("NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE") :
- filename.file_string();
-
- // add the predefined macros
- macro.add
- ("__DATE__", std::string(quickbook_get_date))
- ("__TIME__", std::string(quickbook_get_time))
- ("__FILENAME__", filename_str)
- ;
- }
-
- void actions::push()
- {
- state_stack.push(
- boost::make_tuple(
- filename
- , outdir
- , macro
- , section_level
- , min_section_level
- , section_id
- , qualified_section_id
- , source_mode
- )
- );
-
- out.push();
- phrase.push();
- temp.push();
- temp_para.push();
- list_buffer.push();
- templates.push();
- }
-
- void actions::pop()
- {
- boost::tie(
- filename
- , outdir
- , macro
- , section_level
- , min_section_level
- , section_id
- , qualified_section_id
- , source_mode
- ) = state_stack.top();
- state_stack.pop();
-
- out.pop();
- phrase.pop();
- temp.pop();
- temp_para.pop();
- list_buffer.pop();
- templates.pop();
- }
-}

Deleted: trunk/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,235 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_ACTIONS_CLASS_HPP)
-#define BOOST_SPIRIT_ACTIONS_CLASS_HPP
-
-#include "./actions.hpp"
-#include <boost/tuple/tuple.hpp>
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
- namespace fs = boost::filesystem;
-
- struct actions
- {
- actions(char const* filein_, fs::path const& outdir, string_stream& out_);
-
- ///////////////////////////////////////////////////////////////////////////
- // State
- ///////////////////////////////////////////////////////////////////////////
-
- typedef std::vector<std::string> string_list;
-
- typedef std::vector<docinfo_string> docinfo_list;
- typedef std::pair<docinfo_string, docinfo_string> author;
- typedef std::vector<author> author_list;
- typedef std::pair<string_list, docinfo_string> copyright_item;
- typedef std::vector<copyright_item> copyright_list;
- typedef std::pair<char, int> mark_type;
- static int const max_template_depth = 100;
-
- // header info
- std::string doc_type;
- docinfo_string doc_title;
- docinfo_string doc_version;
- std::string doc_id;
- docinfo_string doc_dirname;
- copyright_list doc_copyrights;
- docinfo_string doc_purpose;
- docinfo_list doc_categories;
- author_list doc_authors;
- docinfo_string doc_license;
- docinfo_string doc_last_revision;
- std::string include_doc_id;
- //temporary state
- docinfo_string doc_id_tmp;
- author name;
- copyright_item copyright;
- docinfo_string doc_category;
-
-
- // main output stream
- collector out;
-
- // auxilliary streams
- collector phrase;
- collector temp;
- collector temp_para;
- collector list_buffer;
-
- // state
- fs::path filename;
- fs::path outdir;
- string_symbols macro;
- int section_level;
- int min_section_level;
- std::string section_id;
- std::string qualified_section_id;
- std::string source_mode;
-
- typedef boost::tuple<
- fs::path
- , fs::path
- , string_symbols
- , int
- , int
- , std::string
- , std::string
- , std::string>
- state_tuple;
-
- std::stack<state_tuple> state_stack;
-
- // temporary or global state
- std::string element_id;
- std::string table_title;
- unsigned table_span;
- std::string table_header;
- std::string macro_id;
- std::stack<mark_type> list_marks;
- int list_indent;
- std::vector<bool> conditions;
- std::string template_identifier;
- string_list template_info;
- int template_depth;
- bool template_escape;
- bool template_block;
- std::vector<quickbook::template_body>
- template_args;
- template_stack templates;
- int error_count;
- std::string image_fileref;
- std::string attribute_name;
- attribute_map attributes;
-
- // push/pop the states and the streams
- void push();
- void pop();
-
- ///////////////////////////////////////////////////////////////////////////
- // actions
- ///////////////////////////////////////////////////////////////////////////
- error_action error;
- phrase_to_docinfo_action extract_doc_title;
- phrase_to_docinfo_action extract_doc_license;
- phrase_to_docinfo_action extract_doc_purpose;
- phrase_to_docinfo_action extract_doc_version;
- phrase_to_docinfo_action extract_doc_id;
- phrase_to_docinfo_action extract_doc_dirname;
- phrase_to_docinfo_action extract_copyright_second;
- phrase_to_docinfo_action extract_name_second;
- phrase_to_docinfo_action extract_name_first;
- phrase_to_docinfo_action extract_doc_last_revision;
- phrase_to_docinfo_action extract_doc_category;
-
- syntax_highlight syntax_p;
- code_action code;
- code_action code_block;
- inline_code_action inline_code;
- implicit_paragraph_action inside_paragraph;
- copy_stream_action write_paragraphs;
- generic_header_action h;
- header_action h1, h2, h3, h4, h5, h6;
- markup_action hr;
- phrase_action blurb, blockquote, preformatted;
- phrase_action warning, caution, important, note, tip;
- plain_char_action plain_char;
- raw_char_action raw_char;
- escape_unicode_action escape_unicode;
- attribute_action attribute;
- image_action image;
- cond_phrase_action_pre cond_phrase_pre;
- cond_phrase_action_post cond_phrase_post;
-
- list_action list;
- list_format_action list_format;
- phrase_action list_item;
-
- link_action funcref_pre;
- markup_action funcref_post;
- link_action classref_pre;
- markup_action classref_post;
- link_action memberref_pre;
- markup_action memberref_post;
- link_action enumref_pre;
- markup_action enumref_post;
- link_action macroref_pre;
- markup_action macroref_post;
- link_action headerref_pre;
- markup_action headerref_post;
- link_action conceptref_pre;
- markup_action conceptref_post;
- link_action globalref_pre;
- markup_action globalref_post;
-
- markup_action bold_pre;
- markup_action bold_post;
- markup_action italic_pre;
- markup_action italic_post;
- markup_action underline_pre;
- markup_action underline_post;
- markup_action teletype_pre;
- markup_action teletype_post;
- markup_action strikethrough_pre;
- markup_action strikethrough_post;
- markup_action quote_pre;
- markup_action quote_post;
- markup_action replaceable_pre;
- markup_action replaceable_post;
- markup_action footnote_pre;
- markup_action footnote_post;
-
- simple_phrase_action simple_bold;
- simple_phrase_action simple_italic;
- simple_phrase_action simple_underline;
- simple_phrase_action simple_teletype;
- simple_phrase_action simple_strikethrough;
-
- variablelist_action variablelist;
- markup_action start_varlistentry;
- markup_action end_varlistentry;
- markup_action start_varlistterm;
- markup_action end_varlistterm;
- start_varlistitem_action start_varlistitem;
- end_varlistitem_action end_varlistitem;
-
- break_action break_;
- macro_identifier_action macro_identifier;
- macro_definition_action macro_definition;
- do_macro_action do_macro;
- template_body_action template_body;
- template_arg_action template_arg;
- do_template_action do_template;
- link_action url_pre;
- markup_action url_post;
- link_action link_pre;
- markup_action link_post;
- table_action table;
- start_row_action start_row;
- markup_action end_row;
- start_col_action start_cell;
- end_col_action end_cell;
- 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;
- import_action import;
-
- markup_action escape_pre;
- markup_action escape_post;
- };
-}
-
-#endif // BOOST_SPIRIT_ACTIONS_CLASS_HPP
-

Deleted: trunk/tools/quickbook/detail/collector.cpp
==============================================================================
--- trunk/tools/quickbook/detail/collector.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,67 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- 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 "./collector.hpp"
-#include <boost/assert.hpp>
-
-namespace quickbook
-{
- string_stream::string_stream()
- : buffer_ptr(new std::string())
- , stream_ptr(new ostream(boost::iostreams::back_inserter(*buffer_ptr.get())))
- {}
-
- string_stream::string_stream(string_stream const& other)
- : buffer_ptr(other.buffer_ptr)
- , stream_ptr(other.stream_ptr)
- {}
-
- string_stream&
- string_stream::operator=(string_stream const& other)
- {
- buffer_ptr = other.buffer_ptr;
- stream_ptr = other.stream_ptr;
- return *this;
- }
-
- collector::collector()
- : main(default_)
- , top(default_)
- {
- }
-
- collector::collector(string_stream& out)
- : main(out)
- , top(out)
- {
- }
-
- collector::~collector()
- {
- BOOST_ASSERT(streams.empty()); // assert there are no more pushes than pops!!!
- }
-
- void
- collector::push()
- {
- streams.push(string_stream());
- top = boost::ref(streams.top());
- }
-
- void
- collector::pop()
- {
- BOOST_ASSERT(!streams.empty());
- streams.pop();
-
- if (streams.empty())
- top = boost::ref(main);
- else
- top = boost::ref(streams.top());
- }
-}

Deleted: trunk/tools/quickbook/detail/collector.hpp
==============================================================================
--- trunk/tools/quickbook/detail/collector.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,123 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_COLLECTOR_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_COLLECTOR_HPP
-
-#include <string>
-#include <stack>
-#include <boost/ref.hpp>
-#include <boost/shared_ptr.hpp>
-#include <boost/noncopyable.hpp>
-#include <boost/iostreams/device/back_inserter.hpp>
-#include <boost/iostreams/filtering_stream.hpp>
-
-namespace quickbook
-{
- struct string_stream
- {
- typedef boost::iostreams::filtering_ostream ostream;
-
- string_stream();
- string_stream(string_stream const& other);
- string_stream& operator=(string_stream const& other);
-
- std::string const& str() const
- {
- stream_ptr->flush();
- return *buffer_ptr.get();
- }
-
- std::ostream& get() const
- {
- return *stream_ptr.get();
- }
-
- void clear()
- {
- buffer_ptr->clear();
- }
-
- void swap(std::string& other)
- {
- stream_ptr->flush();
- std::swap(other, *buffer_ptr.get());
- }
-
- void append(std::string const& other)
- {
- stream_ptr->flush();
- *buffer_ptr.get() += other;
- }
-
- private:
-
- boost::shared_ptr<std::string> buffer_ptr;
- boost::shared_ptr<ostream> stream_ptr;
- };
-
- struct collector : boost::noncopyable
- {
- collector();
- collector(string_stream& out);
- ~collector();
-
- void push();
- void pop();
-
- std::ostream& get() const
- {
- return top.get().get();
- }
-
- std::string const& str() const
- {
- return top.get().str();
- }
-
- void clear()
- {
- top.get().clear();
- }
-
- void swap(std::string& other)
- {
- top.get().swap(other);
- }
-
- void append(std::string const& other)
- {
- top.get().append(other);
- }
-
- private:
-
- std::stack<string_stream> streams;
- boost::reference_wrapper<string_stream> main;
- boost::reference_wrapper<string_stream> top;
- string_stream default_;
- };
-
- template <typename T>
- inline collector&
- operator<<(collector& out, T const& val)
- {
- out.get() << val;
- return out;
- }
-
- inline collector&
- operator<<(collector& out, std::string const& val)
- {
- out.append(val);
- return out;
- }
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_COLLECTOR_HPP
-

Deleted: trunk/tools/quickbook/detail/input_path.cpp
==============================================================================
--- trunk/tools/quickbook/detail/input_path.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,105 +0,0 @@
-/*=============================================================================
- Copyright (c) 2009 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 <boost/program_options.hpp>
-#include "./input_path.hpp"
-
-#if !(defined(__cygwin__) || defined(__CYGWIN__))
-
-// Everything but cygwin
-
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& values,
- input_path*, int)
- {
- std::string path
- = boost::program_options::validators::get_single_string(values);
-
- v = input_path(path);
- }
-}}
-
-#elif defined(QUICKBOOK_CYGWIN_1_5)
-
-// Cygwin 1.5.x
-
-#include <boost/filesystem/v2/config.hpp>
-#include <windows.h>
-#include <sys/cygwin.h>
-
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& values,
- input_path*, int)
- {
- std::string path
- = boost::program_options::validators::get_single_string(values);
-
- char result[MAX_PATH + 1];
-
-#if defined(BOOST_WINDOWS_PATH)
- cygwin_conv_to_win32_path(path.c_str(), result);
-#elif defined(BOOST_POSIX_PATH)
- cygwin_conv_to_posix_path(path.c_str(), result);
-#else
-# error "Boost filesystem path type doesn't seem to be set."
-#endif
-
- v = input_path(result);
- }
-}}
-
-#else
-
-// Cygwin 1.7.x
-
-#include <boost/filesystem/v2/config.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/program_options/errors.hpp>
-#include <windows.h>
-#include <sys/cygwin.h>
-
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& values,
- input_path*, int)
- {
- std::string path
- = boost::program_options::validators::get_single_string(values);
-
-#if defined(BOOST_WINDOWS_PATH)
- cygwin_conv_path_t flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
-#elif defined(BOOST_POSIX_PATH)
- cygwin_conv_path_t flags = CCP_WIN_A_TO_POSIX | CCP_RELATIVE;
-#else
-# error "Boost filesystem path type doesn't seem to be set."
-#endif
-
- ssize_t size = cygwin_conv_path(flags, path.c_str(), NULL, 0);
-
- if (size < 0) {
- throw boost::program_options::validation_error(
- boost::program_options::validation_error::invalid_option_value);
- }
-
- boost::scoped_array<char> result(new char[size]);
-
- if(cygwin_conv_path(flags, path.c_str(), result.get(), size)) {
- throw boost::program_options::validation_error(
- boost::program_options::validation_error::invalid_option_value);
- }
-
- v = input_path(result.get());
- }
-}}
-
-#endif

Deleted: trunk/tools/quickbook/detail/input_path.hpp
==============================================================================
--- trunk/tools/quickbook/detail/input_path.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,39 +0,0 @@
-/*=============================================================================
- Copyright (c) 2009 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_DETAIL_INPUT_PATH_HPP)
-#define BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP
-
-#include <vector>
-#include <boost/any.hpp>
-#include <string>
-
-namespace quickbook { namespace detail
-{
- // Use this class with Boost.Program Options to convert paths to the format
- // the Boost.Filesystem expects. This is needed on cygwin to convert cygwin
- // paths to windows paths (or vice versa, depending on how filesystem is set
- // up).
- //
- // Note that we don't want to convert paths in quickbook files, as they
- // should be platform independent, and aren't necessarily relative to the
- // current directory.
-
- class input_path {
- std::string path_;
- public:
- explicit input_path(char const* c) : path_(c) {}
- explicit input_path(std::string const& c) : path_(c) {}
- operator std::string() const { return path_; }
-
- friend void validate(boost::any&, const std::vector<std::string>&,
- input_path*, int);
- };
-}}
-
-#endif

Deleted: trunk/tools/quickbook/detail/markups.cpp
==============================================================================
--- trunk/tools/quickbook/detail/markups.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,101 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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 "./markups.hpp"
-
-namespace quickbook
-{
- const char* comment_pre = "<!--";
- const char* comment_post = "-->";
- const char* paragraph_pre = "<para>\n";
- const char* paragraph_post = "</para>\n";
- const char* h1_pre = "<bridgehead renderas=\"sect1\">";
- const char* h1_post = "</bridgehead>";
- const char* h2_pre = "<bridgehead renderas=\"sect2\">";
- const char* h2_post = "</bridgehead>";
- const char* h3_pre = "<bridgehead renderas=\"sect3\">";
- const char* h3_post = "</bridgehead>";
- const char* h4_pre = "<bridgehead renderas=\"sect4\">";
- const char* h4_post = "</bridgehead>";
- const char* h5_pre = "<bridgehead renderas=\"sect5\">";
- const char* h5_post = "</bridgehead>";
- const char* h6_pre = "<bridgehead renderas=\"sect6\">";
- const char* h6_post = "</bridgehead>";
- const char* hr_ = "<para/>";
- const char* blurb_pre = "<sidebar role=\"blurb\">\n";
- const char* blurb_post = "</sidebar>\n";
- const char* blockquote_pre = "<blockquote>";
- const char* blockquote_post = "</blockquote>";
- const char* preformatted_pre = "<programlisting>";
- const char* preformatted_post = "</programlisting>";
- const char* warning_pre = "<warning>";
- const char* warning_post = "</warning>";
- const char* caution_pre = "<caution>";
- const char* caution_post = "</caution>";
- const char* important_pre = "<important>";
- const char* important_post = "</important>";
- const char* note_pre = "<note>";
- const char* note_post = "</note>";
- const char* tip_pre = "<tip>";
- const char* tip_post = "</tip>";
- const char* list_item_pre = "<listitem><simpara>\n";
- const char* list_item_post = "\n</simpara></listitem>";
- const char* bold_pre_ = "<emphasis role=\"bold\">";
- const char* bold_post_ = "</emphasis>";
- const char* italic_pre_ = "<emphasis>";
- const char* italic_post_ = "</emphasis>";
- const char* underline_pre_ = "<emphasis role=\"underline\">";
- const char* underline_post_ = "</emphasis>";
- const char* teletype_pre_ = "<literal>";
- const char* teletype_post_ = "</literal>";
- const char* strikethrough_pre_ = "<emphasis role=\"strikethrough\">";
- const char* strikethrough_post_ = "</emphasis>";
- const char* quote_pre_ = "<quote>";
- const char* quote_post_ = "</quote>";
- const char* break_mark = "<sbr/>\n";
- const char* url_pre_ = "<ulink url=\"";
- const char* url_post_ = "</ulink>";
- const char* link_pre_ = "<link linkend=\"";
- const char* link_post_ = "</link>";
- const char* start_varlistentry_ = "<varlistentry>";
- const char* end_varlistentry_ = "</varlistentry>\n";
- const char* start_varlistterm_ = "<term>";
- const char* end_varlistterm_ = "</term>";
- const char* start_varlistitem_ = "<listitem>";
- const char* end_varlistitem_ = "</listitem>";
- const char* start_header_ = "<thead>";
- const char* end_header_ = "</thead>\n";
- const char* start_row_ = "<row>";
- const char* end_row_ = "</row>\n";
- const char* start_cell_ = "<entry>";
- const char* end_cell_ = "</entry>";
- const char* funcref_pre_ = "<functionname alt=\"";
- const char* funcref_post_ = "</functionname>";
- const char* classref_pre_ = "<classname alt=\"";
- const char* classref_post_ = "</classname>";
- const char* memberref_pre_ = "<methodname alt=\"";
- const char* memberref_post_ = "</methodname>";
- const char* enumref_pre_ = "<enumname alt=\"";
- const char* enumref_post_ = "</enumname>";
- const char* macroref_pre_ = "<macroname alt=\"";
- const char* macroref_post_ = "</macroname>";
- const char* headerref_pre_ = "<headername alt=\"";
- const char* headerref_post_ = "</headername>";
- const char* conceptref_pre_ = "<conceptname alt=\"";
- const char* conceptref_post_ = "</conceptname>";
- const char* globalref_pre_ = "<globalname alt=\"";
- const char* globalref_post_ = "</globalname>";
- const char* footnote_pre_ = "<footnote><para>";
- const char* footnote_post_ = "</para></footnote>";
- const char* escape_pre_ = "<!--quickbook-escape-prefix-->";
- const char* escape_post_ = "<!--quickbook-escape-postfix-->";
- const char* replaceable_pre_ = "<replaceable>";
- const char* replaceable_post_ = "</replaceable>";
-}

Deleted: trunk/tools/quickbook/detail/markups.hpp
==============================================================================
--- trunk/tools/quickbook/detail/markups.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,104 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_MARKUPS_HPP)
-#define BOOST_SPIRIT_MARKUPS_HPP
-
-namespace quickbook
-{
- extern const char* comment_pre;
- extern const char* comment_post;
- extern const char* paragraph_pre;
- extern const char* paragraph_post;
- extern const char* h1_pre;
- extern const char* h1_post;
- extern const char* h2_pre;
- extern const char* h2_post;
- extern const char* h3_pre;
- extern const char* h3_post;
- extern const char* h4_pre;
- extern const char* h4_post;
- extern const char* h5_pre;
- extern const char* h5_post;
- extern const char* h6_pre;
- extern const char* h6_post;
- extern const char* hr_;
- extern const char* blurb_pre;
- extern const char* blurb_post;
- extern const char* blockquote_pre;
- extern const char* blockquote_post;
- extern const char* preformatted_pre;
- extern const char* preformatted_post;
- extern const char* warning_pre;
- extern const char* warning_post;
- extern const char* caution_pre;
- extern const char* caution_post;
- extern const char* important_pre;
- extern const char* important_post;
- extern const char* note_pre;
- extern const char* note_post;
- extern const char* tip_pre;
- extern const char* tip_post;
- extern const char* list_item_pre;
- extern const char* list_item_post;
- extern const char* bold_pre_;
- extern const char* bold_post_;
- extern const char* italic_pre_;
- extern const char* italic_post_;
- extern const char* underline_pre_;
- extern const char* underline_post_;
- extern const char* teletype_pre_;
- extern const char* teletype_post_;
- extern const char* strikethrough_pre_;
- extern const char* strikethrough_post_;
- extern const char* quote_pre_;
- extern const char* quote_post_;
- extern const char* break_mark;
- extern const char* url_pre_;
- extern const char* url_post_;
- extern const char* link_pre_;
- extern const char* link_post_;
- extern const char* start_varlistentry_;
- extern const char* end_varlistentry_;
- extern const char* start_varlistterm_;
- extern const char* end_varlistterm_;
- extern const char* start_varlistitem_;
- extern const char* end_varlistitem_;
- extern const char* start_header_;
- extern const char* end_header_;
- extern const char* start_row_;
- extern const char* end_row_;
- extern const char* start_cell_;
- extern const char* end_cell_;
- extern const char* funcref_pre_;
- extern const char* funcref_post_;
- extern const char* classref_pre_;
- extern const char* classref_post_;
- extern const char* memberref_pre_;
- extern const char* memberref_post_;
- extern const char* enumref_pre_;
- extern const char* enumref_post_;
- extern const char* macroref_pre_;
- extern const char* macroref_post_;
- extern const char* headerref_pre_;
- extern const char* headerref_post_;
- extern const char* conceptref_pre_;
- extern const char* conceptref_post_;
- extern const char* globalref_pre_;
- extern const char* globalref_post_;
- extern const char* footnote_pre_;
- extern const char* footnote_post_;
- extern const char* escape_pre_;
- extern const char* escape_post_;
- extern const char* replaceable_pre_;
- extern const char* replaceable_post_;
-}
-
-#endif // BOOST_SPIRIT_MARKUPS_HPP
-

Deleted: trunk/tools/quickbook/detail/post_process.cpp
==============================================================================
--- trunk/tools/quickbook/detail/post_process.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,466 +0,0 @@
-/*=============================================================================
- Copyright (c) 2005 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- 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 "./post_process.hpp"
-#include "./utils.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/bind.hpp>
-#include <set>
-#include <stack>
-#include <cctype>
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
- using boost::bind;
- typedef std::string::const_iterator iter_type;
-
- struct printer
- {
- printer(std::string& out, int& current_indent, int linewidth)
- : prev(0), out(out), current_indent(current_indent) , column(0)
- , in_string(false), linewidth(linewidth) {}
-
- void indent()
- {
- BOOST_ASSERT(current_indent >= 0); // this should not happen!
- for (int i = 0; i < current_indent; ++i)
- out += ' ';
- column = current_indent;
- }
-
- void break_line()
- {
- out.erase(out.find_last_not_of(' ')+1); // trim trailing spaces
- out += '\n';
- indent();
- }
-
- bool line_is_empty() const
- {
- for (iter_type i = out.end()-(column-current_indent); i != out.end(); ++i)
- {
- if (*i != ' ')
- return false;
- }
- return true;
- }
-
- void align_indent()
- {
- // make sure we are at the proper indent position
- if (column != current_indent)
- {
- if (column > current_indent)
- {
- if (line_is_empty())
- {
- // trim just enough trailing spaces down to current_indent position
- out.erase(out.end()-(column-current_indent), out.end());
- column = current_indent;
- }
- else
- {
- // nope, line is not empty. do a hard CR
- break_line();
- }
- }
- else
- {
- // will this happen? (i.e. column <= current_indent)
- while (column != current_indent)
- {
- out += ' ';
- ++column;
- }
- }
- }
- }
-
- void print(char ch)
- {
- // Print a char. Attempt to break the line if we are exceeding
- // the target linewidth. The linewidth is not an absolute limit.
- // There are many cases where a line will exceed the linewidth
- // and there is no way to properly break the line. Preformatted
- // code that exceeds the linewidth are examples. We cannot break
- // preformatted code. We shall not attempt to be very strict with
- // line breaking. What's more important is to have a reproducable
- // output (i.e. processing two logically equivalent xml files
- // results in two lexically equivalent xml files). *** pretty
- // formatting is a secondary goal ***
-
- // Strings will occur only in tag attributes. Normal content
- // will have &quot; instead. We shall deal only with tag
- // attributes here.
- if (ch == '"')
- in_string = !in_string; // don't break strings!
-
- if (!in_string && std::isspace(static_cast<unsigned char>(ch)))
- {
- // we can break spaces if they are not inside strings
- if (!std::isspace(static_cast<unsigned char>(prev)))
- {
- if (column >= linewidth)
- {
- break_line();
- if (column == 0 && ch == ' ')
- {
- ++column;
- out += ' ';
- }
- }
- else
- {
- ++column;
- out += ' ';
- }
- }
- }
- else
- {
- // we can break tag boundaries and stuff after
- // delimiters if they are not inside strings
- // and *only-if* the preceding char is a space
- if (!in_string
- && column >= linewidth
- && (ch == '<' && std::isspace(static_cast<unsigned char>(prev))))
- break_line();
- out += ch;
- ++column;
- }
-
- prev = ch;
- }
-
- void
- print(iter_type f, iter_type l)
- {
- for (iter_type i = f; i != l; ++i)
- print(*i);
- }
-
- void
- print_tag(iter_type f, iter_type l, bool is_flow_tag)
- {
- if (is_flow_tag)
- {
- print(f, l);
- }
- else
- {
- // This is not a flow tag, so, we're going to do a
- // carriage return anyway. Let us remove extra right
- // spaces.
- std::string str(f, l);
- BOOST_ASSERT(f != l); // this should not happen
- iter_type i = str.end();
- while (i != str.begin() && std::isspace(static_cast<unsigned char>(*(i-1))))
- --i;
- print(str.begin(), i);
- }
- }
-
- char prev;
- std::string& out;
- int& current_indent;
- int column;
- bool in_string;
- int linewidth;
- };
-
- char const* block_tags_[] =
- {
- "author"
- , "blockquote"
- , "bridgehead"
- , "callout"
- , "calloutlist"
- , "caution"
- , "copyright"
- , "entry"
- , "important"
- , "informaltable"
- , "itemizedlist"
- , "legalnotice"
- , "listitem"
- , "note"
- , "orderedlist"
- , "para"
- , "row"
- , "section"
- , "simpara"
- , "table"
- , "tbody"
- , "textobject"
- , "tgroup"
- , "thead"
- , "tip"
- , "variablelist"
- , "varlistentry"
- , "warning"
- , "xml"
- , "xi:include"
- };
-
- char const* doc_types_[] =
- {
- "book"
- , "article"
- , "library"
- , "chapter"
- , "part"
- , "appendix"
- , "preface"
- , "qandadiv"
- , "qandaset"
- , "reference"
- , "set"
- };
-
- struct tidy_compiler
- {
- tidy_compiler(std::string& out, int linewidth)
- : out(out), current_indent(0), printer_(out, current_indent, linewidth)
- {
- static int const n_block_tags = sizeof(block_tags_)/sizeof(char const*);
- for (int i = 0; i != n_block_tags; ++i)
- {
- block_tags.insert(block_tags_[i]);
- }
-
- static int const n_doc_types = sizeof(doc_types_)/sizeof(char const*);
- for (int i = 0; i != n_doc_types; ++i)
- {
- block_tags.insert(doc_types_[i]);
- block_tags.insert(doc_types_[i] + std::string("info"));
- block_tags.insert(doc_types_[i] + std::string("purpose"));
- }
- }
-
- bool is_flow_tag(std::string const& tag)
- {
- return block_tags.find(tag) == block_tags.end();
- }
-
- std::set<std::string> block_tags;
- std::stack<std::string> tags;
- std::string& out;
- int current_indent;
- printer printer_;
- std::string current_tag;
- };
-
- struct tidy_grammar : grammar<tidy_grammar>
- {
- tidy_grammar(tidy_compiler& state, int indent)
- : state(state), indent(indent) {}
-
- template <typename Scanner>
- struct definition
- {
- definition(tidy_grammar const& self)
- {
- tag = (lexeme_d[+(alpha_p | '_' | ':')]) [boost::bind(&tidy_grammar::do_tag, &self, _1, _2)];
-
- code =
- "<programlisting>"
- >> *(anychar_p - "</programlisting>")
- >> "</programlisting>"
- ;
-
- // What's the business of lexeme_d['>' >> *space_p]; ?
- // It is there to preserve the space after the tag that is
- // otherwise consumed by the space_p skipper.
-
- escape =
- str_p("<!--quickbook-escape-prefix-->") >>
- (*(anychar_p - str_p("<!--quickbook-escape-postfix-->")))
- [
- boost::bind(&tidy_grammar::do_escape, &self, _1, _2)
- ]
- >> lexeme_d
- [
- str_p("<!--quickbook-escape-postfix-->") >>
- (*space_p)
- [
- boost::bind(&tidy_grammar::do_escape_post, &self, _1, _2)
- ]
- ]
- ;
-
- start_tag = '<' >> tag >> *(anychar_p - '>') >> lexeme_d['>' >> *space_p];
- start_end_tag =
- '<' >> tag >> *(anychar_p - ("/>" | ch_p('>'))) >> lexeme_d["/>" >> *space_p]
- | "<?" >> tag >> *(anychar_p - '?') >> lexeme_d["?>" >> *space_p]
- | "<!--" >> *(anychar_p - "-->") >> lexeme_d["-->" >> *space_p]
- | "<!" >> tag >> *(anychar_p - '>') >> lexeme_d['>' >> *space_p]
- ;
- content = lexeme_d[ +(anychar_p - '<') ];
- end_tag = "</" >> +(anychar_p - '>') >> lexeme_d['>' >> *space_p];
-
- markup =
- escape
- | code [boost::bind(&tidy_grammar::do_code, &self, _1, _2)]
- | start_end_tag [boost::bind(&tidy_grammar::do_start_end_tag, &self, _1, _2)]
- | start_tag [boost::bind(&tidy_grammar::do_start_tag, &self, _1, _2)]
- | end_tag [boost::bind(&tidy_grammar::do_end_tag, &self, _1, _2)]
- | content [boost::bind(&tidy_grammar::do_content, &self, _1, _2)]
- ;
-
- tidy = +markup;
- }
-
- rule<Scanner> const&
- start() { return tidy; }
-
- rule<Scanner> tidy, tag, start_tag, start_end_tag,
- content, end_tag, markup, code, escape;
- };
-
- void do_escape_post(iter_type f, iter_type l) const
- {
- for (iter_type i = f; i != l; ++i)
- state.out += *i;
- }
-
- void do_escape(iter_type f, iter_type l) const
- {
- while (f != l && std::isspace(*f))
- ++f;
- for (iter_type i = f; i != l; ++i)
- state.out += *i;
- }
-
- void do_code(iter_type f, iter_type l) const
- {
- state.out += '\n';
- // print the string taking care of line
- // ending CR/LF platform issues
- for (iter_type i = f; i != l; ++i)
- {
- if (*i == '\n')
- {
- state.out += '\n';
- ++i;
- if (i != l && *i != '\r')
- state.out += *i;
- }
- else if (*i == '\r')
- {
- state.out += '\n';
- ++i;
- if (i != l && *i != '\n')
- state.out += *i;
- }
- else
- {
- state.out += *i;
- }
- }
- state.out += '\n';
- state.printer_.indent();
- }
-
- void do_tag(iter_type f, iter_type l) const
- {
- state.current_tag = std::string(f, l);
- }
-
- void do_start_end_tag(iter_type f, iter_type l) const
- {
- bool is_flow_tag = state.is_flow_tag(state.current_tag);
- if (!is_flow_tag)
- state.printer_.align_indent();
- state.printer_.print_tag(f, l, is_flow_tag);
- if (!is_flow_tag)
- state.printer_.break_line();
- }
-
- void do_start_tag(iter_type f, iter_type l) const
- {
- state.tags.push(state.current_tag);
- bool is_flow_tag = state.is_flow_tag(state.current_tag);
- if (!is_flow_tag)
- state.printer_.align_indent();
- state.printer_.print_tag(f, l, is_flow_tag);
- if (!is_flow_tag)
- {
- state.current_indent += indent;
- state.printer_.break_line();
- }
- }
-
- void do_content(iter_type f, iter_type l) const
- {
- state.printer_.print(f, l);
- }
-
- void do_end_tag(iter_type f, iter_type l) const
- {
- bool is_flow_tag = state.is_flow_tag(state.tags.top());
- if (!is_flow_tag)
- {
- state.current_indent -= indent;
- state.printer_.align_indent();
- }
- state.printer_.print_tag(f, l, is_flow_tag);
- if (!is_flow_tag)
- state.printer_.break_line();
- state.tags.pop();
- }
-
- tidy_compiler& state;
- int indent;
- };
-
- int post_process(
- std::string const& in
- , std::ostream& out
- , int indent
- , int linewidth)
- {
- if (indent == -1)
- indent = 2; // set default to 2
- if (linewidth == -1)
- linewidth = 80; // set default to 80
-
- try
- {
- std::string tidy;
- tidy_compiler state(tidy, linewidth);
- tidy_grammar g(state, indent);
- parse_info<iter_type> r = parse(in.begin(), in.end(), g, space_p);
- if (r.full)
- {
- out << tidy;
- return 0;
- }
- else
- {
- // fallback!
- ::quickbook::detail::outerr("")
- << "Warning: Post Processing Failed."
- << std::endl;
- out << in;
- return 1;
- }
- }
-
- catch(...)
- {
- // fallback!
- ::quickbook::detail::outerr("")
- << "Post Processing Failed."
- << std::endl;
- out << in;
- return 1;
- }
- }
-}
-

Deleted: trunk/tools/quickbook/detail/post_process.hpp
==============================================================================
--- trunk/tools/quickbook/detail/post_process.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,25 +0,0 @@
-/*=============================================================================
- Copyright (c) 2005 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_POST_PROCESS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_POST_PROCESS_HPP
-
-#include <iostream>
-#include <string>
-
-namespace quickbook
-{
- int post_process(
- std::string const& in
- , std::ostream& out
- , int indent
- , int linewidth);
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_POST_PROCESS_HPP
-

Deleted: trunk/tools/quickbook/detail/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/detail/quickbook.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,374 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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 "./quickbook.hpp"
-#include "./actions_class.hpp"
-#include "../block.hpp"
-#include "../doc_info.hpp"
-#include "./post_process.hpp"
-#include "./utils.hpp"
-#include "./input_path.hpp"
-#include <boost/spirit/include/classic_iterator.hpp>
-#include <boost/program_options.hpp>
-#include <boost/filesystem/v2/path.hpp>
-#include <boost/filesystem/v2/operations.hpp>
-#include <boost/ref.hpp>
-
-#include <stdexcept>
-#include <fstream>
-#include <iostream>
-#include <vector>
-
-#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
-#pragma warning(disable:4355)
-#endif
-
-#define QUICKBOOK_VERSION "Quickbook Version 1.5.3"
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
- namespace fs = boost::filesystem;
- tm* current_time; // the current time
- tm* current_gm_time; // the current UTC time
- bool debug_mode; // for quickbook developers only
- int qbk_major_version = -1;
- int qbk_minor_version = -1;
- unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
- bool ms_errors = false; // output errors/warnings as if for VS
- std::vector<std::string> include_path;
- std::vector<std::string> preset_defines;
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // Parse the macros passed as command line parameters
- //
- ///////////////////////////////////////////////////////////////////////////
- struct command_line_grammar
- : public grammar<command_line_grammar>
- {
- command_line_grammar(quickbook::actions& actions)
- : actions(actions) {}
-
- template <typename Scanner>
- struct definition
- {
- definition(command_line_grammar const& self)
- : unused(false), common(self.actions, unused)
- {
- quickbook::actions& actions = self.actions;
-
- macro =
- *space_p
- >> macro_identifier [actions.macro_identifier]
- >> *space_p
- >> ( '='
- >> *space_p
- >> phrase [actions.macro_definition]
- >> *space_p
- )
- | eps_p [actions.macro_definition]
- ;
-
- macro_identifier =
- +(anychar_p - (space_p | ']' | '='))
- ;
-
- phrase =
- *( common
- | (anychar_p - ']') [actions.plain_char]
- )
- ;
- }
-
- bool unused;
- rule<Scanner> macro, macro_identifier, phrase;
- phrase_grammar common;
-
- rule<Scanner> const&
- start() const { return macro; }
- };
-
- quickbook::actions& actions;
- };
-
- static void set_macros(actions& actor)
- {
- quickbook::command_line_grammar grammar(actor);
-
- for(std::vector<std::string>::const_iterator
- it = preset_defines.begin(),
- end = preset_defines.end();
- it != end; ++it)
- {
- typedef position_iterator<std::string::const_iterator> iterator_type;
- iterator_type first(it->begin(), it->end(), "command line parameter");
- iterator_type last(it->end(), it->end());
-
- parse(first, last, grammar);
- // TODO: Check result?
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // Parse a file
- //
- ///////////////////////////////////////////////////////////////////////////
- int
- parse_file(char const* filein_, actions& actor, bool ignore_docinfo)
- {
- using std::cerr;
- using std::vector;
- using std::string;
-
- std::string storage;
- int err = detail::load(filein_, storage);
- if (err != 0) {
- ++actor.error_count;
- return err;
- }
-
- typedef position_iterator<std::string::const_iterator> iterator_type;
- iterator_type first(storage.begin(), storage.end(), filein_);
- iterator_type last(storage.end(), storage.end());
-
- doc_info_grammar l(actor);
- parse_info<iterator_type> info = parse(first, last, l);
-
- if (info.hit || ignore_docinfo)
- {
- pre(actor.out, actor, ignore_docinfo);
-
- block_grammar g(actor);
- info = parse(info.hit ? info.stop : first, last, g);
- if (info.full)
- {
- post(actor.out, actor, ignore_docinfo);
- }
- }
-
- if (!info.full)
- {
- file_position const pos = info.stop.get_position();
- detail::outerr(pos.file,pos.line)
- << "Syntax Error near column " << pos.column << ".\n";
- ++actor.error_count;
- }
-
- return actor.error_count ? 1 : 0;
- }
-
- static int
- parse_document(char const* filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false)
- {
- actions actor(filein_, outdir, out);
- set_macros(actor);
- bool r = parse_file(filein_, actor);
- if (actor.section_level != 0)
- detail::outwarn(filein_)
- << "Warning missing [endsect] detected at end of file."
- << std::endl;
-
- if(actor.error_count)
- {
- detail::outerr(filein_)
- << "Error count: " << actor.error_count << ".\n";
- }
-
- return r;
- }
-
- static int
- parse_document(
- char const* filein_
- , char const* fileout_
- , int indent
- , int linewidth
- , bool pretty_print)
- {
- int result = 0;
- std::ofstream fileout(fileout_);
- fs::path outdir = fs::path(fileout_).parent_path();
- if (outdir.empty())
- outdir = ".";
- if (pretty_print)
- {
- string_stream buffer;
- result = parse_document(filein_, outdir, buffer);
- if (result == 0)
- {
- result = post_process(buffer.str(), fileout, indent, linewidth);
- }
- }
- else
- {
- string_stream buffer;
- result = parse_document(filein_, outdir, buffer);
- fileout << buffer.str();
- }
- return result;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////
-//
-// Main program
-//
-///////////////////////////////////////////////////////////////////////////
-int
-main(int argc, char* argv[])
-{
- try
- {
- using boost::program_options::options_description;
- using boost::program_options::variables_map;
- using boost::program_options::store;
- using boost::program_options::parse_command_line;
- using boost::program_options::command_line_parser;
- using boost::program_options::notify;
- using boost::program_options::value;
- using boost::program_options::positional_options_description;
-
- // First thing, the filesystem should record the current working directory.
- boost::filesystem::initial_path<boost::filesystem::path>();
-
- options_description desc("Allowed options");
- desc.add_options()
- ("help", "produce help message")
- ("version", "print version string")
- ("no-pretty-print", "disable XML pretty printing")
- ("indent", value<int>(), "indent spaces")
- ("linewidth", value<int>(), "line width")
- ("input-file", value<quickbook::detail::input_path>(), "input file")
- ("output-file", value<quickbook::detail::input_path>(), "output file")
- ("debug", "debug mode (for developers)")
- ("ms-errors", "use Microsoft Visual Studio style error & warn message format")
- ("include-path,I", value< std::vector<quickbook::detail::input_path> >(), "include path")
- ("define,D", value< std::vector<std::string> >(), "define macro")
- ;
-
- positional_options_description p;
- p.add("input-file", -1);
-
- variables_map vm;
- int indent = -1;
- int linewidth = -1;
- bool pretty_print = true;
- store(command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
- notify(vm);
-
- if (vm.count("help"))
- {
- std::cout << desc << "\n";
- return 0;
- }
-
- if (vm.count("version"))
- {
- std::cout << QUICKBOOK_VERSION << std::endl;
- return 0;
- }
-
- if (vm.count("ms-errors"))
- quickbook::ms_errors = true;
-
- if (vm.count("no-pretty-print"))
- pretty_print = false;
-
- if (vm.count("indent"))
- indent = vm["indent"].as<int>();
-
- if (vm.count("linewidth"))
- linewidth = vm["linewidth"].as<int>();
-
- if (vm.count("debug"))
- {
- static tm timeinfo;
- timeinfo.tm_year = 2000 - 1900;
- timeinfo.tm_mon = 12 - 1;
- timeinfo.tm_mday = 20;
- timeinfo.tm_hour = 12;
- timeinfo.tm_min = 0;
- timeinfo.tm_sec = 0;
- timeinfo.tm_isdst = -1;
- mktime(&timeinfo);
- quickbook::current_time = &timeinfo;
- quickbook::current_gm_time = &timeinfo;
- quickbook::debug_mode = true;
- }
- else
- {
- time_t t = std::time(0);
- static tm lt = *localtime(&t);
- static tm gmt = *gmtime(&t);
- quickbook::current_time = &lt;
- quickbook::current_gm_time = &gmt;
- quickbook::debug_mode = false;
- }
-
- if (vm.count("include-path"))
- {
- std::vector<quickbook::detail::input_path> paths
- = vm["include-path"].as<
- std::vector<quickbook::detail::input_path> >();
- quickbook::include_path
- = std::vector<std::string>(paths.begin(), paths.end());
- }
-
- if (vm.count("define"))
- {
- quickbook::preset_defines
- = vm["define"].as<std::vector<std::string> >();
- }
-
- if (vm.count("input-file"))
- {
- std::string filein
- = vm["input-file"].as<quickbook::detail::input_path>();
- std::string fileout;
-
- if (vm.count("output-file"))
- {
- fileout = vm["output-file"].as<quickbook::detail::input_path>();
- }
- else
- {
- fileout = quickbook::detail::remove_extension(filein.c_str());
- fileout += ".xml";
- }
-
- std::cout << "Generating Output File: "
- << fileout
- << std::endl;
-
- return quickbook::parse_document(filein.c_str(), fileout.c_str(), indent, linewidth, pretty_print);
- }
- else
- {
- quickbook::detail::outerr("") << "Error: No filename given\n\n"
- << desc << std::endl;
- return 1;
- }
- }
-
- catch(std::exception& e)
- {
- quickbook::detail::outerr("") << "Error: " << e.what() << "\n";
- return 1;
- }
-
- catch(...)
- {
- quickbook::detail::outerr("") << "Error: Exception of unknown type caught\n";
- return 1;
- }
-
- return 0;
-}

Deleted: trunk/tools/quickbook/detail/quickbook.hpp
==============================================================================
--- trunk/tools/quickbook/detail/quickbook.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,47 +0,0 @@
-/*=============================================================================
- Copyright (c) 2009 Daniel James
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_QUICKBOOK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_QUICKBOOK_HPP
-
-namespace quickbook
-{
- extern int qbk_major_version;
- extern int qbk_minor_version;
- extern unsigned qbk_version_n; // qbk_major_version * 100 + qbk_minor_version
-
- struct quickbook_range {
- template <typename Arg>
- struct result
- {
- typedef bool type;
- };
-
- quickbook_range(unsigned min_, unsigned max_)
- : min_(min_), max_(max_) {}
-
- bool operator()() const {
- return qbk_version_n >= min_ && qbk_version_n < max_;
- }
-
- unsigned min_, max_;
- };
-
- inline quickbook_range qbk_since(unsigned min_) {
- return quickbook_range(min_, 999);
- }
-
- inline quickbook_range qbk_before(unsigned max_) {
- return quickbook_range(0, max_);
- }
-}
-
-#endif

Deleted: trunk/tools/quickbook/detail/syntax_highlight.cpp
==============================================================================
--- trunk/tools/quickbook/detail/syntax_highlight.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,74 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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 "../syntax_highlight.hpp"
-#include "./actions_class.hpp"
-
-namespace quickbook
-{
- typedef cpp_highlight<
- span
- , space
- , string_symbols
- , do_macro_action
- , pre_escape_back
- , post_escape_back
- , unexpected_char
- , collector>
- cpp_p_type;
-
- typedef python_highlight<
- span
- , space
- , string_symbols
- , do_macro_action
- , pre_escape_back
- , post_escape_back
- , unexpected_char
- , collector>
- python_p_type;
-
- typedef teletype_highlight<
- plain_char_action
- , string_symbols
- , do_macro_action
- , pre_escape_back
- , post_escape_back
- , collector>
- teletype_p_type;
-
- std::string syntax_highlight::operator()(iterator first, iterator last) const
- {
- // print the code with syntax coloring
- if (source_mode == "c++")
- {
- cpp_p_type cpp_p(temp, macro, do_macro_action(temp), escape_actions);
- parse(first, last, cpp_p);
- }
- else if (source_mode == "python")
- {
- python_p_type python_p(temp, macro, do_macro_action(temp), escape_actions);
- parse(first, last, python_p);
- }
- else if (source_mode == "teletype")
- {
- teletype_p_type teletype_p(temp, macro, do_macro_action(temp), escape_actions);
- parse(first, last, teletype_p);
- }
- else
- {
- BOOST_ASSERT(0);
- }
-
- std::string str;
- temp.swap(str);
-
- return str;
- }
-}
\ No newline at end of file

Deleted: trunk/tools/quickbook/detail/template_stack.cpp
==============================================================================
--- trunk/tools/quickbook/detail/template_stack.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,85 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- 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 "./template_stack.hpp"
-
-#ifdef BOOST_MSVC
-#pragma warning(disable : 4355)
-#endif
-
-namespace quickbook
-{
- template_stack::template_stack()
- : scope(template_stack::parser(*this))
- , scopes()
- {
- scopes.push_front(template_scope());
- }
-
- template_symbol* template_stack::find(std::string const& symbol) const
- {
- for (template_scope const* i = &*scopes.begin(); i; i = i->parent_scope)
- {
- if (template_symbol* ts = boost::spirit::classic::find(i->symbols, symbol.c_str()))
- return ts;
- }
- return 0;
- }
-
- template_symbol* template_stack::find_top_scope(std::string const& symbol) const
- {
- return boost::spirit::classic::find(scopes.front().symbols, symbol.c_str());
- }
-
- template_symbols const& template_stack::top() const
- {
- BOOST_ASSERT(!scopes.empty());
- return scopes.front().symbols;
- }
-
- template_scope const& template_stack::top_scope() const
- {
- BOOST_ASSERT(!scopes.empty());
- return scopes.front();
- }
-
- // TODO: Should symbols defined by '[import]' use the current scope?
- bool template_stack::add(template_symbol const& ts)
- {
- BOOST_ASSERT(!scopes.empty());
- BOOST_ASSERT(ts.parent);
-
- if (this->find_top_scope(ts.identifier)) {
- return false;
- }
-
- boost::spirit::classic::add(scopes.front().symbols,
- ts.identifier.c_str(), ts);
-
- return true;
- }
-
- void template_stack::push()
- {
- template_scope const& old_front = scopes.front();
- scopes.push_front(template_scope());
- set_parent_scope(old_front);
- }
-
- void template_stack::pop()
- {
- scopes.pop_front();
- }
-
- void template_stack::set_parent_scope(template_scope const& parent)
- {
- scopes.front().parent_scope = &parent;
- }
-}
-
-

Deleted: trunk/tools/quickbook/detail/template_stack.hpp
==============================================================================
--- trunk/tools/quickbook/detail/template_stack.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,150 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_TEMPLATE_STACK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_TEMPLATE_STACK_HPP
-
-#include <string>
-#include <deque>
-#include <vector>
-#include <boost/tuple/tuple.hpp>
-#include <boost/assert.hpp>
-#include <boost/spirit/include/classic_position_iterator.hpp>
-#include <boost/spirit/include/classic_functor_parser.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
-#include <boost/next_prior.hpp>
-
-namespace quickbook
-{
- struct template_body
- {
- template_body(
- std::string const& content,
- boost::spirit::classic::file_position position,
- bool is_block
- )
- : content(content)
- , position(position)
- , is_block(is_block)
- {
- }
-
- std::string content;
- boost::spirit::classic::file_position position;
- bool is_block;
- };
-
- struct template_scope;
-
- struct template_symbol
- {
- template_symbol(
- std::string const& identifier,
- std::vector<std::string> const& params,
- std::string const& body,
- boost::spirit::classic::file_position const& position,
- bool is_block,
- template_scope const* parent = 0)
- : identifier(identifier)
- , params(params)
- , body(body, position, is_block)
- , parent(parent)
- , callout(false)
- , callouts() {}
-
- std::string identifier;
- std::vector<std::string> params;
- template_body body;
-
- // This is only used for quickbook 1.5+, 1.4 uses the dynamic scope.
- // TODO: I should probably call this something like lexical_parent
- // or static_parent for clarity.
- template_scope const* parent;
-
- bool callout;
- std::vector<template_body> callouts;
- };
-
- typedef boost::spirit::classic::symbols<template_symbol> template_symbols;
-
- // template scope
- //
- // 1.4-: parent_scope is the previous scope on the stack
- // (the template's dynamic parent).
- // 1.5+: parent_scope is the template's lexical parent.
- //
- // This means that a search along the parent_scope chain will follow the
- // correct lookup chain for that version of quickboook.
- //
- // symbols contains the templates defined in this scope.
-
- struct template_scope
- {
- template_scope() : parent_scope() {}
- template_scope const* parent_scope;
- template_symbols symbols;
- };
-
- struct template_stack
- {
- typedef std::deque<template_scope> deque;
-
- struct parser
- {
- typedef boost::spirit::classic::nil_t result_t;
-
- parser(template_stack& ts)
- : ts(ts) {}
-
- template <typename Scanner>
- std::ptrdiff_t
- operator()(Scanner const& scan, result_t) const
- {
- // search all scopes for the longest matching symbol.
- typename Scanner::iterator_t f = scan.first;
- std::ptrdiff_t len = -1;
- for (template_scope const* i = &*ts.scopes.begin(); i; i = i->parent_scope)
- {
- boost::spirit::classic::match<> m = i->symbols.parse(scan);
- if (m.length() > len)
- len = m.length();
- scan.first = f;
- }
- if (len >= 0)
- scan.first = boost::next(f, len);
- return len;
- }
-
- template_stack& ts;
- };
-
- template_stack();
- template_symbol* find(std::string const& symbol) const;
- template_symbol* find_top_scope(std::string const& symbol) const;
- template_symbols const& top() const;
- template_scope const& top_scope() const;
- // Add the given template symbol to the current scope.
- // If it doesn't have a scope, sets the symbol's scope to the current scope.
- bool add(template_symbol const&);
- void push();
- void pop();
-
- // Set the current scope's parent.
- void set_parent_scope(template_scope const&);
-
- boost::spirit::classic::functor_parser<parser> scope;
-
- private:
-
- friend struct parser;
- deque scopes;
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_TEMPLATE_STACK_HPP
-

Deleted: trunk/tools/quickbook/detail/utils.cpp
==============================================================================
--- trunk/tools/quickbook/detail/utils.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,321 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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 "./utils.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-
-#include <cctype>
-#include <cstring>
-#include <stdexcept>
-#include <fstream>
-#include <iostream>
-#include <map>
-
-namespace quickbook {
- extern bool ms_errors;
-}
-
-namespace quickbook { namespace detail
-{
- void print_char(char ch, std::ostream& out)
- {
- switch (ch)
- {
- case '<': out << "&lt;"; break;
- case '>': out << "&gt;"; break;
- case '&': out << "&amp;"; break;
- case '"': out << "&quot;"; break;
- default: out << ch; break;
- // note &apos; is not included. see the curse of apos:
- // http://fishbowl.pastiche.org/2003/07/01/the_curse_of_apos
- }
- }
-
- void print_string(std::basic_string<char> const& str, std::ostream& out)
- {
- for (std::string::const_iterator cur = str.begin();
- cur != str.end(); ++cur)
- {
- print_char(*cur, out);
- }
- }
-
- void print_space(char ch, std::ostream& out)
- {
- out << ch;
- }
-
- char filter_identifier_char(char ch)
- {
- if (!std::isalnum(static_cast<unsigned char>(ch)))
- ch = '_';
- return static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
- }
-
- // un-indent a code segment
- void unindent(std::string& program)
- {
- // Erase leading blank lines and newlines:
- std::string::size_type start = program.find_first_not_of(" \t");
- if (start != std::string::npos &&
- (program[start] == '\r' || program[start] == '\n'))
- {
- program.erase(0, start);
- }
- start = program.find_first_not_of("\r\n");
- program.erase(0, start);
-
- if (program.size() == 0)
- return; // nothing left to do
-
- // Get the first line indent
- std::string::size_type indent = program.find_first_not_of(" \t");
- std::string::size_type pos = 0;
- if (std::string::npos == indent)
- {
- // Nothing left to do here. The code is empty (just spaces).
- // We clear the program to signal the caller that it is empty
- // and return early.
- program.clear();
- return;
- }
-
- // Calculate the minimum indent from the rest of the lines
- do
- {
- pos = program.find_first_not_of("\r\n", pos);
- if (std::string::npos == pos)
- break;
-
- std::string::size_type n = program.find_first_not_of(" \t", pos);
- if (n != std::string::npos)
- {
- char ch = program[n];
- if (ch != '\r' && ch != '\n') // ignore empty lines
- indent = (std::min)(indent, n-pos);
- }
- }
- while (std::string::npos != (pos = program.find_first_of("\r\n", pos)));
-
- // Trim white spaces from column 0..indent
- pos = 0;
- program.erase(0, indent);
- while (std::string::npos != (pos = program.find_first_of("\r\n", pos)))
- {
- if (std::string::npos == (pos = program.find_first_not_of("\r\n", pos)))
- {
- break;
- }
-
- std::string::size_type next = program.find_first_of("\r\n", pos);
- program.erase(pos, (std::min)(indent, next-pos));
- }
- }
-
- // remove the extension from a filename
- std::string
- remove_extension(std::string const& filename)
- {
- std::string::size_type const n = filename.find_last_of('.');
- if(std::string::npos == n)
- {
- return filename;
- }
- else
- {
- return std::string(filename.begin(), filename.begin()+n);
- }
- }
-
- std::string escape_uri(std::string uri)
- {
- for (std::string::size_type n = 0; n < uri.size(); ++n)
- {
- static char const mark[] = "-_.!~*'()?\\/";
- if((!std::isalnum(static_cast<unsigned char>(uri[n])) || 127 < static_cast<unsigned char>(uri[n]))
- && 0 == std::strchr(mark, uri[n]))
- {
- static char const hex[] = "0123456789abcdef";
- char escape[] = { hex[uri[n] / 16], hex[uri[n] % 16] };
- uri.insert(n + 1, escape, 2);
- uri[n] = '%';
- n += 2;
- }
- }
- return uri;
- }
-
- std::ostream& outerr(std::string const& file, int line)
- {
- if (line >= 0)
- {
- if (ms_errors)
- return std::clog << file << "(" << line << "): error: ";
- else
- return std::clog << file << ":" << line << ": error: ";
- }
- else
- {
- return std::clog << file << ": error: ";
- }
- }
-
- std::ostream& outwarn(std::string const& file, int line)
- {
- if (line >= 0)
- {
- if (ms_errors)
- return std::clog << file << "(" << line << "): warning: ";
- else
- return std::clog << file << ":" << line << ": warning: ";
- }
- else
- {
- return std::clog << file << ": warning: ";
- }
- }
-
- // Read the first few bytes in a file to see it starts with a byte order
- // mark. If it doesn't, then write the characters we've already read in.
- // Although, given how UTF-8 works, if we've read anything in, the files
- // probably broken.
-
- template <class InputIterator, class OutputIterator>
- bool check_bom(InputIterator& begin, InputIterator end,
- OutputIterator out, char const* chars, int length)
- {
- char const* ptr = chars;
-
- while(begin != end && *begin == *ptr) {
- ++begin;
- ++ptr;
- --length;
- if(length == 0) return true;
- }
-
- // Failed to match, so write the skipped characters to storage:
- while(chars != ptr) *out++ = *chars++;
-
- return false;
- }
-
- template <class InputIterator, class OutputIterator>
- std::string read_bom(InputIterator& begin, InputIterator end,
- OutputIterator out)
- {
- if(begin == end) return "";
-
- const char* utf8 = "\xef\xbb\xbf" ;
- const char* utf32be = "\0\0\xfe\xff";
- const char* utf32le = "\xff\xfe\0\0";
-
- unsigned char c = *begin;
- switch(c)
- {
- case 0xEF: { // UTF-8
- return check_bom(begin, end, out, utf8, 3) ? "UTF-8" : "";
- }
- case 0xFF: // UTF-16/UTF-32 little endian
- return !check_bom(begin, end, out, utf32le, 2) ? "" :
- check_bom(begin, end, out, utf32le + 2, 2) ? "UTF-32" : "UTF-16";
- case 0: // UTF-32 big endian
- return check_bom(begin, end, out, utf32be, 4) ? "UTF-32" : "";
- case 0xFE: // UTF-16 big endian
- return check_bom(begin, end, out, utf32be + 2, 2) ? "UTF-16" : "";
- default:
- return "";
- }
- }
-
- // Copy a string, converting mac and windows style newlines to unix
- // newlines.
-
- template <class InputIterator, class OutputIterator>
- bool normalize(InputIterator begin, InputIterator end,
- OutputIterator out, std::string const& filename)
- {
- std::string encoding = read_bom(begin, end, out);
-
- if(encoding != "UTF-8" && encoding != "") {
- outerr(filename) << encoding << " is not supported. Please use UTF-8."
- << std::endl;
-
- return false;
- }
-
- while(begin != end) {
- if(*begin == '\r') {
- *out++ = '\n';
- ++begin;
- if(begin != end && *begin == '\n') ++begin;
- }
- else {
- *out++ = *begin++;
- }
- }
-
- return true;
- }
-
- int load(std::string const& filename, std::string& storage)
- {
- using std::cerr;
- using std::endl;
- using std::ios;
- using std::ifstream;
- using std::istream_iterator;
-
- ifstream in(filename.c_str(), std::ios_base::in);
-
- if (!in)
- {
- outerr(filename) << "Could not open input file." << endl;
- return 1;
- }
-
- // Turn off white space skipping on the stream
- in.unsetf(ios::skipws);
-
- if(!normalize(
- istream_iterator<char>(in),
- istream_iterator<char>(),
- std::back_inserter(storage),
- filename))
- {
- return 1;
- }
-
- // ensure that we have enough trailing newlines to eliminate
- // the need to check for end of file in the grammar.
- storage.push_back('\n');
- storage.push_back('\n');
- return 0;
- }
-
- file_type get_file_type(std::string const& extension)
- {
- static std::map<std::string, file_type> ftypes;
- if (ftypes.empty())
- {
- // init the map of types
- ftypes["cpp"] = cpp_file;
- ftypes["hpp"] = cpp_file;
- ftypes["h"] = cpp_file;
- ftypes["c"] = cpp_file;
- ftypes["cxx"] = cpp_file;
- ftypes["hxx"] = cpp_file;
- ftypes["ipp"] = cpp_file;
- ftypes["py"] = python_file;
- }
- return ftypes[extension];
- }
-
-}}
-
-

Deleted: trunk/tools/quickbook/detail/utils.hpp
==============================================================================
--- trunk/tools/quickbook/detail/utils.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,86 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_UTILS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_UTILS_HPP
-
-#include <string>
-#include <iostream>
-#include <cctype>
-#include <boost/ref.hpp>
-#include <boost/assert.hpp>
-
-namespace quickbook { namespace detail
-{
- void print_char(char ch, std::ostream& out);
- void print_string(std::basic_string<char> const& str, std::ostream& out);
- void print_space(char ch, std::ostream& out);
- char filter_identifier_char(char ch);
-
- template <typename Iterator>
- inline std::string
- make_identifier(Iterator const& first, Iterator const& last)
- {
- std::string out_name;
- for (Iterator i = first; i != last; ++i)
- out_name += filter_identifier_char(*i);
- return out_name;
- }
-
- template <typename T>
- struct var_wrapper
- : public ::boost::reference_wrapper<T>
- {
- typedef ::boost::reference_wrapper<T> parent;
-
- explicit inline var_wrapper(T& t) : parent(t) {}
-
- inline T& operator()() const { return parent::get(); }
- };
-
- template <typename T>
- inline var_wrapper<T>
- var(T& t)
- {
- return var_wrapper<T>(t);
- }
-
- // un-indent a code segment
- void unindent(std::string& program);
-
- // remove the extension from a filename
- std::string remove_extension(std::string const& filename);
-
- std::string escape_uri(std::string uri);
-
- // Preformats an error/warning message so that it can be parsed by
- // common IDEs. Uses the ms_errors global to determine if VS format
- // or GCC format. Returns the stream to continue ouput of the verbose
- // error message.
- std::ostream & outerr(std::string const& file, int line = -1);
- std::ostream & outwarn(std::string const& file, int line = -1);
-
- // load file into memory with extra trailing newlines to eliminate
- // the need to check for end of file in the grammar.
- int load(std::string const& filename, std::string& storage);
-
- // given a file extension, return the type of the source file
- // we'll have an internal database for known file types.
-
- enum file_type
- {
- cpp_file
- , python_file
- };
-
- file_type get_file_type(std::string const& extension);
-}}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_UTILS_HPP
-

Deleted: trunk/tools/quickbook/doc_info.hpp
==============================================================================
--- trunk/tools/quickbook/doc_info.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,216 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_DOC_INFO_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
-
-#include "./phrase.hpp"
-#include "./detail/quickbook.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_actor.hpp>
-#include <boost/spirit/include/classic_loops.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
-
- struct doc_info_grammar
- : public grammar<doc_info_grammar>
- {
- doc_info_grammar(quickbook::actions& actions)
- : actions(actions) {}
-
- template <typename Scanner>
- struct definition
- {
- typedef uint_parser<int, 10, 1, 2> uint2_t;
-
- definition(doc_info_grammar const& self)
- : unused(false), common(self.actions, unused)
- {
- quickbook::actions& actions = self.actions;
-
- doc_types =
- "book", "article", "library", "chapter", "part"
- , "appendix", "preface", "qandadiv", "qandaset"
- , "reference", "set"
- ;
-
- doc_info =
- space
- >> '[' >> space
- >> (doc_types >> eps_p) [assign_a(actions.doc_type)]
- >> hard_space
- >> ( *(~eps_p(ch_p('[') | ']' | eol_p) >> char_)
- ) [actions.extract_doc_title]
- >> !(
- space >> '[' >>
- quickbook_version
- >> space >> ']'
- )
- >>
- *(
- space >> '[' >>
- (
- doc_version
- | doc_id
- | doc_dirname
- | doc_copyright [push_back_a(actions.doc_copyrights, actions.copyright)]
- | doc_purpose
- | doc_category
- | doc_authors
- | doc_license
- | doc_last_revision
- | doc_source_mode
- )
- >> space >> ']' >> +eol_p
- )
- >> space >> ']' >> +eol_p
- ;
-
- quickbook_version =
- "quickbook" >> hard_space
- >> ( uint_p [assign_a(qbk_major_version)]
- >> '.'
- >> uint2_t() [assign_a(qbk_minor_version)]
- )
- ;
-
- doc_version =
- "version" >> hard_space
- >> (*(~eps_p(']') >> char_)) [actions.extract_doc_version]
- ;
-
- // TODO: Restrictions on doc_id?
- doc_id =
- "id" >> hard_space
- >> (*(~eps_p(']') >> char_)) [actions.extract_doc_id]
- ;
-
- // TODO: Restrictions on doc_dirname?
- doc_dirname =
- "dirname" >> hard_space
- >> (*(~eps_p(']') >> char_)) [actions.extract_doc_dirname]
- ;
-
- doc_copyright =
- "copyright" >> hard_space [clear_a(actions.copyright.first)]
- >> +( repeat_p(4)[digit_p] [push_back_a(actions.copyright.first)]
- >> space
- )
- >> space
- >> (*(~eps_p(']') >> char_)) [actions.extract_copyright_second]
- ;
-
- doc_purpose =
- "purpose" >> hard_space
- >> phrase [actions.extract_doc_purpose]
- ;
-
- doc_category =
- "category" >> hard_space
- >> (*(~eps_p(']') >> char_)) [actions.extract_doc_category]
- [push_back_a(actions.doc_categories, actions.doc_category)]
- ;
-
- doc_author =
- '[' >> space
- >> (*(~eps_p(',') >> char_)) [actions.extract_name_second] // surname
- >> ',' >> space
- >> (*(~eps_p(']') >> char_)) [actions.extract_name_first] // firstname
- >> ']'
- ;
-
- doc_authors =
- "authors"
- >> hard_space
- >> doc_author [push_back_a(actions.doc_authors, actions.name)]
- >> space
- >> *( !(ch_p(',') >> space)
- >> doc_author [push_back_a(actions.doc_authors, actions.name)]
- >> space
- )
- ;
-
- doc_license =
- "license" >> hard_space
- >> phrase [actions.extract_doc_license]
- ;
-
- doc_last_revision =
- "last-revision" >> hard_space
- >> (*(~eps_p(']') >> char_)) [actions.extract_doc_last_revision]
- ;
-
- doc_source_mode =
- "source-mode" >> hard_space
- >> (
- str_p("c++")
- | "python"
- | "teletype"
- ) [assign_a(actions.source_mode)]
- ;
-
- comment =
- "[/" >> *(anychar_p - ']') >> ']'
- ;
-
- space =
- *(space_p | comment)
- ;
-
- hard_space =
- (eps_p - (alnum_p | '_')) >> space // must not be preceded by
- ; // alpha-numeric or underscore
-
- phrase =
- *( common
- | comment
- | (anychar_p - ']') [actions.plain_char]
- )
- ;
-
- char_ =
- str_p("\\n") [actions.break_]
- | "\\ " // ignore an escaped space
- | '\\' >> punct_p [actions.raw_char]
- | "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")]
- [actions.escape_unicode]
- | "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")]
- [actions.escape_unicode]
- | (
- ("'''" >> !eol_p) [actions.escape_pre]
- >> *(anychar_p - "'''") [actions.raw_char]
- >> str_p("'''") [actions.escape_post]
- )
- | anychar_p [actions.plain_char]
- ;
- }
-
- bool unused;
- std::string category;
- rule<Scanner> doc_info, doc_title, doc_version, doc_id, doc_dirname,
- doc_copyright, doc_purpose, doc_category, doc_authors,
- doc_author, comment, space, hard_space, doc_license,
- doc_last_revision, doc_source_mode, phrase, quickbook_version,
- char_;
- phrase_grammar common;
- symbols<> doc_types;
-
- rule<Scanner> const&
- start() const { return doc_info; }
- };
-
- quickbook::actions& actions;
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
-

Deleted: trunk/tools/quickbook/phrase.hpp
==============================================================================
--- trunk/tools/quickbook/phrase.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,539 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_PHRASE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
-
-#include "./detail/quickbook.hpp"
-#include "./detail/actions_class.hpp"
-#include "detail/utils.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/spirit/include/classic_chset.hpp>
-#include <boost/spirit/include/classic_assign_actor.hpp>
-#include <boost/spirit/include/classic_clear_actor.hpp>
-#include <boost/spirit/include/classic_if.hpp>
-#include <boost/spirit/include/classic_loops.hpp>
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
-
- template <typename Rule, typename Action>
- inline void
- simple_markup(
- Rule& simple
- , char mark
- , Action const& action
- , Rule const& close
- )
- {
- simple =
- mark >>
- (
- (
- graph_p // A single char. e.g. *c*
- >> eps_p(mark
- >> (space_p | punct_p | end_p))
- // space_p, punct_p or end_p
- ) // must follow mark
- |
- ( graph_p >> // graph_p must follow mark
- *(anychar_p -
- ( (graph_p >> mark) // Make sure that we don't go
- | close // past a single block
- )
- ) >> graph_p // graph_p must precede mark
- >> eps_p(mark
- >> (space_p | punct_p | end_p))
- // space_p, punct_p or end_p
- ) // must follow mark
- ) [action]
- >> mark
- ;
- }
-
- struct phrase_grammar : grammar<phrase_grammar>
- {
- phrase_grammar(quickbook::actions& actions, bool& no_eols)
- : no_eols(no_eols), actions(actions) {}
-
- template <typename Scanner>
- struct definition
- {
- definition(phrase_grammar const& self)
- {
- using detail::var;
- quickbook::actions& actions = self.actions;
-
- space =
- *(space_p | comment)
- ;
-
- blank =
- *(blank_p | comment)
- ;
-
- eol = blank >> eol_p
- ;
-
- phrase_end =
- ']' |
- if_p(var(self.no_eols))
- [
- eol >> eol // Make sure that we don't go
- ] // past a single block, except
- ; // when preformatted.
-
- hard_space =
- (eps_p - (alnum_p | '_')) >> space // must not be preceded by
- ; // alpha-numeric or underscore
-
- comment =
- "[/" >> *(dummy_block | (anychar_p - ']')) >> ']'
- ;
-
- dummy_block =
- '[' >> *(dummy_block | (anychar_p - ']')) >> ']'
- ;
-
- common =
- macro
- | phrase_markup
- | code_block
- | inline_code
- | simple_format
- | escape
- | comment
- ;
-
- macro =
- eps_p(actions.macro // must not be followed by
- >> (eps_p - (alpha_p | '_'))) // alpha or underscore
- >> actions.macro [actions.do_macro]
- ;
-
- static const bool true_ = true;
- static const bool false_ = false;
-
- template_ =
- (
- ch_p('`') [assign_a(actions.template_escape,true_)]
- |
- eps_p [assign_a(actions.template_escape,false_)]
- )
- >>
- ( (
- (eps_p(punct_p)
- >> actions.templates.scope
- ) [assign_a(actions.template_identifier)]
- [clear_a(actions.template_args)]
- >> !template_args
- ) | (
- (actions.templates.scope
- >> eps_p(hard_space)
- ) [assign_a(actions.template_identifier)]
- [clear_a(actions.template_args)]
- >> space
- >> !template_args
- ) )
- >> eps_p(']')
- ;
-
- template_args =
- if_p(qbk_since(105u)) [
- template_args_1_5
- ].else_p [
- template_args_1_4
- ]
- ;
-
- template_args_1_4 = template_arg_1_4 >> *(".." >> template_arg_1_4);
-
- template_arg_1_4 =
- ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)]
- | eps_p [assign_a(actions.template_block, false_)]
- )
- >> template_inner_arg_1_4 [actions.template_arg]
- ;
-
- template_inner_arg_1_4 =
- +(brackets_1_4 | (anychar_p - (str_p("..") | ']')))
- ;
-
- brackets_1_4 =
- '[' >> template_inner_arg_1_4 >> ']'
- ;
-
- template_args_1_5 = template_arg_1_5 >> *(".." >> template_arg_1_5);
-
- template_arg_1_5 =
- ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)]
- | eps_p [assign_a(actions.template_block, false_)]
- )
- >> (+(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']'))))
- [actions.template_arg]
- ;
-
- template_inner_arg_1_5 =
- +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p('[') | ']')))
- ;
-
- brackets_1_5 =
- '[' >> template_inner_arg_1_5 >> ']'
- ;
-
- inline_code =
- '`' >>
- (
- *(anychar_p -
- ( '`'
- | (eol >> eol) // Make sure that we don't go
- ) // past a single block
- ) >> eps_p('`')
- ) [actions.inline_code]
- >> '`'
- ;
-
- code_block =
- (
- "```" >>
- (
- *(anychar_p - "```")
- >> eps_p("```")
- ) [actions.code_block]
- >> "```"
- )
- | (
- "``" >>
- (
- *(anychar_p - "``")
- >> eps_p("``")
- ) [actions.code_block]
- >> "``"
- )
- ;
-
- simple_format =
- simple_bold
- | simple_italic
- | simple_underline
- | simple_teletype
- ;
-
- simple_phrase_end = '[' | phrase_end;
-
- simple_markup(simple_bold,
- '*', actions.simple_bold, simple_phrase_end);
- simple_markup(simple_italic,
- '/', actions.simple_italic, simple_phrase_end);
- simple_markup(simple_underline,
- '_', actions.simple_underline, simple_phrase_end);
- simple_markup(simple_teletype,
- '=', actions.simple_teletype, simple_phrase_end);
-
- phrase =
- *( common
- | comment
- | (anychar_p - phrase_end) [actions.plain_char]
- )
- ;
-
- phrase_markup =
- '['
- >> ( cond_phrase
- | image
- | url
- | link
- | anchor
- | source_mode
- | funcref
- | classref
- | memberref
- | enumref
- | macroref
- | headerref
- | conceptref
- | globalref
- | bold
- | italic
- | underline
- | teletype
- | strikethrough
- | quote
- | replaceable
- | footnote
- | template_ [actions.do_template]
- | str_p("br") [actions.break_]
- )
- >> ']'
- ;
-
- escape =
- str_p("\\ ") // ignore an escaped space
- | '\\' >> punct_p [actions.raw_char]
- | "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")]
- [actions.escape_unicode]
- | "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")]
- [actions.escape_unicode]
- | (
- ("'''" >> !eol) [actions.escape_pre]
- >> *(anychar_p - "'''") [actions.raw_char]
- >> str_p("'''") [actions.escape_post]
- )
- ;
-
- macro_identifier =
- +(anychar_p - (space_p | ']'))
- ;
-
- cond_phrase =
- '?' >> blank
- >> macro_identifier [actions.cond_phrase_pre]
- >> (!phrase) [actions.cond_phrase_post]
- ;
-
- image =
- '$' >> blank [clear_a(actions.attributes)]
- >> if_p(qbk_since(105u)) [
- (+(
- *space_p
- >> +(anychar_p - (space_p | phrase_end | '['))
- )) [assign_a(actions.image_fileref)]
- >> hard_space
- >> *(
- '['
- >> (*(alnum_p | '_')) [assign_a(actions.attribute_name)]
- >> space
- >> (*(anychar_p - (phrase_end | '[')))
- [actions.attribute]
- >> ']'
- >> space
- )
- ].else_p [
- (*(anychar_p -
- phrase_end)) [assign_a(actions.image_fileref)]
- ]
- >> eps_p(']') [actions.image]
- ;
-
- url =
- '@'
- >> (*(anychar_p -
- (']' | hard_space))) [actions.url_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.url_post]
- ;
-
- link =
- "link" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.link_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.link_post]
- ;
-
- anchor =
- '#'
- >> blank
- >> ( *(anychar_p -
- phrase_end)
- ) [actions.anchor]
- ;
-
- funcref =
- "funcref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.funcref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.funcref_post]
- ;
-
- classref =
- "classref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.classref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.classref_post]
- ;
-
- memberref =
- "memberref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.memberref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.memberref_post]
- ;
-
- enumref =
- "enumref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.enumref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.enumref_post]
- ;
-
- macroref =
- "macroref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.macroref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.macroref_post]
- ;
-
- headerref =
- "headerref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.headerref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.headerref_post]
- ;
-
- conceptref =
- "conceptref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.conceptref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.conceptref_post]
- ;
-
- globalref =
- "globalref" >> hard_space
- >> (*(anychar_p -
- (']' | hard_space))) [actions.globalref_pre]
- >> ( eps_p(']')
- | (hard_space >> phrase)
- ) [actions.globalref_post]
- ;
-
- bold =
- ch_p('*') [actions.bold_pre]
- >> blank >> phrase [actions.bold_post]
- ;
-
- italic =
- ch_p('\'') [actions.italic_pre]
- >> blank >> phrase [actions.italic_post]
- ;
-
- underline =
- ch_p('_') [actions.underline_pre]
- >> blank >> phrase [actions.underline_post]
- ;
-
- teletype =
- ch_p('^') [actions.teletype_pre]
- >> blank >> phrase [actions.teletype_post]
- ;
-
- strikethrough =
- ch_p('-') [actions.strikethrough_pre]
- >> blank >> phrase [actions.strikethrough_post]
- ;
-
- quote =
- ch_p('"') [actions.quote_pre]
- >> blank >> phrase [actions.quote_post]
- ;
-
- replaceable =
- ch_p('~') [actions.replaceable_pre]
- >> blank >> phrase [actions.replaceable_post]
- ;
-
- source_mode =
- (
- str_p("c++")
- | "python"
- | "teletype"
- ) [assign_a(actions.source_mode)]
- ;
-
- footnote =
- str_p("footnote") [actions.footnote_pre]
- >> blank >> phrase [actions.footnote_post]
- ;
- }
-
- rule<Scanner> space, blank, comment, phrase, phrase_markup, image,
- simple_phrase_end, phrase_end, bold, italic, underline, teletype,
- strikethrough, escape, url, common, funcref, classref,
- memberref, enumref, macroref, headerref, conceptref, globalref,
- anchor, link, hard_space, eol, inline_code, simple_format,
- simple_bold, simple_italic, simple_underline,
- simple_teletype, source_mode, template_,
- quote, code_block, footnote, replaceable, macro,
- dummy_block, cond_phrase, macro_identifier, template_args,
- template_args_1_4, template_arg_1_4,
- template_inner_arg_1_4, brackets_1_4,
- template_args_1_5, template_arg_1_5,
- template_inner_arg_1_5, brackets_1_5
- ;
-
- rule<Scanner> const&
- start() const { return common; }
- };
-
- bool& no_eols;
- quickbook::actions& actions;
- };
-
- struct simple_phrase_grammar
- : public grammar<simple_phrase_grammar >
- {
- simple_phrase_grammar(quickbook::actions& actions)
- : actions(actions) {}
-
- template <typename Scanner>
- struct definition
- {
- definition(simple_phrase_grammar const& self)
- : unused(false), common(self.actions, unused)
- {
- quickbook::actions& actions = self.actions;
-
- phrase =
- *( common
- | comment
- | (anychar_p - ']') [actions.plain_char]
- )
- ;
-
- comment =
- "[/" >> *(dummy_block | (anychar_p - ']')) >> ']'
- ;
-
- dummy_block =
- '[' >> *(dummy_block | (anychar_p - ']')) >> ']'
- ;
- }
-
- bool unused;
- rule<Scanner> phrase, comment, dummy_block;
- phrase_grammar common;
-
- rule<Scanner> const&
- start() const { return phrase; }
- };
-
- quickbook::actions& actions;
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
-

Copied: trunk/tools/quickbook/src/Jamfile.v2 (from r65029, /trunk/tools/quickbook/Jamfile.v2)
==============================================================================
--- /trunk/tools/quickbook/Jamfile.v2 (original)
+++ trunk/tools/quickbook/src/Jamfile.v2 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -18,16 +18,16 @@
 
 exe quickbook
     :
- detail/quickbook.cpp
- detail/actions.cpp
- detail/actions_class.cpp
- detail/utils.cpp
- detail/input_path.cpp
- detail/post_process.cpp
- detail/collector.cpp
- detail/template_stack.cpp
- detail/markups.cpp
- detail/syntax_highlight.cpp
+ quickbook.cpp
+ actions.cpp
+ actions_class.cpp
+ utils.cpp
+ input_path.cpp
+ post_process.cpp
+ collector.cpp
+ template_stack.cpp
+ markups.cpp
+ syntax_highlight.cpp
     /boost//program_options
     /boost//filesystem
     : #<define>QUICKBOOK_NO_DATES
@@ -44,23 +44,3 @@
       <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
       <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
     ;
-
-install dist-bin
- :
- quickbook
- :
- <install-type>EXE
- <location>../../dist/bin
- :
- release
- ;
-
-install dist-lib
- :
- quickbook
- :
- <install-type>LIB
- <location>../../dist/lib
- :
- release
- ;

Copied: trunk/tools/quickbook/src/actions.cpp (from r65029, /trunk/tools/quickbook/detail/actions.cpp)
==============================================================================
--- /trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -22,9 +22,9 @@
 #include "./utils.hpp"
 #include "./markups.hpp"
 #include "./actions_class.hpp"
-#include "../block.hpp"
-#include "../phrase.hpp"
-#include "../code_snippet.hpp"
+#include "./block.hpp"
+#include "./phrase.hpp"
+#include "./code_snippet.hpp"
 
 namespace quickbook
 {

Copied: trunk/tools/quickbook/src/actions.hpp (from r65029, /trunk/tools/quickbook/detail/actions.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/actions_class.cpp (from r65029, /trunk/tools/quickbook/detail/actions_class.cpp)
==============================================================================

Copied: trunk/tools/quickbook/src/actions_class.hpp (from r65029, /trunk/tools/quickbook/detail/actions_class.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/block.hpp (from r65029, /trunk/tools/quickbook/block.hpp)
==============================================================================
--- /trunk/tools/quickbook/block.hpp (original)
+++ trunk/tools/quickbook/src/block.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -10,8 +10,8 @@
 #if !defined(BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP)
 #define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
 
-#include "./detail/quickbook.hpp"
-#include "./detail/utils.hpp"
+#include "./quickbook.hpp"
+#include "./utils.hpp"
 #include "./phrase.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>

Copied: trunk/tools/quickbook/src/code_snippet.hpp (from r65029, /trunk/tools/quickbook/code_snippet.hpp)
==============================================================================
--- /trunk/tools/quickbook/code_snippet.hpp (original)
+++ trunk/tools/quickbook/src/code_snippet.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -12,8 +12,8 @@
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
 #include <boost/bind.hpp>
-#include "./detail/template_stack.hpp"
-#include "./detail/actions.hpp"
+#include "./template_stack.hpp"
+#include "./actions.hpp"
 
 namespace quickbook
 {

Copied: trunk/tools/quickbook/src/collector.cpp (from r65029, /trunk/tools/quickbook/detail/collector.cpp)
==============================================================================

Copied: trunk/tools/quickbook/src/collector.hpp (from r65029, /trunk/tools/quickbook/detail/collector.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/doc_info.hpp (from r65029, /trunk/tools/quickbook/doc_info.hpp)
==============================================================================
--- /trunk/tools/quickbook/doc_info.hpp (original)
+++ trunk/tools/quickbook/src/doc_info.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -11,7 +11,7 @@
 #define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
 
 #include "./phrase.hpp"
-#include "./detail/quickbook.hpp"
+#include "./quickbook.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
 #include <boost/spirit/include/classic_loops.hpp>

Copied: trunk/tools/quickbook/src/input_path.cpp (from r65029, /trunk/tools/quickbook/detail/input_path.cpp)
==============================================================================

Copied: trunk/tools/quickbook/src/input_path.hpp (from r65029, /trunk/tools/quickbook/detail/input_path.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/markups.cpp (from r65029, /trunk/tools/quickbook/detail/markups.cpp)
==============================================================================

Copied: trunk/tools/quickbook/src/markups.hpp (from r65029, /trunk/tools/quickbook/detail/markups.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/phrase.hpp (from r65029, /trunk/tools/quickbook/phrase.hpp)
==============================================================================
--- /trunk/tools/quickbook/phrase.hpp (original)
+++ trunk/tools/quickbook/src/phrase.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -10,9 +10,9 @@
 #if !defined(BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP)
 #define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
 
-#include "./detail/quickbook.hpp"
-#include "./detail/actions_class.hpp"
-#include "detail/utils.hpp"
+#include "./quickbook.hpp"
+#include "./actions_class.hpp"
+#include "utils.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>

Copied: trunk/tools/quickbook/src/post_process.cpp (from r65029, /trunk/tools/quickbook/detail/post_process.cpp)
==============================================================================

Copied: trunk/tools/quickbook/src/post_process.hpp (from r65029, /trunk/tools/quickbook/detail/post_process.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/quickbook.cpp (from r65029, /trunk/tools/quickbook/detail/quickbook.cpp)
==============================================================================
--- /trunk/tools/quickbook/detail/quickbook.cpp (original)
+++ trunk/tools/quickbook/src/quickbook.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -9,8 +9,8 @@
 =============================================================================*/
 #include "./quickbook.hpp"
 #include "./actions_class.hpp"
-#include "../block.hpp"
-#include "../doc_info.hpp"
+#include "./block.hpp"
+#include "./doc_info.hpp"
 #include "./post_process.hpp"
 #include "./utils.hpp"
 #include "./input_path.hpp"

Copied: trunk/tools/quickbook/src/quickbook.hpp (from r65029, /trunk/tools/quickbook/detail/quickbook.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/syntax_highlight.cpp (from r65029, /trunk/tools/quickbook/detail/syntax_highlight.cpp)
==============================================================================
--- /trunk/tools/quickbook/detail/syntax_highlight.cpp (original)
+++ trunk/tools/quickbook/src/syntax_highlight.cpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -7,7 +7,7 @@
     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
-#include "../syntax_highlight.hpp"
+#include "./syntax_highlight.hpp"
 #include "./actions_class.hpp"
 
 namespace quickbook

Copied: trunk/tools/quickbook/src/syntax_highlight.hpp (from r65029, /trunk/tools/quickbook/syntax_highlight.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/template_stack.cpp (from r65029, /trunk/tools/quickbook/detail/template_stack.cpp)
==============================================================================

Copied: trunk/tools/quickbook/src/template_stack.hpp (from r65029, /trunk/tools/quickbook/detail/template_stack.hpp)
==============================================================================

Copied: trunk/tools/quickbook/src/utils.cpp (from r65029, /trunk/tools/quickbook/detail/utils.cpp)
==============================================================================

Copied: trunk/tools/quickbook/src/utils.hpp (from r65029, /trunk/tools/quickbook/detail/utils.hpp)
==============================================================================

Deleted: trunk/tools/quickbook/syntax_highlight.hpp
==============================================================================
--- trunk/tools/quickbook/syntax_highlight.hpp 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,404 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- 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_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP
-
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/spirit/include/classic_chset.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
-#include <boost/spirit/include/classic_loops.hpp>
-#include "./phrase.hpp"
-
-namespace quickbook
-{
- using namespace boost::spirit::classic;
-
- // Grammar for C++ highlighting
- template <
- typename Process
- , typename Space
- , typename Macro
- , typename DoMacro
- , typename PreEscape
- , typename PostEscape
- , typename Unexpected
- , typename Out>
- struct cpp_highlight
- : public grammar<cpp_highlight<Process, Space, Macro, DoMacro, PreEscape, PostEscape, Unexpected, Out> >
- {
- cpp_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions)
- : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {}
-
- template <typename Scanner>
- struct definition
- {
- definition(cpp_highlight const& self)
- : common(self.escape_actions, unused)
- , unused(false)
- {
- program
- =
- *( (+space_p) [Space(self.out)]
- | macro
- | escape
- | preprocessor [Process("preprocessor", self.out)]
- | comment [Process("comment", self.out)]
- | keyword [Process("keyword", self.out)]
- | identifier [Process("identifier", self.out)]
- | special [Process("special", self.out)]
- | string_ [Process("string", self.out)]
- | char_ [Process("char", self.out)]
- | number [Process("number", self.out)]
- | repeat_p(1)[anychar_p] [Unexpected(self.out)]
- )
- ;
-
- macro =
- eps_p(self.macro // must not be followed by
- >> (eps_p - (alpha_p | '_'))) // alpha or underscore
- >> self.macro [self.do_macro]
- ;
-
- qbk_phrase =
- *( common
- | (anychar_p - str_p("``")) [self.escape_actions.plain_char]
- )
- ;
-
- escape =
- str_p("``") [PreEscape(self.escape_actions, save)]
- >>
- (
- (
- (
- (+(anychar_p - "``") >> eps_p("``"))
- & qbk_phrase
- )
- >> str_p("``")
- )
- |
- (
- eps_p [self.escape_actions.error]
- >> *anychar_p
- )
- ) [PostEscape(self.out, self.escape_actions, save)]
- ;
-
- preprocessor
- = '#' >> *space_p >> ((alpha_p | '_') >> *(alnum_p | '_'))
- ;
-
- comment
- = comment_p("//") | comment_p("/*", "*/")
- ;
-
- keyword
- = keyword_ >> (eps_p - (alnum_p | '_'))
- ; // make sure we recognize whole words only
-
- keyword_
- = "and_eq", "and", "asm", "auto", "bitand", "bitor",
- "bool", "break", "case", "catch", "char", "class",
- "compl", "const_cast", "const", "continue", "default",
- "delete", "do", "double", "dynamic_cast", "else",
- "enum", "explicit", "export", "extern", "false",
- "float", "for", "friend", "goto", "if", "inline",
- "int", "long", "mutable", "namespace", "new", "not_eq",
- "not", "operator", "or_eq", "or", "private",
- "protected", "public", "register", "reinterpret_cast",
- "return", "short", "signed", "sizeof", "static",
- "static_cast", "struct", "switch", "template", "this",
- "throw", "true", "try", "typedef", "typeid",
- "typename", "union", "unsigned", "using", "virtual",
- "void", "volatile", "wchar_t", "while", "xor_eq", "xor"
- ;
-
- special
- = +chset_p("~!%^&*()+={[}]:;,<.>?/|\\-")
- ;
-
- string_char = ('\\' >> anychar_p) | (anychar_p - '\\');
-
- string_
- = !as_lower_d['l'] >> confix_p('"', *string_char, '"')
- ;
-
- char_
- = !as_lower_d['l'] >> confix_p('\'', *string_char, '\'')
- ;
-
- number
- = (
- as_lower_d["0x"] >> hex_p
- | '0' >> oct_p
- | real_p
- )
- >> *as_lower_d[chset_p("ldfu")]
- ;
-
- identifier
- = (alpha_p | '_') >> *(alnum_p | '_')
- ;
- }
-
- rule<Scanner> program, macro, preprocessor, comment, special, string_,
- char_, number, identifier, keyword, qbk_phrase, escape,
- string_char;
-
- symbols<> keyword_;
- phrase_grammar common;
- std::string save;
- bool unused;
-
- rule<Scanner> const&
- start() const { return program; }
- };
-
- Out& out;
- Macro const& macro;
- DoMacro do_macro;
- actions& escape_actions;
- };
-
- // Grammar for Python highlighting
- // See also: The Python Reference Manual
- // http://docs.python.org/ref/ref.html
- template <
- typename Process
- , typename Space
- , typename Macro
- , typename DoMacro
- , typename PreEscape
- , typename PostEscape
- , typename Unexpected
- , typename Out>
- struct python_highlight
- : public grammar<python_highlight<Process, Space, Macro, DoMacro, PreEscape, PostEscape, Unexpected, Out> >
- {
- python_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions)
- : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {}
-
- template <typename Scanner>
- struct definition
- {
- definition(python_highlight const& self)
- : common(self.escape_actions, unused)
- , unused(false)
- {
- program
- =
- *( (+space_p) [Space(self.out)]
- | macro
- | escape
- | comment [Process("comment", self.out)]
- | keyword [Process("keyword", self.out)]
- | identifier [Process("identifier", self.out)]
- | special [Process("special", self.out)]
- | string_ [Process("string", self.out)]
- | number [Process("number", self.out)]
- | repeat_p(1)[anychar_p] [Unexpected(self.out)]
- )
- ;
-
- macro =
- eps_p(self.macro // must not be followed by
- >> (eps_p - (alpha_p | '_'))) // alpha or underscore
- >> self.macro [self.do_macro]
- ;
-
- qbk_phrase =
- *( common
- | (anychar_p - str_p("``")) [self.escape_actions.plain_char]
- )
- ;
-
- escape =
- str_p("``") [PreEscape(self.escape_actions, save)]
- >>
- (
- (
- (
- (+(anychar_p - "``") >> eps_p("``"))
- & qbk_phrase
- )
- >> str_p("``")
- )
- |
- (
- eps_p [self.escape_actions.error]
- >> *anychar_p
- )
- ) [PostEscape(self.out, self.escape_actions, save)]
- ;
-
- comment
- = comment_p("#")
- ;
-
- keyword
- = keyword_ >> (eps_p - (alnum_p | '_'))
- ; // make sure we recognize whole words only
-
- keyword_
- =
- "and", "del", "for", "is", "raise",
- "assert", "elif", "from", "lambda", "return",
- "break", "else", "global", "not", "try",
- "class", "except", "if", "or", "while",
- "continue", "exec", "import", "pass", "yield",
- "def", "finally", "in", "print",
-
- // Technically "as" and "None" are not yet keywords (at Python
- // 2.4). They are destined to become keywords, and we treat them
- // as such for syntax highlighting purposes.
-
- "as", "None"
- ;
-
- special
- = +chset_p("~!%^&*()+={[}]:;,<.>/|\\-")
- ;
-
- string_prefix
- = as_lower_d[str_p("u") >> ! str_p("r")]
- ;
-
- string_
- = ! string_prefix >> (long_string | short_string)
- ;
-
- string_char = ('\\' >> anychar_p) | (anychar_p - '\\');
-
- short_string
- = confix_p('\'', * string_char, '\'') |
- confix_p('"', * string_char, '"')
- ;
-
- long_string
- // Note: the "str_p" on the next two lines work around
- // an INTERNAL COMPILER ERROR when using VC7.1
- = confix_p(str_p("'''"), * string_char, "'''") |
- confix_p(str_p("\"\"\""), * string_char, "\"\"\"")
- ;
-
- number
- = (
- as_lower_d["0x"] >> hex_p
- | '0' >> oct_p
- | real_p
- )
- >> *as_lower_d[chset_p("lj")]
- ;
-
- identifier
- = (alpha_p | '_') >> *(alnum_p | '_')
- ;
- }
-
- rule<Scanner> program, macro, comment, special, string_, string_prefix,
- short_string, long_string, number, identifier, keyword,
- qbk_phrase, escape, string_char;
-
- symbols<> keyword_;
- phrase_grammar common;
- std::string save;
- bool unused;
-
- rule<Scanner> const&
- start() const { return program; }
- };
-
- Out& out;
- Macro const& macro;
- DoMacro do_macro;
- actions& escape_actions;
- };
-
- // Grammar for plain text (no actual highlighting)
- template <
- typename CharProcess
- , typename Macro
- , typename DoMacro
- , typename PreEscape
- , typename PostEscape
- , typename Out>
- struct teletype_highlight
- : public grammar<teletype_highlight<CharProcess, Macro, DoMacro, PreEscape, PostEscape, Out> >
- {
- teletype_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions)
- : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {}
-
- template <typename Scanner>
- struct definition
- {
- definition(teletype_highlight const& self)
- : common(self.escape_actions, unused)
- , unused(false)
- {
- program
- =
- *( macro
- | escape
- | repeat_p(1)[anychar_p] [CharProcess(self.out)]
- )
- ;
-
- macro =
- eps_p(self.macro // must not be followed by
- >> (eps_p - (alpha_p | '_'))) // alpha or underscore
- >> self.macro [self.do_macro]
- ;
-
- qbk_phrase =
- *( common
- | (anychar_p - str_p("``")) [self.escape_actions.plain_char]
- )
- ;
-
- escape =
- str_p("``") [PreEscape(self.escape_actions, save)]
- >>
- (
- (
- (
- (+(anychar_p - "``") >> eps_p("``"))
- & qbk_phrase
- )
- >> str_p("``")
- )
- |
- (
- eps_p [self.escape_actions.error]
- >> *anychar_p
- )
- ) [PostEscape(self.out, self.escape_actions, save)]
- ;
- }
-
- rule<Scanner> program, macro, qbk_phrase, escape;
-
- phrase_grammar common;
- std::string save;
- bool unused;
-
- rule<Scanner> const&
- start() const { return program; }
- };
-
- Out& out;
- Macro const& macro;
- DoMacro do_macro;
- actions& escape_actions;
- };
-
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP

Modified: trunk/tools/quickbook/test/quickbook-testing.jam
==============================================================================
--- trunk/tools/quickbook/test/quickbook-testing.jam (original)
+++ trunk/tools/quickbook/test/quickbook-testing.jam 2010-08-26 16:56:37 EDT (Thu, 26 Aug 2010)
@@ -50,7 +50,7 @@
             : $(input)
             : $(requirements)
                 <location-prefix>$(target-name).test
- <quickbook-testing.quickbook-command>..//quickbook
+ <quickbook-testing.quickbook-command>../src//quickbook
         ]
 
         [ targets.create-typed-target RUN
@@ -81,7 +81,7 @@
         [ targets.create-typed-target RUN_FAIL
             : $(project)
             : $(target-name)
- : ..//quickbook
+ : ../src//quickbook
             : $(requirements)
               <preserve-test-targets>on
               <dependency>$(input)


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