Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:09:08

0001 /*=============================================================================
0002     Phoenix V1.2.1
0003     Copyright (c) 2001-2002 Joel de Guzman
0004 
0005   Distributed under the Boost Software License, Version 1.0. (See accompanying
0006   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #ifndef BOOST_SPIRIT_CLASSIC_PHOENIX_SPECIAL_OPS_HPP
0009 #define BOOST_SPIRIT_CLASSIC_PHOENIX_SPECIAL_OPS_HPP
0010 
0011 #include <boost/config.hpp>
0012 #ifdef BOOST_NO_STRINGSTREAM
0013 #include <strstream>
0014 #define PHOENIX_SSTREAM strstream
0015 #else
0016 #include <sstream>
0017 #define PHOENIX_SSTREAM stringstream
0018 #endif
0019 
0020 ///////////////////////////////////////////////////////////////////////////////
0021 #include <boost/spirit/home/classic/phoenix/operators.hpp>
0022 #include <iosfwd>
0023 #include <complex>
0024 
0025 ///////////////////////////////////////////////////////////////////////////////
0026 #if defined(_STLPORT_VERSION) && defined(__STL_USE_OWN_NAMESPACE)
0027 #define PHOENIX_STD _STLP_STD
0028 #define PHOENIX_NO_STD_NAMESPACE
0029 #else
0030 #define PHOENIX_STD std
0031 #endif
0032 
0033 ///////////////////////////////////////////////////////////////////////////////
0034 namespace phoenix
0035 {
0036 
0037 ///////////////////////////////////////////////////////////////////////////////
0038 //
0039 //  The following specializations take into account the C++ standard
0040 //  library components. There are a couple of issues that have to be
0041 //  dealt with to enable lazy operator overloads for the standard
0042 //  library classes.
0043 //
0044 //      *iostream (e.g. cout, cin, strstream/ stringstream) uses non-
0045 //      canonical shift operator overloads where the lhs is taken in
0046 //      by reference.
0047 //
0048 //      *I/O manipulators overloads for the RHS of the << and >>
0049 //      operators.
0050 //
0051 //      *STL iterators can be objects that conform to pointer semantics.
0052 //      Some operators need to be specialized for these.
0053 //
0054 //      *std::complex is given a rank (see rank class in operators.hpp)
0055 //
0056 ///////////////////////////////////////////////////////////////////////////////
0057 
0058 ///////////////////////////////////////////////////////////////////////////////
0059 //
0060 //  specialization for rank<std::complex>
0061 //
0062 ///////////////////////////////////////////////////////////////////////////////
0063 template <typename T> struct rank<PHOENIX_STD::complex<T> >
0064 { static int const value = 170 + rank<T>::value; };
0065 
0066 ///////////////////////////////////////////////////////////////////////////////
0067 //
0068 //  specializations for std::istream
0069 //
0070 ///////////////////////////////////////////////////////////////////////////////
0071 
0072 //////////////////////////////////
0073 template <typename T1>
0074 struct binary_operator<shift_r_op, PHOENIX_STD::istream, T1>
0075 {
0076     typedef PHOENIX_STD::istream& result_type;
0077     static result_type eval(PHOENIX_STD::istream& out, T1& rhs)
0078     { return out >> rhs; }
0079 };
0080 
0081 //////////////////////////////////
0082 template <typename BaseT>
0083 inline typename impl::make_binary3
0084     <shift_r_op, variable<PHOENIX_STD::istream>, BaseT>::type
0085 operator>>(PHOENIX_STD::istream& _0, actor<BaseT> const& _1)
0086 {
0087     return impl::make_binary3
0088     <shift_r_op, variable<PHOENIX_STD::istream>, BaseT>
0089     ::construct(var(_0), _1);
0090 }
0091 
0092 ///////////////////////////////////////////////////////////////////////////////
0093 //
0094 //  specializations for std::ostream
0095 //
0096 ///////////////////////////////////////////////////////////////////////////////
0097 
0098 //////////////////////////////////
0099 template <typename T1>
0100 struct binary_operator<shift_l_op, PHOENIX_STD::ostream, T1>
0101 {
0102     typedef PHOENIX_STD::ostream& result_type;
0103     static result_type eval(PHOENIX_STD::ostream& out, T1 const& rhs)
0104     { return out << rhs; }
0105 };
0106 
0107 //////////////////////////////////
0108 template <typename BaseT>
0109 inline typename impl::make_binary3
0110     <shift_l_op, variable<PHOENIX_STD::ostream>, BaseT>::type
0111 operator<<(PHOENIX_STD::ostream& _0, actor<BaseT> const& _1)
0112 {
0113     return impl::make_binary3
0114     <shift_l_op, variable<PHOENIX_STD::ostream>, BaseT>
0115     ::construct(var(_0), _1);
0116 }
0117 
0118 ///////////////////////////////////////////////////////////////////////////////
0119 //
0120 //  specializations for std::strstream / stringstream
0121 //
0122 ///////////////////////////////////////////////////////////////////////////////
0123 template <typename T1>
0124 struct binary_operator<shift_r_op, PHOENIX_STD::PHOENIX_SSTREAM, T1>
0125 {
0126     typedef PHOENIX_STD::istream& result_type;
0127     static result_type eval(PHOENIX_STD::istream& out, T1& rhs)
0128     { return out >> rhs; }
0129 };
0130 
0131 //////////////////////////////////
0132 template <typename BaseT>
0133 inline typename impl::make_binary3
0134     <shift_r_op, variable<PHOENIX_STD::PHOENIX_SSTREAM>, BaseT>::type
0135 operator>>(PHOENIX_STD::PHOENIX_SSTREAM& _0, actor<BaseT> const& _1)
0136 {
0137     return impl::make_binary3
0138     <shift_r_op, variable<PHOENIX_STD::PHOENIX_SSTREAM>, BaseT>
0139     ::construct(var(_0), _1);
0140 }
0141 
0142 //////////////////////////////////
0143 template <typename T1>
0144 struct binary_operator<shift_l_op, PHOENIX_STD::PHOENIX_SSTREAM, T1>
0145 {
0146     typedef PHOENIX_STD::ostream& result_type;
0147     static result_type eval(PHOENIX_STD::ostream& out, T1 const& rhs)
0148     { return out << rhs; }
0149 };
0150 
0151 //////////////////////////////////
0152 template <typename BaseT>
0153 inline typename impl::make_binary3
0154     <shift_l_op, variable<PHOENIX_STD::PHOENIX_SSTREAM>, BaseT>::type
0155 operator<<(PHOENIX_STD::PHOENIX_SSTREAM& _0, actor<BaseT> const& _1)
0156 {
0157     return impl::make_binary3
0158     <shift_l_op, variable<PHOENIX_STD::PHOENIX_SSTREAM>, BaseT>
0159     ::construct(var(_0), _1);
0160 }
0161 
0162 ///////////////////////////////////////////////////////////////////////////////
0163 //
0164 //      I/O manipulator specializations
0165 //
0166 ///////////////////////////////////////////////////////////////////////////////
0167 
0168 typedef PHOENIX_STD::ios_base&  (*iomanip_t)(PHOENIX_STD::ios_base&);
0169 typedef PHOENIX_STD::istream&   (*imanip_t)(PHOENIX_STD::istream&);
0170 typedef PHOENIX_STD::ostream&   (*omanip_t)(PHOENIX_STD::ostream&);
0171 
0172 #if defined(BOOST_BORLANDC)
0173 
0174 ///////////////////////////////////////////////////////////////////////////////
0175 //
0176 //      Borland does not like i/o manipulators functions such as endl to
0177 //      be the rhs of a lazy << operator (Borland incorrectly reports
0178 //      ambiguity). To get around the problem, we provide function
0179 //      pointer versions of the same name with a single trailing
0180 //      underscore.
0181 //
0182 //      You can use the same trick for other i/o manipulators.
0183 //      Alternatively, you can prefix the manipulator with a '&'
0184 //      operator. Example:
0185 //
0186 //          cout << arg1 << &endl
0187 //
0188 ///////////////////////////////////////////////////////////////////////////////
0189 
0190 imanip_t    ws_     = &PHOENIX_STD::ws;
0191 iomanip_t   dec_    = &PHOENIX_STD::dec;
0192 iomanip_t   hex_    = &PHOENIX_STD::hex;
0193 iomanip_t   oct_    = &PHOENIX_STD::oct;
0194 omanip_t    endl_   = &PHOENIX_STD::endl;
0195 omanip_t    ends_   = &PHOENIX_STD::ends;
0196 omanip_t    flush_  = &PHOENIX_STD::flush;
0197 
0198 #else // BOOST_BORLANDC
0199 
0200 ///////////////////////////////////////////////////////////////////////////////
0201 //
0202 //      The following are overloads for I/O manipulators.
0203 //
0204 ///////////////////////////////////////////////////////////////////////////////
0205 template <typename BaseT>
0206 inline typename impl::make_binary1<shift_l_op, BaseT, imanip_t>::type
0207 operator>>(actor<BaseT> const& _0, imanip_t _1)
0208 {
0209     return impl::make_binary1<shift_l_op, BaseT, imanip_t>::construct(_0, _1);
0210 }
0211 
0212 //////////////////////////////////
0213 template <typename BaseT>
0214 inline typename impl::make_binary1<shift_l_op, BaseT, iomanip_t>::type
0215 operator>>(actor<BaseT> const& _0, iomanip_t _1)
0216 {
0217     return impl::make_binary1<shift_l_op, BaseT, iomanip_t>::construct(_0, _1);
0218 }
0219 
0220 //////////////////////////////////
0221 template <typename BaseT>
0222 inline typename impl::make_binary1<shift_l_op, BaseT, omanip_t>::type
0223 operator<<(actor<BaseT> const& _0, omanip_t _1)
0224 {
0225     return impl::make_binary1<shift_l_op, BaseT, omanip_t>::construct(_0, _1);
0226 }
0227 
0228 //////////////////////////////////
0229 template <typename BaseT>
0230 inline typename impl::make_binary1<shift_l_op, BaseT, iomanip_t>::type
0231 operator<<(actor<BaseT> const& _0, iomanip_t _1)
0232 {
0233     return impl::make_binary1<shift_l_op, BaseT, iomanip_t>::construct(_0, _1);
0234 }
0235 
0236 #endif // BOOST_BORLANDC
0237 
0238 ///////////////////////////////////////////////////////////////////////////////
0239 //
0240 //  specializations for stl iterators and containers
0241 //
0242 ///////////////////////////////////////////////////////////////////////////////
0243 template <typename T>
0244 struct unary_operator<dereference_op, T>
0245 {
0246     typedef typename T::reference result_type;
0247     static result_type eval(T const& iter)
0248     { return *iter; }
0249 };
0250 
0251 //////////////////////////////////
0252 template <typename T0, typename T1>
0253 struct binary_operator<index_op, T0, T1>
0254 {
0255     typedef typename T0::reference result_type;
0256     static result_type eval(T0& container, T1 const& index)
0257     { return container[index]; }
0258 };
0259 
0260 //////////////////////////////////
0261 template <typename T0, typename T1>
0262 struct binary_operator<index_op, T0 const, T1>
0263 {
0264     typedef typename T0::const_reference result_type;
0265     static result_type eval(T0 const& container, T1 const& index)
0266     { return container[index]; }
0267 };
0268 
0269 ///////////////////////////////////////////////////////////////////////////////
0270 }   //  namespace phoenix
0271 
0272 #undef PHOENIX_SSTREAM
0273 #undef PHOENIX_STD
0274 #endif