|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72546 - in sandbox/coerce/boost/coerce: . detail
From: vexocide_at_[hidden]
Date: 2011-06-11 19:23:57
Author: vexocide
Date: 2011-06-11 19:23:56 EDT (Sat, 11 Jun 2011)
New Revision: 72546
URL: http://svn.boost.org/trac/boost/changeset/72546
Log:
Refactored string.hpp to use static functions
Text files modified:
sandbox/coerce/boost/coerce/char.hpp | 2
sandbox/coerce/boost/coerce/detail/qi.hpp | 19 +++----
sandbox/coerce/boost/coerce/string.hpp | 95 ++++++++++++++-------------------------
3 files changed, 44 insertions(+), 72 deletions(-)
Modified: sandbox/coerce/boost/coerce/char.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/char.hpp (original)
+++ sandbox/coerce/boost/coerce/char.hpp 2011-06-11 19:23:56 EDT (Sat, 11 Jun 2011)
@@ -25,7 +25,7 @@
struct is_char_impl<char>
: mpl::true_ { };
-#ifndef BOOST_NO_WCHAR_T
+#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template <>
struct is_char_impl<wchar_t>
: mpl::true_ { };
Modified: sandbox/coerce/boost/coerce/detail/qi.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/detail/qi.hpp (original)
+++ sandbox/coerce/boost/coerce/detail/qi.hpp 2011-06-11 19:23:56 EDT (Sat, 11 Jun 2011)
@@ -25,20 +25,19 @@
template <typename Target, typename Source>
static inline bool
call(Target & target, Source const & source) {
- typedef traits::string<Source> string_type;
- string_type string(source);
+ typedef traits::string<Source> string_traits;
- typedef typename string_type::size_type size_type;
- size_type size = string.size();
+ typename string_traits::size_type
+ length = string_traits::length(source);
+ detail::call_reserve(target, length);
- detail::call_reserve(target, size);
+ typename string_traits::const_iterator
+ begin = string_traits::begin(source), iterator = begin;
- typename string_type::const_iterator
- begin = string.begin(), iterator = begin, end = string.end();
+ bool result = spirit::qi::parse(
+ iterator, string_traits::end(source), target);
- bool result = spirit::qi::parse(iterator, end, target);
-
- if (static_cast<size_type>(iterator - begin) != size) {
+ if (static_cast<typename string_traits::size_type>(iterator - begin) != length) {
return false;
}
Modified: sandbox/coerce/boost/coerce/string.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/string.hpp (original)
+++ sandbox/coerce/boost/coerce/string.hpp 2011-06-11 19:23:56 EDT (Sat, 11 Jun 2011)
@@ -31,40 +31,31 @@
template <typename T>
struct string_impl_pointer<T, mpl::true_> {
typedef T * type;
-
- typedef T const * const_iterator;
- typedef std::size_t size_type;
- string_impl_pointer(T const * const value)
- : value_(value) { }
+ typedef T const *const_iterator;
+ typedef std::size_t size_type;
- inline const_iterator
- begin() const {
- return value_;
+ static inline const_iterator
+ begin(type const value) {
+ return value;
}
- inline const_iterator
- end() const {
- return value_ + size();
+ static inline const_iterator
+ end(type const value) {
+ return value + length(value) + 1;
}
- inline size_type
- size() const {
+ static inline size_type
+ length(type const value) {
return std::char_traits<
typename remove_const<T>::type
- >::length(value_);
+ >::length(value);
}
-
- private:
- T const * const value_;
};
template <typename T>
struct string_impl<T *>
- : string_impl_pointer<T> {
- string_impl(T const * const value)
- : string_impl_pointer<T>(value) { }
- };
+ : string_impl_pointer<T> { };
template <typename T, std::size_t N, typename U = typename is_char<T>::type>
struct string_impl_extent
@@ -74,37 +65,28 @@
struct string_impl_extent<T, N, mpl::true_> {
typedef T type[N];
- typedef T const * const_iterator;
+ typedef T const *const_iterator;
typedef std::size_t size_type;
- string_impl_extent(T const (& value)[N])
- : value_(value) { }
-
- inline const_iterator
- begin() const {
- return &value_[0];
+ static inline const_iterator
+ begin(type const & value) {
+ return &value[0];
}
- inline const_iterator
- end() const {
- return &value_[0] + size();
+ static inline const_iterator
+ end(type const & value) {
+ return &value[0] + length(value);
}
- inline size_type
- size() const {
- return value_[N - 1] == 0 ? N - 1 : N;
+ static inline size_type
+ length(type const & value) {
+ return value[N - 1] == 0 ? N - 1 : N;
}
-
- private:
- T const (& value_)[N];
};
template <typename T, std::size_t N>
struct string_impl<T [N]>
- : string_impl_extent<T, N> {
- string_impl(T const (& value)[N])
- : string_impl_extent<T, N>(value) { }
- };
+ : string_impl_extent<T, N> { };
template <typename T, typename Traits, typename Allocator>
struct string_impl<std::basic_string<T, Traits, Allocator> > {
@@ -113,34 +95,25 @@
typedef typename type::const_iterator const_iterator;
typedef typename type::size_type size_type;
- string_impl(type const & value)
- : value_(value) { }
-
- inline const_iterator
- begin() const {
- return value_.begin();
+ static inline const_iterator
+ begin(type const & value) {
+ return value.begin();
}
- inline const_iterator
- end() const {
- return value_.end();
+ static inline const_iterator
+ end(type const & value) {
+ return value.end();
}
- inline size_type
- size() const {
- return value_.size();
+ static inline size_type
+ length(type const & value) {
+ return value.length();
}
-
- private:
- type const & value_;
};
- template <typename T, typename Enable = void>
+ template <typename T>
struct string
- : string_impl<T> {
- string(T const & value)
- : string_impl<T>(value) { }
- };
+ : string_impl<T> { };
template <typename T>
struct is_string
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