|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69302 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-02-26 06:32:16
Author: danieljames
Date: 2011-02-26 06:32:11 EST (Sat, 26 Feb 2011)
New Revision: 69302
URL: http://svn.boost.org/trac/boost/changeset/69302
Log:
Implement integer values, and use them for the quickbook version.
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 6 ---
branches/quickbook-filenames/tools/quickbook/src/actions.hpp | 2 -
branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp | 20 ++++++++---
branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp | 9 +++-
branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp | 1
branches/quickbook-filenames/tools/quickbook/src/values.cpp | 63 ++++++++++++++++++++++++++++++++++++---
branches/quickbook-filenames/tools/quickbook/src/values.hpp | 10 +++++
branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp | 6 +++
8 files changed, 94 insertions(+), 23 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-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -32,8 +32,6 @@
char const* quickbook_get_date = "__quickbook_get_date__";
char const* quickbook_get_time = "__quickbook_get_time__";
- int qbk_major_version = -1;
- int qbk_minor_version = -1;
unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
namespace {
@@ -1630,8 +1628,6 @@
// save the source mode and version info (only restored for 1.6+)
std::string source_mode = actions.source_mode;
- 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
@@ -1667,8 +1663,6 @@
{
actions.source_mode = source_mode;
- qbk_major_version = qbk_major_version_store;
- qbk_minor_version = qbk_minor_version_store;
qbk_version_n = qbk_version_n_store;
}
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-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -37,8 +37,6 @@
namespace cl = boost::spirit::classic;
namespace fs = boost::filesystem;
- 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 {
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-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -79,8 +79,8 @@
while (values.check(value::default_tag)) values.consume();
- std::vector<std::string> duplicates;
-
+ value qbk_version = values.optional_consume(doc_info_tags::qbk_version);
+
value doc_title;
if (values.check())
{
@@ -89,6 +89,8 @@
actions.doc_title_qbk = doc_title.get_quickbook();
}
+ std::vector<std::string> duplicates;
+
value id = consume_last_single(values, doc_info_attributes::id, &duplicates);
value dirname = consume_last_single(values, doc_info_attributes::dirname, &duplicates);
value last_revision = consume_last_single(values, doc_info_attributes::last_revision, &duplicates);
@@ -155,22 +157,28 @@
// Quickbook version
- if (qbk_major_version == -1)
+ int qbk_major_version, qbk_minor_version;
+
+ if (qbk_version.empty())
{
// hard code quickbook version to v1.1
qbk_major_version = 1;
qbk_minor_version = 1;
- qbk_version_n = 101;
detail::outwarn(actions.filename,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;
+ value_consumer qbk_version_values(qbk_version);
+ qbk_major_version = qbk_version_values.consume().get_int();
+ qbk_minor_version = qbk_version_values.consume().get_int();
+ qbk_version_values.finish();
}
+ qbk_version_n = ((unsigned) qbk_major_version * 100) +
+ (unsigned) qbk_minor_version;
+
if (qbk_version_n == 106)
{
detail::outwarn(actions.filename,1)
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-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -135,11 +135,14 @@
;
local.quickbook_version =
- "quickbook" >> hard_space
- >> ( cl::uint_p [cl::assign_a(qbk_major_version)]
+ actions.values.list(doc_info_tags::qbk_version)
+ [ "quickbook"
+ >> hard_space
+ >> ( cl::uint_p [actions.values.entry(ph::arg1)]
>> '.'
- >> uint2_t() [cl::assign_a(qbk_minor_version)]
+ >> uint2_t() [actions.values.entry(ph::arg1)]
)
+ ]
;
// TODO: Clear phrase afterwards?
Modified: branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp 2011-02-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -14,6 +14,7 @@
namespace quickbook
{
QUICKBOOK_VALUE_TAGS(doc_info_tags, 0x400,
+ (qbk_version)
(type)
(title)
(author_surname)(author_first)
Modified: branches/quickbook-filenames/tools/quickbook/src/values.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/values.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/values.cpp 2011-02-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -9,6 +9,7 @@
#include "values.hpp"
#include <boost/intrusive_ptr.hpp>
#include <boost/current_function.hpp>
+#include <boost/lexical_cast.hpp>
#define UNDEFINED_ERROR() \
throw value_error( \
@@ -41,6 +42,7 @@
value_node* value_node::store() { return this; }
file_position value_node::get_position() const { UNDEFINED_ERROR(); }
+ int value_node::get_int() const { UNDEFINED_ERROR(); }
std::string value_node::get_quickbook() const { UNDEFINED_ERROR(); }
std::string value_node::get_boostbook() const { UNDEFINED_ERROR(); }
value_node* value_node::get_list() const { UNDEFINED_ERROR(); }
@@ -196,6 +198,62 @@
}
////////////////////////////////////////////////////////////////////////////
+ // Integers
+
+ namespace detail
+ {
+ struct value_int_impl : public value_node
+ {
+ public:
+ explicit value_int_impl(int, value::tag_type);
+ private:
+ char const* type_name() const { return "integer"; }
+ virtual value_node* clone() const;
+ virtual int get_int() const;
+ virtual std::string get_quickbook() const;
+ virtual std::string get_boostbook() const;
+ virtual bool empty() const;
+
+ int value_;
+ };
+
+ value_int_impl::value_int_impl(int v, value::tag_type t)
+ : value_node(t)
+ , value_(v)
+ {}
+
+ value_node* value_int_impl::clone() const
+ {
+ return new value_int_impl(value_, tag_);
+ }
+
+ int value_int_impl::get_int() const
+ {
+ return value_;
+ }
+
+ std::string value_int_impl::get_quickbook() const
+ {
+ return boost::lexical_cast<std::string>(value_);
+ }
+
+ std::string value_int_impl::get_boostbook() const
+ {
+ return boost::lexical_cast<std::string>(value_);
+ }
+
+ bool value_int_impl::empty() const
+ {
+ return false;
+ }
+ }
+
+ value int_value(int v, value::tag_type t)
+ {
+ return value(new detail::value_int_impl(v, t));
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
// Strings
namespace detail
@@ -675,11 +733,6 @@
}
}
- value list_value(value::tag_type t)
- {
- return value(new detail::value_list_impl(t));
- }
-
//////////////////////////////////////////////////////////////////////////
// List builder
Modified: branches/quickbook-filenames/tools/quickbook/src/values.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/values.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/values.hpp 2011-02-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -51,6 +51,7 @@
virtual file_position get_position() const;
virtual std::string get_quickbook() const;
virtual std::string get_boostbook() const;
+ virtual int get_int() const;
virtual bool empty() const;
virtual bool is_list() const;
@@ -110,6 +111,8 @@
{ return value_->get_quickbook(); }
std::string get_boostbook() const
{ return value_->get_boostbook(); }
+ int get_int() const
+ { return value_->get_int(); }
protected:
value_node* value_;
@@ -219,8 +222,13 @@
explicit value(detail::value_node*);
};
+ // Empty
value empty_value(value::tag_type = value::default_tag);
- value list_value(value::tag_type = value::default_tag);
+
+ // Integers
+ value int_value(int, value::tag_type = value::default_tag);
+
+ // Boostbook and quickbook strings
value qbk_value(iterator, iterator, value::tag_type = value::default_tag);
value qbk_value(std::string const&,
file_position = file_position(),
Modified: branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/values_parse.hpp 2011-02-26 06:32:11 EST (Sat, 26 Feb 2011)
@@ -74,6 +74,12 @@
{
b.insert(qbk_value(v, begin.get_position(), tag));
}
+
+ void operator()(int v,
+ value::tag_type tag = value::default_tag) const
+ {
+ b.insert(int_value(v, tag));
+ }
value_builder& b;
};
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