$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r75252 - branches/quickbook-dev/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-11-02 03:49:53
Author: danieljames
Date: 2011-11-02 03:49:52 EDT (Wed, 02 Nov 2011)
New Revision: 75252
URL: http://svn.boost.org/trac/boost/changeset/75252
Log:
Quickbook: Separate string_ref.
Added:
   branches/quickbook-dev/tools/quickbook/src/string_ref.cpp   (contents, props changed)
   branches/quickbook-dev/tools/quickbook/src/string_ref.hpp   (contents, props changed)
Text files modified: 
   branches/quickbook-dev/tools/quickbook/src/Jamfile.v2     |     1                                         
   branches/quickbook-dev/tools/quickbook/src/id_manager.cpp |    72 --------------------------------------- 
   2 files changed, 2 insertions(+), 71 deletions(-)
Modified: branches/quickbook-dev/tools/quickbook/src/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/Jamfile.v2	(original)
+++ branches/quickbook-dev/tools/quickbook/src/Jamfile.v2	2011-11-02 03:49:52 EDT (Wed, 02 Nov 2011)
@@ -26,6 +26,7 @@
     doc_info_actions.cpp
     actions_class.cpp
     utils.cpp
+    string_ref.cpp
     input_path.cpp
     values.cpp
     id_manager.cpp
Modified: branches/quickbook-dev/tools/quickbook/src/id_manager.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/id_manager.cpp	(original)
+++ branches/quickbook-dev/tools/quickbook/src/id_manager.cpp	2011-11-02 03:49:52 EDT (Wed, 02 Nov 2011)
@@ -8,6 +8,7 @@
 
 #include "id_manager.hpp"
 #include "utils.hpp"
+#include "string_ref.hpp"
 #include <boost/shared_ptr.hpp>
 #include <boost/unordered_map.hpp>
 #include <boost/lexical_cast.hpp>
@@ -22,7 +23,6 @@
     // Forward declarations
     //
 
-    struct string_ref;
     struct id_placeholder;
     struct id_data;
     std::string process_ids(id_state&, std::string const&);
@@ -30,76 +30,6 @@
     static const std::size_t max_size = 32;
 
     //
-    // string_ref
-    //
-
-    struct string_ref
-    {
-    public:
-        typedef std::string::const_iterator iterator;
-
-    private:
-        iterator begin_, end_;
-
-    public:
-        string_ref() : begin_(), end_() {}
-
-        explicit string_ref(iterator b, iterator e)
-            : begin_(b), end_(e) {}
-
-        explicit string_ref(std::string const& x)
-            : begin_(x.begin()), end_(x.end()) {}
-
-        iterator begin() const { return begin_; }
-        iterator end() const { return end_; }
-
-        std::size_t size() const
-        {
-            return static_cast<std::size_t>(end_ - begin_);
-        }
-
-        std::string to_string() const
-        {
-            return std::string(begin_, end_);
-        }
-    };
-
-    bool operator==(string_ref const& x, string_ref const& y);
-    bool operator<(string_ref const& x, string_ref const& y);
-
-    inline bool operator==(string_ref const& x, std::string const& y)
-    {
-        return x == string_ref(y);
-    }
-
-    inline bool operator==(std::string const& x, string_ref const& y)
-    {
-        return string_ref(x) == y;
-    }
-
-    inline bool operator<(string_ref const& x, std::string const& y)
-    {
-        return x < string_ref(y);
-    }
-
-    inline bool operator<(std::string const& x, string_ref const& y)
-    {
-        return string_ref(x) < y;
-    }
-
-    bool operator==(string_ref const& x, string_ref const& y)
-    {
-        return x.size() == y.size() &&
-            std::equal(x.begin(), x.end(), y.begin());
-    }
-
-    bool operator<(string_ref const& x, string_ref const& y)
-    {
-        return std::lexicographical_compare(
-            x.begin(), x.end(), y.begin(), y.end());
-    }
-
-    //
     // id_placeholder
     //
 
Added: branches/quickbook-dev/tools/quickbook/src/string_ref.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/src/string_ref.cpp	2011-11-02 03:49:52 EDT (Wed, 02 Nov 2011)
@@ -0,0 +1,24 @@
+/*=============================================================================
+    Copyright (c) 2011 Daniel James
+
+    Use, modification and distribution is subject to the Boost Software
+    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+    http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include "string_ref.hpp"
+#include <boost/range/algorithm/equal.hpp>
+#include <boost/range/algorithm/lexicographical_compare.hpp>
+
+namespace quickbook
+{
+    bool operator==(string_ref const& x, string_ref const& y)
+    {
+        return boost::equal(x, y);
+    }
+
+    bool operator<(string_ref const& x, string_ref const& y)
+    {
+        return boost::lexicographical_compare(x, y);
+    }
+}
Added: branches/quickbook-dev/tools/quickbook/src/string_ref.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/src/string_ref.hpp	2011-11-02 03:49:52 EDT (Wed, 02 Nov 2011)
@@ -0,0 +1,76 @@
+/*=============================================================================
+    Copyright (c) 2011 Daniel James
+
+    Use, modification and distribution is subject to the Boost Software
+    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+    http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#if !defined(BOOST_QUICKBOOK_STRING_REF_HPP)
+#define BOOST_QUICKBOOK_STRING_REF_HPP
+
+#include <boost/operators.hpp>
+#include <string>
+
+namespace quickbook
+{
+    struct string_ref
+        : boost::less_than_comparable<string_ref,
+            boost::less_than_comparable<string_ref, std::string,
+            boost::equality_comparable<string_ref,
+            boost::equality_comparable<string_ref, std::string> > > >
+    {
+    public:
+        typedef std::string::const_iterator iterator;
+        typedef std::string::const_iterator const_iterator;
+
+    private:
+        iterator begin_, end_;
+
+    public:
+        string_ref() : begin_(), end_() {}
+
+        explicit string_ref(iterator b, iterator e)
+            : begin_(b), end_(e) {}
+
+        explicit string_ref(std::string const& x)
+            : begin_(x.begin()), end_(x.end()) {}
+
+        operator std::string() const {
+            return std::string(begin_, end_);
+        }
+
+        iterator begin() const { return begin_; }
+        iterator end() const { return end_; }
+
+        std::size_t size() const
+        {
+            return static_cast<std::size_t>(end_ - begin_);
+        }
+
+        bool empty() const
+        {
+            return begin_ == end_;
+        }
+    };
+
+    bool operator==(string_ref const& x, string_ref const& y);
+    bool operator<(string_ref const& x, string_ref const& y);
+
+    inline bool operator==(string_ref const& x, std::string const& y)
+    {
+        return x == string_ref(y);
+    }
+
+    inline bool operator<(string_ref const& x, std::string const& y)
+    {
+        return x < string_ref(y);
+    }
+
+    inline bool operator>(string_ref const& x, std::string const& y)
+    {
+        return x > string_ref(y);
+    }
+}
+
+#endif