Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68888 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-02-14 19:25:00


Author: danieljames
Date: 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
New Revision: 68888
URL: http://svn.boost.org/trac/boost/changeset/68888

Log:
Use values for doc info.
Added:
   branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp (contents, props changed)
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 16 -
   branches/quickbook-filenames/tools/quickbook/src/actions.hpp | 31 ----
   branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp | 24 ---
   branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp | 40 -----
   branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp | 287 ++++++++++++++++++++++-----------------
   branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp | 195 ++++++++++++++------------
   6 files changed, 277 insertions(+), 316 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
@@ -1482,7 +1482,6 @@
         fs::path filein = include_search(actions.filename.parent_path(),
             check_path(first, last, actions));
         std::string doc_type, doc_id;
- docinfo_string doc_dirname, doc_last_revision;
 
         // swap the filenames
         std::swap(actions.filename, filein);
@@ -1491,14 +1490,10 @@
         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 source mode and version info (only restored for 1.6+)
@@ -1533,8 +1528,6 @@
 
         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)
         {
@@ -1562,11 +1555,12 @@
 
     void phrase_to_docinfo_action::operator()(iterator first, iterator last) const
     {
- if(!actions.output_pre(phrase)) return;
+ if(!actions.output_pre(actions.phrase)) return;
 
- out.encoded.clear();
- phrase.swap(out.encoded);
- out.raw = std::string(first, last);
+ std::string encoded;
+ actions.phrase.swap(encoded);
+ actions.values.builder.insert(
+ qbk_bbk_value(first, last, encoded, actions.values.builder.release_tag()));
     }
     
     void phrase_to_value_action::operator()(iterator first, iterator last) const

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.hpp 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
@@ -758,29 +758,6 @@
         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);
 
@@ -798,15 +775,11 @@
 
     struct phrase_to_docinfo_action
     {
- phrase_to_docinfo_action(docinfo_string& out, collector& phrase, quickbook::actions& actions)
- : out(out)
- , phrase(phrase)
- , actions(actions) {}
+ phrase_to_docinfo_action(quickbook::actions& actions)
+ : actions(actions) {}
 
         void operator()(iterator first, iterator last) const;
 
- docinfo_string& out;
- collector& phrase;
         quickbook::actions& actions;
     };
 

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
@@ -25,19 +25,12 @@
 
         , values()
         , phrase_value(*this)
+ , docinfo_value(*this)
 
     // header info
         , doc_type()
- , doc_title()
- , doc_version()
+ , doc_title_qbk()
         , doc_id()
- , doc_dirname()
- , doc_copyrights()
- , doc_purpose()
- , doc_categories()
- , doc_authors()
- , doc_license()
- , doc_last_revision()
         , include_doc_id()
 
     // main output stream
@@ -73,19 +66,6 @@
 
     // actions
         , error(*this)
- , extract_doc_title(doc_title, phrase, *this)
- , extract_doc_license(doc_license, phrase, *this)
- , extract_doc_purpose(doc_purpose, phrase, *this)
- , extract_doc_version(doc_version, phrase, *this)
- , extract_doc_id(doc_id_tmp, phrase, *this)
- , extract_doc_dirname(doc_dirname, phrase, *this)
- , extract_copyright_second(copyright.second, phrase, *this)
- , extract_name_second(name.second, phrase, *this)
- , extract_name_first(name.first, phrase, *this)
- , extract_doc_last_revision(doc_last_revision, phrase, *this)
- , extract_doc_category(doc_category, phrase, *this)
- , extract_doc_biblioid(doc_biblioid.second, phrase, *this)
- , extract_doc_lang(doc_lang, phrase, *this)
         , scoped_block(*this)
         , code(out, phrase, *this)
         , code_block(phrase, phrase, *this)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
@@ -35,41 +35,18 @@
 
         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<std::string, docinfo_string> biblioid_item;
- typedef std::vector<biblioid_item> biblioid_list;
         typedef std::pair<char, int> mark_type;
         static int const max_template_depth = 100;
 
         value_parser values;
         phrase_to_value_action phrase_value;
+ phrase_to_docinfo_action docinfo_value;
 
     // header info
         std::string doc_type;
- docinfo_string doc_title;
- docinfo_string doc_version;
+ std::string doc_title_qbk;
         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;
- biblioid_list doc_biblioid_items;
- docinfo_string doc_lang;
         std::string include_doc_id;
- //temporary state
- biblioid_item doc_biblioid;
- docinfo_string doc_id_tmp;
- author name;
- copyright_item copyright;
- docinfo_string doc_category;
-
 
     // main output stream
         collector out;
@@ -128,19 +105,6 @@
     // 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;
- phrase_to_docinfo_action extract_doc_biblioid;
- phrase_to_docinfo_action extract_doc_lang;
 
         scoped_parser<scoped_block_push>
                                 scoped_block;

Modified: branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
@@ -15,41 +15,102 @@
 #include "utils.hpp"
 #include "input_path.hpp"
 #include "actions_class.hpp"
+#include "doc_info_tags.hpp"
 
 namespace quickbook
 {
- std::string const& docinfo_string::get(unsigned version) const
+ static void write_document_title(collector& out, value const& title, value const& version);
+
+ static std::string doc_info_output(value const& p, unsigned version)
+ {
+ return (qbk_version_n < version) ? p.get_quickbook() : p.get_boostbook();
+ }
+
+ value consume_last(value_consumer& c, value::tag_type tag,
+ std::vector<std::string>* duplicates)
     {
- return (qbk_version_n < version) ? raw : encoded;
+ value p;
+
+ int count = 0;
+ while(c.is(tag)) {
+ p = c.consume();
+ ++count;
+ }
+
+ if(count > 1) duplicates->push_back(doc_info_attributes::name(tag));
+
+ return p;
     }
 
- static void write_document_title(collector& out, quickbook::actions& actions);
- static void write_document_info(collector& out, quickbook::actions& actions);
+ std::vector<value> consume_multiple(value_consumer& c, value::tag_type tag)
+ {
+ std::vector<value> values;
+
+ while(c.is(tag)) {
+ values.push_back(c.consume());
+ }
+
+ return values;
+ }
 
     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(106);
+ value_consumer values = actions.values.get();
+ std::vector<std::string> duplicates;
+
+ value doc_title;
+ if (values.is())
+ {
+ actions.doc_type = values.consume(doc_info_tags::type).get_quickbook();
+ doc_title = values.consume(doc_info_tags::title);
+ actions.doc_title_qbk = doc_title.get_quickbook();
+ }
+
+ value id = consume_last(values, doc_info_attributes::id, &duplicates);
+ value dirname = consume_last(values, doc_info_attributes::dirname, &duplicates);
+ value last_revision = consume_last(values, doc_info_attributes::last_revision, &duplicates);
+ value purpose = consume_last(values, doc_info_attributes::purpose, &duplicates);
+ std::vector<value> categories = consume_multiple(values, doc_info_attributes::category);
+ value lang = consume_last(values, doc_info_attributes::lang, &duplicates);
+ value version = consume_last(values, doc_info_attributes::version, &duplicates);
+ std::vector<value> authors = consume_multiple(values, doc_info_attributes::authors);
+ std::vector<value> copyrights = consume_multiple(values, doc_info_attributes::copyright);
+ value license = consume_last(values, doc_info_attributes::license, &duplicates);
+ std::vector<value> biblioids = consume_multiple(values, doc_info_attributes::biblioid);
+
+ BOOST_ASSERT(!values.is());
+
+ if(!duplicates.empty())
+ {
+ detail::outwarn(actions.filename,1)
+ << (duplicates.size() > 1 ?
+ "Duplicate attributes" : "Duplicate attribute")
+ << ":" << detail::utf8(boost::algorithm::join(duplicates, ", "))
+ << "\n"
+ ;
+ }
+
+ if (!id.is_empty())
+ actions.doc_id = id.get_quickbook();
 
         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;
+ actions.doc_title_qbk.begin(),actions.doc_title_qbk.end());
+
+ if (dirname.is_empty() && actions.doc_type == "library") {
+ if (!id.is_empty()) {
+ dirname = id;
             }
             else {
- actions.doc_dirname.raw = actions.doc_dirname.encoded = actions.doc_id;
+ dirname = qbk_bbk_value(actions.doc_id, doc_info_attributes::dirname);
             }
         }
 
- actions.doc_id_tmp.clear();
 
