Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83120 - in trunk/tools/quickbook: src test/unit
From: dnljms_at_[hidden]
Date: 2013-02-24 06:22:34


Author: danieljames
Date: 2013-02-24 06:22:33 EST (Sun, 24 Feb 2013)
New Revision: 83120
URL: http://svn.boost.org/trac/boost/changeset/83120

Log:
Clean up poorly overloaded 'add' method.
Text files modified:
   trunk/tools/quickbook/src/code_snippet.cpp | 24 ++++++++++++------------
   trunk/tools/quickbook/src/files.cpp | 8 +-------
   trunk/tools/quickbook/src/files.hpp | 3 +--
   trunk/tools/quickbook/test/unit/source_map_test.cpp | 4 ++--
   4 files changed, 16 insertions(+), 23 deletions(-)

Modified: trunk/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- trunk/tools/quickbook/src/code_snippet.cpp (original)
+++ trunk/tools/quickbook/src/code_snippet.cpp 2013-02-24 06:22:33 EST (Sun, 24 Feb 2013)
@@ -375,9 +375,9 @@
             if (last_code_pos != first) {
                 if (!in_code)
                 {
- content.add("\n\n", last_code_pos);
- content.add(source_type, last_code_pos);
- content.add("```\n", last_code_pos);
+ content.add_at_pos("\n\n", last_code_pos);
+ content.add_at_pos(source_type, last_code_pos);
+ content.add_at_pos("```\n", last_code_pos);
 
                     in_code = true;
                 }
@@ -395,7 +395,7 @@
     
         if (in_code)
         {
- content.add("\n```\n\n", last_code_pos);
+ content.add_at_pos("\n```\n\n", last_code_pos);
             in_code = false;
         }
     }
@@ -413,9 +413,9 @@
 
         if (!in_code)
         {
- content.add("\n\n", first);
- content.add(source_type, first);
- content.add("```\n", first);
+ content.add_at_pos("\n\n", first);
+ content.add_at_pos(source_type, first);
+ content.add_at_pos("```\n", first);
             in_code = true;
         }
 
@@ -436,7 +436,7 @@
     
             snippet_data& snippet = *snippet_stack;
 
- content.add("\n", mark_begin);
+ content.add_at_pos("\n", mark_begin);
             content.unindent_and_add(boost::string_ref(mark_begin, mark_end - mark_begin));
 
             if (snippet.id == "!")
@@ -515,13 +515,13 @@
         mapped_file_builder f;
         f.start(source_file);
         if (snippet->start_code) {
- f.add("\n\n", snippet->source_pos);
- f.add(source_type, snippet->source_pos);
- f.add("```\n", snippet->source_pos);
+ f.add_at_pos("\n\n", snippet->source_pos);
+ f.add_at_pos(source_type, snippet->source_pos);
+ f.add_at_pos("```\n", snippet->source_pos);
         }
         f.add(content, snippet->start_pos, content.get_pos());
         if (in_code) {
- f.add("\n```\n\n", position);
+ f.add_at_pos("\n```\n\n", position);
         }
 
         std::vector<std::string> params;

Modified: trunk/tools/quickbook/src/files.cpp
==============================================================================
--- trunk/tools/quickbook/src/files.cpp (original)
+++ trunk/tools/quickbook/src/files.cpp 2013-02-24 06:22:33 EST (Sun, 24 Feb 2013)
@@ -361,13 +361,7 @@
         return data->new_file->source().size();
     }
     
- void mapped_file_builder::add(char const* x, iterator pos)
- {
- data->new_file->add_empty_mapped_file_section(pos);
- data->new_file->source_.append(x);
- }
-
- void mapped_file_builder::add(boost::string_ref x, iterator pos)
+ void mapped_file_builder::add_at_pos(boost::string_ref x, iterator pos)
     {
         data->new_file->add_empty_mapped_file_section(pos);
         data->new_file->source_.append(x.begin(), x.end());

Modified: trunk/tools/quickbook/src/files.hpp
==============================================================================
--- trunk/tools/quickbook/src/files.hpp (original)
+++ trunk/tools/quickbook/src/files.hpp 2013-02-24 06:22:33 EST (Sun, 24 Feb 2013)
@@ -125,8 +125,7 @@
         bool empty() const;
         pos get_pos() const;
 
- void add(char const*, iterator);
- void add(boost::string_ref, iterator);
+ void add_at_pos(boost::string_ref, iterator);
         void add(boost::string_ref);
         void add(mapped_file_builder const&);
         void add(mapped_file_builder const&, pos, pos);

Modified: trunk/tools/quickbook/test/unit/source_map_test.cpp
==============================================================================
--- trunk/tools/quickbook/test/unit/source_map_test.cpp (original)
+++ trunk/tools/quickbook/test/unit/source_map_test.cpp 2013-02-24 06:22:33 EST (Sun, 24 Feb 2013)
@@ -125,9 +125,9 @@
 
     { // Generated text
         builder.start(fake_file);
- builder.add("------\n", line1);
+ builder.add_at_pos("------\n", line1);
         builder.add(boost::string_ref(line1, line1_end - line1));
- builder.add("\n------\n", line1_end);
+ builder.add_at_pos("\n------\n", line1_end);
         quickbook::file_ptr f1 = builder.release();
         BOOST_TEST_EQ(f1->source(),
             boost::string_ref("------\nFirst Line\n------\n"));


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