Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_INTERVAL_IO_BOOST_INTERVAL_IO_H
00002 #define OPENTISSUE_CORE_MATH_INTERVAL_IO_BOOST_INTERVAL_IO_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <boost/numeric/interval.hpp>
00013
00014 #include <iosfwd>
00015
00016 namespace OpenTissue
00017 {
00018 namespace math
00019 {
00020 namespace interval
00021 {
00022
00031 template<class T, class Policies, class CharType, class CharTraits>
00032 std::basic_ostream<CharType, CharTraits> & operator<<(
00033 std::basic_ostream<CharType, CharTraits> &stream
00034 , boost::numeric::interval<T, Policies> const & value
00035 )
00036 {
00037 if (empty(value))
00038 {
00039 return stream << "[]";
00040 }
00041 else
00042 {
00043 return stream << '[' << lower(value) << ',' << upper(value) << ']';
00044 }
00045 }
00046
00055 template<class T, class Policies, class CharType, class CharTraits>
00056 std::basic_istream<CharType, CharTraits> & operator>>(
00057 std::basic_istream<CharType, CharTraits> & stream
00058 , boost::numeric::interval<T, Policies> & value
00059 )
00060 {
00061 T l, u;
00062 char c = 0;
00063 stream >> c;
00064 if (c == '[')
00065 {
00066 stream >> l >> c;
00067 if (c == ',')
00068 stream >> u >> c;
00069 else
00070 u = l;
00071 if (c != ']')
00072 stream.setstate(stream.failbit);
00073 }
00074 else
00075 {
00076 stream.putback(c);
00077 stream >> l;
00078 u = l;
00079 }
00080 if (stream)
00081 value.assign(l, u);
00082 else
00083 value = boost::numeric::interval<T, Policies>::empty();
00084 return stream;
00085 }
00086
00087
00088 }
00089 }
00090 }
00091
00092
00093 #endif