- if (actions.doc_last_revision.empty())
+ if (last_revision.is_empty())
         {
             // default value for last-revision is now
 
@@ -61,7 +122,7 @@
                     "$" /* prevent CVS substitution */ "Date: %Y/%m/%d %H:%M:%S $"),
                 current_gm_time
             );
- actions.doc_last_revision.raw = actions.doc_last_revision.encoded = strdate;
+ last_revision = qbk_bbk_value(strdate, doc_info_attributes::last_revision);
         }
 
         // if we're ignoring the document info, we're done.
@@ -111,13 +172,13 @@
         {
             std::vector<std::string> invalid_attributes;
 
- if (!actions.doc_purpose.empty())
+ if (!purpose.is_empty())
                 invalid_attributes.push_back("purpose");
 
- if (!actions.doc_categories.empty())
+ if (!categories.empty())
                 invalid_attributes.push_back("category");
 
- if (!actions.doc_dirname.empty())
+ if (!dirname.is_empty())
                 invalid_attributes.push_back("dirname");
 
             if(!invalid_attributes.empty())
@@ -144,176 +205,154 @@
             << actions.doc_id
             << "\"\n";
         
- if(!actions.doc_lang.empty())
+ if(!lang.is_empty())
         {
             out << " lang=\""
- << actions.doc_lang.get(106)
+ << doc_info_output(lang, 106)
                 << "\"\n";
         }
 
         if(actions.doc_type == "library")
         {
- out << " name=\"" << actions.doc_title.get(106) << "\"\n";
+ out << " name=\"" << doc_info_output(doc_title, 106) << "\"\n";
         }
 
- if(!actions.doc_dirname.empty())
+ if(!dirname.is_empty())
         {
             out << " dirname=\""
- << actions.doc_dirname.get(106)
+ << doc_info_output(dirname, 106)
                 << "\"\n";
         }
 
         out << " last-revision=\""
- << actions.doc_last_revision.get(106)
+ << doc_info_output(last_revision, 106)
             << "\" \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(106);
- if (!actions.doc_version.empty()) {
- out << ' ' << actions.doc_version.get(106);
- }
- out<< "</title>\n\n\n";
- }
- }
-
- void write_document_info(collector& out, quickbook::actions& actions)
- {
         std::ostringstream tmp;
 
- if(!actions.doc_authors.empty())
+ if(!authors.empty())
         {
             tmp << " <authorgroup>\n";
- for(actions::author_list::const_iterator
- it = actions.doc_authors.begin(),
- end = actions.doc_authors.end();
- it != end; ++it)
+ BOOST_FOREACH(value_consumer author_values, authors)
             {
- tmp << " <author>\n"
- << " <firstname>"
- << it->first.get(106)
- << "</firstname>\n"
- << " <surname>"
- << it->second.get(106)
- << "</surname>\n"
- << " </author>\n";
+ while (author_values.is()) {
+ value surname = author_values.consume(doc_info_tags::author_surname);
+ value first = author_values.consume(doc_info_tags::author_first);
+
+ tmp << " <author>\n"
+ << " <firstname>"
+ << doc_info_output(first, 106)
+ << "</firstname>\n"
+ << " <surname>"
+ << doc_info_output(surname, 106)
+ << "</surname>\n"
+ << " </author>\n";
+ }
             }
             tmp << " </authorgroup>\n";
         }
 
- if (!actions.doc_copyrights.empty())
+ BOOST_FOREACH(value_consumer copyright, copyrights)
         {
- for(actions::copyright_list::const_iterator
- it = actions.doc_copyrights.begin(),
- end = actions.doc_copyrights.end();
- it != end; ++it)
+ tmp << "\n" << " <copyright>\n";
+
+ while(copyright.is(doc_info_tags::copyright_year))
             {
- 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(106)
- << "</holder>\n"
- << " </copyright>\n"
- << "\n"
- ;
+ tmp << " <year>" << copyright.consume().get_quickbook() << "</year>\n";
             }
+
+ tmp << " <holder>"
+ << doc_info_output(copyright.consume(doc_info_tags::copyright_name), 106)
+ << "</holder>\n"
+ << " </copyright>\n"
+ << "\n"
+ ;
         }
 
- if (!actions.doc_license.empty())
+ if (!license.is_empty())
         {
             tmp << " <legalnotice>\n"
                 << " <para>\n"
- << " " << actions.doc_license.get(103) << "\n"
+ << " " << doc_info_output(license, 103) << "\n"
                 << " </para>\n"
                 << " </legalnotice>\n"
                 << "\n"
             ;
         }
 
- if (!actions.doc_purpose.empty())
+ if (!purpose.is_empty())
         {
             tmp << " <" << actions.doc_type << "purpose>\n"
- << " " << actions.doc_purpose.get(103)
+ << " " << doc_info_output(purpose, 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)
- {
- if (!it->empty())
- {
- tmp << " <" << actions.doc_type << "category name=\"category:"
- << it->get(106)
- << "\"></" << actions.doc_type << "category>\n"
- << "\n"
- ;
- }
+ BOOST_FOREACH(value const& category, categories) {
+ if(!category.is_empty()) {
+ tmp << " <" << actions.doc_type << "category name=\"category:"
+ << doc_info_output(category, 106)
+ << "\"></" << actions.doc_type << "category>\n"
+ << "\n"
+ ;
             }
         }
 
- for (actions::biblioid_list::const_iterator
- it = actions.doc_biblioid_items.begin(),
- end = actions.doc_biblioid_items.end();
- it != end; ++it)
+ BOOST_FOREACH(value_consumer biblioid, biblioids)
         {
             tmp << " <biblioid class=\""
- << it->first
+ << biblioid.consume(doc_info_tags::biblioid_class).get_quickbook()
                 << "\">"
- << it->second.get(103)
+ << doc_info_output(biblioid.consume(doc_info_tags::biblioid_value), 106)
                 << "</biblioid>"
                 << "\n"
                 ;
         }
 
- std::string value = tmp.str();
- if(!value.empty())
+ if(actions.doc_type != "library") {
+ write_document_title(out, doc_title, version);
+ }
+
+ std::string docinfo = tmp.str();
+ if(!docinfo.empty())
         {
             out << " <" << actions.doc_type << "info>\n"
- << value
+ << docinfo
                 << " </" << actions.doc_type << "info>\n"
                 << "\n"
             ;
         }
+
+ if(actions.doc_type == "library") {
+ write_document_title(out, doc_title, version);
+ }
+ }
+
+ 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";
+ }
+
+ static void write_document_title(collector& out, value const& title, value const& version)
+ {
+ if (!title.is_empty())
+ {
+ out << " <title>"
+ << doc_info_output(title, 106);
+ if (!version.is_empty()) {
+ out << ' ' << doc_info_output(version, 106);
+ }
+ out<< "</title>\n\n\n";
+ }
     }
 }

