imgtools/imglib/boostlibrary/boost/optional/optional_io.hpp
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 13:59:58 +0800
changeset 712 df89378e9223
parent 600 6d08f4a05d93
permissions -rw-r--r--
Fix these errors: Some cases of PREQ1230 fail because of buildrom issue rombuild crashs when create ext-romimage readimage crashes on reading wk42 vasco_ui core image vc2008 compiling issues
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     1
// Copyright (C) 2005, Fernando Luis Cacciola Carballal.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     2
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     3
// Use, modification, and distribution is subject to the Boost Software
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     4
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     5
// http://www.boost.org/LICENSE_1_0.txt)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     6
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     7
// See http://www.boost.org/lib/optional for documentation.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     8
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     9
// You are welcome to contact the author at:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    10
//  fernando_cacciola@hotmail.com
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    11
//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    12
#ifndef BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    13
#define BOOST_OPTIONAL_OPTIONAL_IO_FLC_19NOV2002_HPP
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    14
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    15
#if defined __GNUC__
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    16
#  if (__GNUC__ == 2 && __GNUC_MINOR__ <= 97) 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    17
#    define BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
#  endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
#endif // __GNUC__
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
#if defined BOOST_OPTIONAL_NO_TEMPLATED_STREAMS
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
#  include <iostream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
#else 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
#  include <istream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
#  include <ostream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    26
#endif  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
#include "boost/optional/optional.hpp"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
#include "boost/utility/value_init.hpp"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
namespace boost
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
#if defined (BOOST_NO_TEMPLATED_STREAMS)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
template<class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
inline std::ostream& operator<<(std::ostream& out, optional<T> const& v)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
#else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
template<class CharType, class CharTrait, class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
inline
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
std::basic_ostream<CharType, CharTrait>&
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
operator<<(std::basic_ostream<CharType, CharTrait>& out, optional<T> const& v)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    43
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    44
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    45
  if ( out.good() )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    46
  {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    47
    if ( !v )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    48
         out << "--" ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    49
    else out << ' ' << *v ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
  }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
  return out;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
#if defined (BOOST_NO_TEMPLATED_STREAMS)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
template<class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    57
inline std::istream& operator>>(std::istream& in, optional<T>& v)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
#else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
template<class CharType, class CharTrait, class T>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
inline
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    61
std::basic_istream<CharType, CharTrait>&
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    65
  if ( in.good() )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    66
  {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    67
    int d = in.get();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    68
    if ( d == ' ' )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    69
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    70
      T x ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    71
      in >> x;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
      v = x ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    73
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    74
    else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    75
      v = optional<T>() ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    76
  }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    77
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    78
  return in;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    79
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    80
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    81
} // namespace boost
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    82
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    83
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    84