Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69887 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-03-12 05:07:14


Author: danieljames
Date: 2011-03-12 05:07:12 EST (Sat, 12 Mar 2011)
New Revision: 69887
URL: http://svn.boost.org/trac/boost/changeset/69887

Log:
Use spirit to convert years to integers.
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp | 6 ++----
   branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp | 10 +++++-----
   2 files changed, 7 insertions(+), 9 deletions(-)

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-03-12 05:07:12 EST (Sat, 12 Mar 2011)
@@ -11,7 +11,6 @@
 #include <sstream>
 #include <boost/bind.hpp>
 #include <boost/algorithm/string/join.hpp>
-#include <boost/lexical_cast.hpp>
 #include "quickbook.hpp"
 #include "utils.hpp"
 #include "input_path.hpp"
@@ -291,11 +290,10 @@
     
                 while(copyright.check(doc_info_tags::copyright_year))
                 {
- int year_start =
- boost::lexical_cast<int>(copyright.consume().get_quickbook());
+ int year_start = copyright.consume().get_int();
                     int year_end =
                         copyright.check(doc_info_tags::copyright_year_end) ?
- boost::lexical_cast<int>(copyright.consume().get_quickbook()) :
+ copyright.consume().get_int() :
                         year_start;
     
                     if (year_end < year_start) {

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-03-12 05:07:12 EST (Sat, 12 Mar 2011)
@@ -16,6 +16,7 @@
 #include <boost/spirit/include/classic_loops.hpp>
 #include <boost/spirit/include/classic_symbols.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
+#include <boost/spirit/include/classic_numerics.hpp>
 #include <boost/spirit/include/phoenix1_primitives.hpp>
 
 namespace quickbook
@@ -65,9 +66,10 @@
         cl::rule<scanner>
                         doc_title, doc_simple, doc_phrase, doc_fallback,
                         doc_authors, doc_author,
- doc_copyright, doc_copyright_year, doc_copyright_holder,
+ doc_copyright, doc_copyright_holder,
                         doc_source_mode, doc_biblioid,
                         quickbook_version, char_;
+ cl::uint_parser<int, 10, 4, 4> doc_copyright_year;
         cl::symbols<> doc_types;
         cl::symbols<value::tag_type> doc_attributes;
         std::map<value::tag_type, cl::rule<scanner>* > attribute_rules;
@@ -159,8 +161,6 @@
         local.attribute_rules[doc_info_attributes::last_revision] = &local.doc_simple;
         local.attribute_rules[doc_info_attributes::lang] = &local.doc_simple;
 
- local.doc_copyright_year = cl::repeat_p(4)[cl::digit_p];
-
         local.doc_copyright_holder
             = *( ~cl::eps_p
                     ( ']'
@@ -171,12 +171,12 @@
 
         local.doc_copyright =
             *( +( local.doc_copyright_year
- [actions.values.entry(ph::arg1, ph::arg2, doc_info_tags::copyright_year)]
+ [actions.values.entry(ph::arg1, doc_info_tags::copyright_year)]
>> space
>> !( '-'
>> space
>> local.doc_copyright_year
- [actions.values.entry(ph::arg1, ph::arg2, doc_info_tags::copyright_year_end)]
+ [actions.values.entry(ph::arg1, doc_info_tags::copyright_year_end)]
>> space
                     )
>> !cl::ch_p(',')


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