Modified: branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
@@ -10,6 +10,7 @@
 
 #include "grammar_impl.hpp"
 #include "actions_class.hpp"
+#include "doc_info_tags.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
 #include <boost/spirit/include/classic_loops.hpp>
@@ -20,15 +21,45 @@
 {
     namespace cl = boost::spirit::classic;
 
+ struct attribute_info
+ {
+ attribute_info(value::tag_type t, cl::rule<scanner>* r)
+ : tag(t), rule(r)
+ {}
+
+ value::tag_type tag;
+ cl::rule<scanner>* rule;
+ };
+
     struct doc_info_grammar_local
     {
+ struct assign_attribute_type
+ {
+ assign_attribute_type(doc_info_grammar_local& l)
+ : l(l)
+ {}
+
+ void operator()(value::tag_type& t) const {
+ l.attribute_rule = *l.attribute_rules[t];
+ }
+
+ doc_info_grammar_local& l;
+ };
+
         cl::rule<scanner>
- doc_title, doc_version, doc_id, doc_dirname,
- doc_copyright, doc_purpose, doc_category, doc_authors,
- doc_author, doc_license,
- doc_last_revision, doc_source_mode, doc_biblioid, doc_lang,
+ doc_title, doc_simple, doc_phrase,
+ doc_copyright, doc_authors, doc_author,
+ doc_source_mode, doc_biblioid,
                         quickbook_version, char_;
         cl::symbols<> doc_types;
+ cl::symbols<value::tag_type> doc_attributes;
+ std::map<value::tag_type, cl::rule<scanner>* > attribute_rules;
+ cl::rule<scanner> attribute_rule;
+ assign_attribute_type assign_attribute;
+
+ doc_info_grammar_local()
+ : assign_attribute(*this)
+ {}
     };
 
     void quickbook_grammar::impl::init_doc_info()
@@ -42,40 +73,41 @@
           , "appendix", "preface", "qandadiv", "qandaset"
           , "reference", "set"
         ;
+
+ BOOST_FOREACH(value::tag_type t, doc_info_attributes::tags()) {
+ local.doc_attributes.add(doc_info_attributes::name(t), t);
+ }
         
         doc_info_details =
             space
>> '[' >> space
>> (local.doc_types >> cl::eps_p)
- [cl::assign_a(actions.doc_type)]
+ [actions.values.reset]
+ [actions.values.entry(doc_info_tags::type)]
>> hard_space
>> ( *(~cl::eps_p(cl::ch_p('[') | ']' | cl::eol_p) >> local.char_)
- ) [actions.extract_doc_title]
+ ) [actions.values.tag(doc_info_tags::title)]
+ [actions.docinfo_value]
>> !(
                     space >> '[' >>
                         local.quickbook_version
>> space >> ']'
                 )
