|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85129 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2013-07-23 04:23:07
Author: danieljames
Date: 2013-07-23 04:23:07 EDT (Tue, 23 Jul 2013)
New Revision: 85129
URL: http://svn.boost.org/trac/boost/changeset/85129
Log:
Single state saver.
It's always okay to save `template_depth` and `min_section_level`
because they only change at template calls, and template calls are
always cleanly nested.
Text files modified:
trunk/tools/quickbook/src/actions.cpp | 12 ++++++------
trunk/tools/quickbook/src/state.cpp | 17 ++++-------------
trunk/tools/quickbook/src/state_save.hpp | 19 ++++++-------------
3 files changed, 16 insertions(+), 32 deletions(-)
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp Tue Jul 23 04:22:49 2013 (r85128)
+++ trunk/tools/quickbook/src/actions.cpp 2013-07-23 04:23:07 EDT (Tue, 23 Jul 2013) (r85129)
@@ -593,7 +593,7 @@
std::string callout_value;
{
- template_state state(*this);
+ state_save save(*this, state_save::scope_all);
++template_depth;
bool r = parse_template(callout_body, *this);
@@ -1263,7 +1263,7 @@
std::string phrase;
{
- template_state save(state);
+ state_save save(state, state_save::scope_all);
state.templates.start_template(symbol);
qbk_version_n = symbol->content.get_file()->version();
@@ -1933,10 +1933,10 @@
//
// For old versions of quickbook, templates aren't scoped by the
// file.
- file_state save(state,
- load_type == block_tags::import ? file_state::scope_output :
- qbk_version_n >= 106u ? file_state::scope_callables :
- file_state::scope_macros);
+ state_save save(state,
+ load_type == block_tags::import ? state_save::scope_output :
+ qbk_version_n >= 106u ? state_save::scope_callables :
+ state_save::scope_macros);
state.current_file = load(paths.filename); // Throws load_error
state.filename_relative = paths.filename_relative;
Modified: trunk/tools/quickbook/src/state.cpp
==============================================================================
--- trunk/tools/quickbook/src/state.cpp Tue Jul 23 04:22:49 2013 (r85128)
+++ trunk/tools/quickbook/src/state.cpp 2013-07-23 04:23:07 EDT (Tue, 23 Jul 2013) (r85129)
@@ -70,7 +70,7 @@
return *grammar_;
}
- file_state::file_state(quickbook::state& state, scope_flags scope)
+ state_save::state_save(quickbook::state& state, scope_flags scope)
: state(state)
, scope(scope)
, qbk_version(qbk_version_n)
@@ -80,6 +80,8 @@
, xinclude_base(state.xinclude_base)
, source_mode(state.source_mode)
, macro()
+ , template_depth(state.template_depth)
+ , min_section_level(state.min_section_level)
{
if (scope & scope_macros) macro = state.macro;
if (scope & scope_templates) state.templates.push();
@@ -90,7 +92,7 @@
state.values.builder.save();
}
- file_state::~file_state()
+ state_save::~state_save()
{
state.values.builder.restore();
boost::swap(qbk_version_n, qbk_version);
@@ -105,17 +107,6 @@
}
if (scope & scope_templates) state.templates.pop();
if (scope & scope_macros) state.macro = macro;
- }
-
- template_state::template_state(quickbook::state& state)
- : file_state(state, file_state::scope_all)
- , template_depth(state.template_depth)
- , min_section_level(state.min_section_level)
- {
- }
-
- template_state::~template_state()
- {
boost::swap(state.template_depth, template_depth);
boost::swap(state.min_section_level, min_section_level);
}
Modified: trunk/tools/quickbook/src/state_save.hpp
==============================================================================
--- trunk/tools/quickbook/src/state_save.hpp Tue Jul 23 04:22:49 2013 (r85128)
+++ trunk/tools/quickbook/src/state_save.hpp 2013-07-23 04:23:07 EDT (Tue, 23 Jul 2013) (r85129)
@@ -18,7 +18,7 @@
//
// Defined in state.cpp
- struct file_state
+ struct state_save
{
enum scope_flags {
scope_none = 0,
@@ -29,8 +29,8 @@
scope_all = scope_callables + scope_output
};
- explicit file_state(quickbook::state&, scope_flags);
- ~file_state();
+ explicit state_save(quickbook::state&, scope_flags);
+ ~state_save();
quickbook::state& state;
scope_flags scope;
@@ -42,18 +42,11 @@
fs::path xinclude_base;
std::string source_mode;
string_symbols macro;
- private:
- file_state(file_state const&);
- file_state& operator=(file_state const&);
- };
-
- struct template_state : file_state
- {
- explicit template_state(quickbook::state&);
- ~template_state();
-
int template_depth;
int min_section_level;
+ private:
+ state_save(state_save const&);
+ state_save& operator=(state_save const&);
};
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk