Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66347 - in sandbox/chrono/boost/chrono: . detail
From: vicente.botet_at_[hidden]
Date: 2010-11-01 20:55:44


Author: viboes
Date: 2010-11-01 20:55:41 EDT (Mon, 01 Nov 2010)
New Revision: 66347
URL: http://svn.boost.org/trac/boost/changeset/66347

Log:
Chrono: Remove Input part from chrono_io + Fix bug

Removed:
   sandbox/chrono/boost/chrono/detail/scan_keyword.hpp
Text files modified:
   sandbox/chrono/boost/chrono/chrono_io.hpp | 7 +++++++
   sandbox/chrono/boost/chrono/duration.hpp | 2 +-
   2 files changed, 8 insertions(+), 1 deletions(-)

Modified: sandbox/chrono/boost/chrono/chrono_io.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/chrono_io.hpp (original)
+++ sandbox/chrono/boost/chrono/chrono_io.hpp 2010-11-01 20:55:41 EDT (Mon, 01 Nov 2010)
@@ -20,7 +20,9 @@
 #include <boost/type_traits/is_signed.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/math/common_factor_rt.hpp>
+#ifdef BOOST_CHRONO_IO_INPUT
 #include <boost/chrono/detail/scan_keyword.hpp>
+#endif
 
 namespace boost
 {
@@ -205,6 +207,8 @@
 };
 
 }
+
+#ifdef BOOST_CHRONO_IO_INPUT
 template <class CharT, class Traits, class Rep, class Period>
 std::basic_istream<CharT, Traits>&
 operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
@@ -467,6 +471,7 @@
         is.setstate(is.failbit);
     return is;
 }
+#endif
 
 template <class Clock, class CharT>
 struct clock_string;
@@ -614,6 +619,7 @@
     return os << tp.time_since_epoch() << clock_string<Clock, CharT>::since();
 }
 
+#ifdef BOOST_CHRONO_IO_INPUT
 template <class CharT, class Traits, class Clock, class Duration>
 std::basic_istream<CharT, Traits>&
 operator>>(std::basic_istream<CharT, Traits>& is,
@@ -644,6 +650,7 @@
         is.setstate(is.failbit);
     return is;
 }
+#endif
 } // chrono
 
 }

Deleted: sandbox/chrono/boost/chrono/detail/scan_keyword.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/scan_keyword.hpp 2010-11-01 20:55:41 EDT (Mon, 01 Nov 2010)
+++ (empty file)
@@ -1,153 +0,0 @@
-// scan_keyword.hpp --------------------------------------------------------------//
-
-// (C) Copyright Howard Hinnant
-// Copyright 2010 Vicente J. Botet Escriba
-
-// Distributed under the Boost Software License, Version 1.0.
-// See http://www.boost.org/LICENSE_1_0.txt
-
-#ifndef BOOST_CHRONO_DETAIL_SCAN_KEYWORD_HPP
-#define BOOST_CHRONO_DETAIL_SCAN_KEYWORD_HPP
-
-#include <boost/chrono/config.hpp>
-#include <boost/interprocess/smart_ptr/unique_ptr.hpp>
-#include <ios>
-#include <exception>
-
-namespace boost {
- using interprocess::unique_ptr;
-
-namespace chrono {
-namespace chrono_detail {
-
-// scan_keyword
-// Scans [b, e) until a match is found in the basic_strings range
-// [kb, ke) or until it can be shown that there is no match in [kb, ke).
-// b will be incremented (visibly), consuming CharT until a match is found
-// or proved to not exist. A keyword may be "", in which will match anything.
-// If one keyword is a prefix of another, and the next CharT in the input
-// might match another keyword, the algorithm will attempt to find the longest
-// matching keyword. If the longer matching keyword ends up not matching, then
-// no keyword match is found. If no keyword match is found, ke is returned
-// and failbit is set in err.
-// Else an iterator pointing to the matching keyword is found. If more than
-// one keyword matches, an iterator to the first matching keyword is returned.
-// If on exit b == e, eofbit is set in err. If case_senstive is false,
-// ct is used to force to lower case before comparing characters.
-// Examples:
-// Keywords: "a", "abb"
-// If the input is "a", the first keyword matches and eofbit is set.
-// If the input is "abc", no match is found and "ab" are consumed.
-
-template <class InputIterator, class ForwardIterator, class Ctype>
-ForwardIterator
-scan_keyword(InputIterator& b, InputIterator e,
- ForwardIterator kb, ForwardIterator ke,
- const Ctype& ct, std::ios_base::iostate& err,
- bool case_sensitive = true)
-{
- typedef typename std::iterator_traits<InputIterator>::value_type CharT;
- size_t nkw = std::distance(kb, ke);
- const unsigned char doesnt_match = '\0';
- const unsigned char might_match = '\1';
- const unsigned char does_match = '\2';
- unsigned char statbuf[100];
- unsigned char* status = statbuf;
- unique_ptr<unsigned char, void(*)(void*)> stat_hold(0, free);
- if (nkw > sizeof(statbuf))
- {
- status = (unsigned char*)malloc(nkw);
- if (status == 0)
- throw std::bad_alloc();
- stat_hold.reset(status);
- }
- size_t n_might_match = nkw; // At this point, any keyword might match
- size_t n_does_match = 0; // but none of them definitely do
- // Initialize all statuses to might_match, except for "" keywords are does_match
- unsigned char* st = status;
- for (ForwardIterator ky = kb; ky != ke; ++ky, ++st)
- {
- if (!ky->empty())
- *st = might_match;
- else
- {
- *st = does_match;
- --n_might_match;
- ++n_does_match;
- }
- }
- // While there might be a match, test keywords against the next CharT
- for (size_t indx = 0; b != e && n_might_match > 0; ++indx)
- {
- // Peek at the next CharT but don't consume it
- CharT c = *b;
- if (!case_sensitive)
- c = ct.toupper(c);
- bool consume = false;
- // For each keyword which might match, see if the indx character is c
- // If a match if found, consume c
- // If a match is found, and that is the last character in the keyword,
- // then that keyword matches.
- // If the keyword doesn't match this character, then change the keyword
- // to doesn't match
- st = status;
- for (ForwardIterator ky = kb; ky != ke; ++ky, ++st)
- {
- if (*st == might_match)
- {
- CharT kc = (*ky)[indx];
- if (!case_sensitive)
- kc = ct.toupper(kc);
- if (c == kc)
- {
- consume = true;
- if (ky->size() == indx+1)
- {
- *st = does_match;
- --n_might_match;
- ++n_does_match;
- }
- }
- else
- {
- *st = doesnt_match;
- --n_might_match;
- }
- }
- }
- // consume if we matched a character
- if (consume)
- {
- ++b;
- // If we consumed a character and there might be a matched keyword that
- // was marked matched on a previous iteration, then such keywords
- // which are now marked as not matching.
- if (n_might_match + n_does_match > 1)
- {
- st = status;
- for (ForwardIterator ky = kb; ky != ke; ++ky, ++st)
- {
- if (*st == does_match && ky->size() != indx+1)
- {
- *st = doesnt_match;
- --n_does_match;
- }
- }
- }
- }
- }
- // We've exited the loop because we hit eof and/or we have no more "might matches".
- if (b == e)
- err |= std::ios_base::eofbit;
- // Return the first matching result
- for (st = status; kb != ke; ++kb, ++st)
- if (*st == does_match)
- break;
- if (kb == ke)
- err |= std::ios_base::failbit;
- return kb;
-}
-}
-}
-}
-#endif // BOOST_CHRONO_DETAIL_SCAN_KEYWORD_HPP

Modified: sandbox/chrono/boost/chrono/duration.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/duration.hpp (original)
+++ sandbox/chrono/boost/chrono/duration.hpp 2010-11-01 20:55:41 EDT (Mon, 01 Nov 2010)
@@ -406,7 +406,7 @@
     //BOOST_CHRONO_STATIC_ASSERT(boost::is_integral<Rep>::value, BOOST_CHRONO_A_DURATION_REPRESENTATION_MUST_BE_INTEGRAL, ());
     BOOST_CHRONO_STATIC_ASSERT(!boost::chrono::detail::is_duration<Rep>::value,
             BOOST_CHRONO_A_DURATION_REPRESENTATION_CAN_NOT_BE_A_DURATION, ());
- BOOST_CHRONO_STATIC_ASSERT(boost::ratio_detail::is_ratio<Period>::value,
+ BOOST_CHRONO_STATIC_ASSERT(boost::ratio_detail::is_ratio<typename Period::type>::value,
             BOOST_CHRONO_SECOND_TEMPLATE_PARAMETER_OF_DURATION_MUST_BE_A_STD_RATIO, ());
     BOOST_CHRONO_STATIC_ASSERT(Period::num>0,
             BOOST_CHRONO_DURATION_PERIOD_MUST_BE_POSITIVE, ());


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