- >>
- *(
- space >> '[' >>
- (
- local.doc_version
- | local.doc_id
- | local.doc_dirname
- | local.doc_copyright [cl::push_back_a(actions.doc_copyrights, actions.copyright)]
- | local.doc_purpose
- | local.doc_category
- | local.doc_authors
- | local.doc_license
- | local.doc_last_revision
- | local.doc_source_mode
- | local.doc_biblioid
- | local.doc_lang
- )
- >> space >> ']' >> +cl::eol_p
+ >> *(
+ space
+ >> '['
+ >> local.doc_attributes
+ [local.assign_attribute]
+ [actions.values.tag]
+ >> hard_space
+ >> local.attribute_rule
+ >> space
+ >> ']'
+ >> +cl::eol_p
                 )
- >> space >> ']' >> +cl::eol_p
+ >> space [actions.values.sort]
+ >> ']'
+ >> +cl::eol_p
             ;
 
         local.quickbook_version =
@@ -86,106 +118,85 @@
                 )
             ;
 
- local.doc_version =
- "version" >> hard_space
- >> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_doc_version]
- ;
-
- // TODO: Restrictions on doc_id?
- local.doc_id =
- "id" >> hard_space
- >> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_doc_id]
- ;
+ // TODO: Restrictions on doc_id and doc_dirname?
 
- // TODO: Restrictions on doc_dirname?
- local.doc_dirname =
- "dirname" >> hard_space
- >> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_doc_dirname]
- ;
+ local.doc_simple = (*(~cl::eps_p(']') >> local.char_)) [actions.docinfo_value];
+ local.attribute_rules[doc_info_attributes::version] = &local.doc_simple;
+ local.attribute_rules[doc_info_attributes::id] = &local.doc_simple;
+ local.attribute_rules[doc_info_attributes::dirname] = &local.doc_simple;
+ local.attribute_rules[doc_info_attributes::category] = &local.doc_simple;
+ local.attribute_rules[doc_info_attributes::last_revision] = &local.doc_simple;
+ local.attribute_rules[doc_info_attributes::lang] = &local.doc_simple;
 
         local.doc_copyright =
- "copyright"
- >> hard_space [cl::clear_a(actions.copyright.first)]
- >> +( cl::repeat_p(4)[cl::digit_p]
- [cl::push_back_a(actions.copyright.first)]
+ actions.values.scoped(doc_info_attributes::copyright)
+ [
+ +( cl::repeat_p(4)[cl::digit_p]
+ [actions.values.entry(doc_info_tags::copyright_year)]
>> space
                 )
>> space
>> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_copyright_second]
+ [actions.values.tag(doc_info_tags::copyright_name)]
+ [actions.docinfo_value]
+ ]
             ;
 
- local.doc_purpose =
- "purpose" >> hard_space
- >> simple_phrase [actions.extract_doc_purpose]
- ;
+ local.attribute_rules[doc_info_attributes::copyright] = &local.doc_copyright;
 
