Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72088 - sandbox/tools/auto_index/src
From: john_at_[hidden]
Date: 2011-05-22 14:07:57


Author: johnmaddock
Date: 2011-05-22 14:07:56 EDT (Sun, 22 May 2011)
New Revision: 72088
URL: http://svn.boost.org/trac/boost/changeset/72088

Log:
Simplify (and delete!) code.
Text files modified:
   sandbox/tools/auto_index/src/auto_index.cpp | 19 +++++--------------
   sandbox/tools/auto_index/src/auto_index.hpp | 15 ++++-----------
   sandbox/tools/auto_index/src/tiny_xml.cpp | 2 +-
   3 files changed, 10 insertions(+), 26 deletions(-)

Modified: sandbox/tools/auto_index/src/auto_index.cpp
==============================================================================
--- sandbox/tools/auto_index/src/auto_index.cpp (original)
+++ sandbox/tools/auto_index/src/auto_index.cpp 2011-05-22 14:07:56 EDT (Sun, 22 May 2011)
@@ -31,16 +31,6 @@
    return 1;
 }
 
-void eat_whitespace(std::istream & is)
-{
- char c = is.peek();
- while(std::isspace(c))
- {
- is.get(c);
- c = is.peek();
- }
-}
-
 void eat_block(std::string& result, std::istream & is)
 {
    //
@@ -65,15 +55,16 @@
    // We need to get any leading <? and <! elements:
    //
    std::string result;
- eat_whitespace(is);
+ is >> std::ws;
    if(is.get() != '<')
       throw std::runtime_error("Invalid leading markup in XML file found");
    char c = is.peek();
    while((c == '?') || (c == '!'))
    {
- result += '<';
- eat_block(result, is);
- eat_whitespace(is);
+ std::string temp;
+ std::getline(is, temp, '>');
+ result += '<' + temp + '>';
+ is >> std::ws;
       if(is.get() != '<')
          throw std::runtime_error("Invalid leading markup in XML file found");
       c = is.peek();

Modified: sandbox/tools/auto_index/src/auto_index.hpp
==============================================================================
--- sandbox/tools/auto_index/src/auto_index.hpp (original)
+++ sandbox/tools/auto_index/src/auto_index.hpp 2011-05-22 14:07:56 EDT (Sun, 22 May 2011)
@@ -19,6 +19,7 @@
 #include "tiny_xml.hpp"
 #include <boost/regex.hpp>
 #include <boost/filesystem.hpp>
+#include <boost/algorithm/string/case_conv.hpp>
 #include <fstream>
 #include <cctype>
 #include <map>
@@ -43,14 +44,6 @@
 bool operator < (const index_entry_ptr& a, const index_entry_ptr& b);
 typedef std::set<index_entry_ptr> index_entry_set;
 
-inline std::string make_upper_key(const std::string& s)
-{
- std::string result;
- for(std::string::const_iterator i = s.begin(); i != s.end(); ++i)
- result.append(1, std::toupper(*i));
- return result;
-}
-
 struct index_entry
 {
    std::string key; // The index term.
@@ -61,9 +54,9 @@
    bool preferred; // This entry is the preferred one for this key
 
    index_entry() : preferred(false) {}
- index_entry(const std::string& k) : key(k), preferred(false) { sort_key = make_upper_key(key); }
- index_entry(const std::string& k, const std::string& i) : key(k), id(i), preferred(false) { sort_key = make_upper_key(key); }
- index_entry(const std::string& k, const std::string& i, const std::string& c) : key(k), id(i), category(c), preferred(false) { sort_key = make_upper_key(key); }
+ index_entry(const std::string& k) : key(k), sort_key(k), preferred(false) { boost::to_upper(sort_key); }
+ index_entry(const std::string& k, const std::string& i) : key(k), sort_key(k), id(i), preferred(false) { boost::to_upper(sort_key); }
+ index_entry(const std::string& k, const std::string& i, const std::string& c) : key(k), sort_key(k), id(i), category(c), preferred(false) { boost::to_upper(sort_key); }
 };
 
 

Modified: sandbox/tools/auto_index/src/tiny_xml.cpp
==============================================================================
--- sandbox/tools/auto_index/src/tiny_xml.cpp (original)
+++ sandbox/tools/auto_index/src/tiny_xml.cpp 2011-05-22 14:07:56 EDT (Sun, 22 May 2011)
@@ -11,7 +11,7 @@
 namespace
 {
 
- void eat_whitespace( char & c, std::istream & in )
+ inline void eat_whitespace( char & c, std::istream & in )
    {
       while ( c == ' ' || c == '\r' || c == '\n' || c == '\t' )
          in.get( c );


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