- local.doc_category =
- "category" >> hard_space
- >> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_doc_category]
- [cl::push_back_a(actions.doc_categories, actions.doc_category)]
- ;
+ local.doc_phrase = simple_phrase[actions.docinfo_value];
+ local.attribute_rules[doc_info_attributes::purpose] = &local.doc_phrase;
+ local.attribute_rules[doc_info_attributes::license] = &local.doc_phrase;
 
         local.doc_author =
- '[' >> space
+ '['
+ >> space
>> (*(~cl::eps_p(',') >> local.char_))
- [actions.extract_name_second]
+ [actions.values.tag(doc_info_tags::author_surname)]
+ [actions.docinfo_value]
>> ',' >> space
>> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_name_first]
+ [actions.values.tag(doc_info_tags::author_first)]
+ [actions.docinfo_value]
>> ']'
             ;
 
         local.doc_authors =
- "authors"
- >> hard_space
- >> local.doc_author [cl::push_back_a(actions.doc_authors, actions.name)]
- >> space
- >> *( !(cl::ch_p(',') >> space)
- >> local.doc_author [cl::push_back_a(actions.doc_authors, actions.name)]
+ actions.values.scoped(doc_info_attributes::authors)
+ [
+ local.doc_author
>> space
- )
- ;
-
- local.doc_license =
- "license" >> hard_space
- >> simple_phrase [actions.extract_doc_license]
+ >> *( !(cl::ch_p(',') >> space)
+ >> local.doc_author
+ >> space
+ )
+ ]
             ;
 
- local.doc_last_revision =
- "last-revision" >> hard_space
- >> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_doc_last_revision]
- ;
+ local.attribute_rules[doc_info_attributes::authors] = &local.doc_authors;
 
         local.doc_source_mode =
- "source-mode" >> hard_space
- >> (
+ (
                    cl::str_p("c++")
                 | "python"
                 | "teletype"
                 ) [cl::assign_a(actions.source_mode)]
             ;
 
+ local.attribute_rules[doc_info_attributes::source_mode] = &local.doc_source_mode;
+
         local.doc_biblioid =
- "biblioid"
- >> hard_space
- >> (+cl::alnum_p) [cl::assign_a(actions.doc_biblioid.first)]
- >> hard_space
- >> (+(~cl::eps_p(']') >> local.char_))
- [actions.extract_doc_biblioid]
- [cl::push_back_a(actions.doc_biblioid_items, actions.doc_biblioid)]
+ actions.values.scoped(doc_info_attributes::biblioid)
+ [
+ (+cl::alnum_p) [actions.values.entry(doc_info_tags::biblioid_class)]
+ >> hard_space
+ >> (+(~cl::eps_p(']') >> local.char_))
+ [actions.values.tag(doc_info_tags::biblioid_value)]
+ [actions.docinfo_value]
+ ]
             ;
 
- local.doc_lang =
- "lang" >> hard_space
- >> (*(~cl::eps_p(']') >> local.char_))
- [actions.extract_doc_lang]
- ;
+ local.attribute_rules[doc_info_attributes::biblioid] = &local.doc_biblioid;
 
         local.char_ =
                 cl::str_p("\\n") [actions.break_]

Added: branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp 2011-02-14 19:24:55 EST (Mon, 14 Feb 2011)
@@ -0,0 +1,41 @@
+/*=============================================================================
+ Copyright (c) 2011 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_SPIRIT_QUICKBOOK_DOC_INFO_TAGS_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_TAGS_HPP
+
+#include "value_tags.hpp"
+
+namespace quickbook
+{
+ QUICKBOOK_VALUE_TAGS(doc_info_tags, 0x400,
+ (type)
+ (title)
+ (author_surname)(author_first)
+ (copyright_year)(copyright_name)
+ (license)
+ (biblioid_class)(biblioid_value)
+ )
+
+ QUICKBOOK_VALUE_NAMED_TAGS(doc_info_attributes, 0x450,
+ ((id)("id"))
+ ((dirname)("dirname"))
+ ((last_revision)("last-revision"))
+ ((purpose)("purpose"))
+ ((category)("category"))
+ ((lang)("lang"))
+ ((version)("version"))
+ ((authors)("authors"))
+ ((copyright)("copyright"))
+ ((license)("license"))
+ ((biblioid)("biblioid"))
+ ((source_mode)("source-mode"))
+ )
+}
+
+#endif


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