home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWSTD_IOTRAITS
- #define __RWSTD_IOTRAITS
- #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
-
- /***************************************************************************
- *
- * iotraits - Declarations for traits
- *
- * $Id: iotraits,v 1.7 1996/09/24 19:17:50 smithey Exp $
- *
- ***************************************************************************
- *
- * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
- * ALL RIGHTS RESERVED *
- * The software and information contained herein are proprietary to, and
- * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
- * intends to preserve as trade secrets such software and information.
- * This software is furnished pursuant to a written license agreement and
- * may be used, copied, transmitted, and stored only in accordance with
- * the terms of such license and with the inclusion of the above copyright
- * notice. This software and information or any other copies thereof may
- * not be provided or otherwise made available to any other person.
- *
- * Notwithstanding any other lease or license that may pertain to, or
- * accompany the delivery of, this computer software and information, the
- * rights of the Government regarding its use, reproduction and disclosure
- * are as set forth in Section 52.227-19 of the FARS Computer
- * Software-Restricted Rights clause.
- *
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
- * Technical Data and Computer Software clause at DFARS 252.227-7013.
- * Contractor/Manufacturer is Rogue Wave Software, Inc.,
- * P.O. Box 2328, Corvallis, Oregon 97339.
- *
- * This computer software and information is distributed with "restricted
- * rights." Use, duplication or disclosure is subject to restrictions as
- * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
- * Computer Software-Restricted Rights (April 1985)." If the Clause at
- * 18-52.227-74 "Rights in Data General" is specified in the contract,
- * then the "Alternate III" clause applies.
- *
- **************************************************************************/
-
- #include <iosfwd>
-
-
- #ifndef _RWSTD_NO_NAMESPACE
- namespace std {
- #endif
-
- /*
- * these are all necessary for the "traits" class
- */
-
- /*
- * MBSTATE_T
- *
- */
-
- // should come from the C library
- // not from there
-
- #ifdef _RWSTD_NO_MBSTATE_T
- struct _RWSTDExport mbstate_t {
-
- mbstate_t( long state=0 )
- : mbstate_(state) { ; }
-
- mbstate_t(const mbstate_t& state)
- : mbstate_(state.mbstate_) { ; }
-
- mbstate_t& operator=(const mbstate_t& state)
- {
- if ( &state != this )
- mbstate_= state.mbstate_;
-
- return *this;
- }
-
- mbstate_t& operator=(const long state)
- {
- mbstate_= state;
-
- return *this;
- }
-
- bool operator==(const mbstate_t& state) const
- {
- return ( mbstate_ == state.mbstate_ );
- }
-
- bool operator!=(const mbstate_t& state) const
- {
- return ( !(mbstate_ == state.mbstate_) );
- }
-
-
- long mbstate_;
-
- };
-
- #endif /* _RWSTD_NO_MBSTATE_T */
-
- /*
- * class FPOS
- *
- * it maintains all of the information necessary to restore an arbitrary
- * sequence, controlled by the Standard C++ library, to a previous stream
- * position and conversion state.
- */
-
-
- /*
- *
- * CLASS fpos
- *
- */
-
- #ifndef _RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES
- template <class stateT = mbstate_t>
- #else
- template <class stateT>
- #endif
- class _RWSTDExportTemplate fpos {
-
- public:
-
- typedef stateT state_type;
-
- inline fpos(long off = 0);
-
- inline fpos(long, long, state_type);
-
- #ifdef _RWSTD_NO_MBSTATE_T
- inline fpos(state_type);
- #endif
-
- inline bool good();
-
- inline operator long() const;
-
- inline fpos(const fpos<stateT>&);
- inline fpos<stateT>& operator= (const fpos<stateT>&);
-
- inline long offset (long);
- inline state_type state (state_type);
- inline long pos(long);
-
- inline long offset() const;
- inline long pos() const;
- inline state_type state () const;
-
- inline fpos<stateT>& operator+=(const fpos<stateT> &off);
- inline fpos<stateT> operator+(const fpos<stateT> &off) const;
- inline fpos<stateT>& operator-=(const fpos<stateT> &off);
- inline fpos<stateT> operator-(const fpos<stateT> &off) const;
-
- inline fpos<stateT>& operator+=(int off);
- inline fpos<stateT> operator+(int off) const;
- inline fpos<stateT>& operator-=(int off);
- inline fpos<stateT> operator-(int off) const;
-
- inline fpos<stateT>& operator+=(long off);
- inline fpos<stateT> operator+(long off) const;
- inline fpos<stateT>& operator-=(long off);
- inline fpos<stateT> operator-(long off) const;
-
- inline bool operator==(const fpos<stateT>& rhs) const;
- inline bool operator!=(const fpos<stateT>& rhs) const;
-
- inline bool operator< (const fpos<stateT>& rhs) const;
- inline bool operator> (const fpos<stateT>& rhs) const;
- inline bool operator<= (const fpos<stateT>& rhs) const;
- inline bool operator>= (const fpos<stateT>& rhs) const;
-
- inline bool operator==(const int& rhs) const;
- inline bool operator!=(const int& rhs) const;
-
- inline bool operator< (const int& rhs) const;
- inline bool operator> (const int& rhs) const;
- inline bool operator<= (const int& rhs) const;
- inline bool operator>= (const int& rhs) const;
-
- inline bool operator==(const long& rhs) const;
- inline bool operator!=(const long& rhs) const;
-
- inline bool operator< (const long& rhs) const;
- inline bool operator> (const long& rhs) const;
- inline bool operator<= (const long& rhs) const;
- inline bool operator>= (const long& rhs) const;
-
-
- private:
-
- long pos_; // signed displacement
- long fp_ ; // absolute position
- state_type state_; // conversion state
- bool status_; // status
- };
-
-
- /*
- *
- * CLASS fpos MEMBER FUNCTIONS
- *
- */
-
-
- /*
- * fpos(long)
- */
-
- template <class stateT>
- inline
- fpos<stateT>::fpos(long off)
- : pos_(off)
- , fp_(0)
- , state_(0)
- , status_(true)
- {
- if ( off == -1 ) status_ = false;
- }
-
- /*
- * fpos(stateT)
- */
- #ifdef _RWSTD_NO_MBSTATE_T
- template <class stateT>
- inline
- fpos<stateT>::fpos(stateT state)
- : pos_(0)
- , fp_(0)
- , state_(state)
- , status_(true)
- {;}
- #endif
-
- /*
- * fpos(long,fpos_t,state_type)
- */
-
- template <class stateT>
- inline
- fpos<stateT>::fpos(long off,long fposit,state_type state)
- : pos_(off)
- , fp_(fposit)
- , state_(state)
- , status_(true)
- { ; }
-
-
- /*
- * fpos(const fpos&)
- */
-
- template <class stateT>
- inline
- fpos<stateT>::fpos(const fpos<stateT>& str_pos)
- {
- pos_ = str_pos.pos_;
- fp_ = str_pos.fp_;
- state_ = str_pos.state_;
- status_ = str_pos.status_;
- }
-
-
- /*
- * int offset(long)
- */
-
- template <class stateT>
- inline long
- fpos<stateT>::offset(long off)
- {
- long var=pos_;
- pos_ = off;
-
- return var;
- }
-
- /*
- * long pos(long)
- */
-
- template <class stateT>
- inline long
- fpos<stateT>::pos(long posi)
- {
- long var=fp_;
- fp_ = posi;
-
- return var;
- }
-
-
- /*
- * state_type state(state_type)
- */
-
- template <class stateT>
- inline _TYPENAME fpos<stateT>::state_type
- fpos<stateT>::state(state_type state)
- {
- state_type var=state_;
- state_ = state;
-
- return var;
- }
-
-
- /*
- * bool good ( )
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::good()
- {
- return status_;
- }
-
-
- /*
- * operator long ( )
- */
-
- template <class stateT>
- inline fpos<stateT>::operator long() const
- {
- return (long)( fp_ + pos_ );
- }
-
- /*
- * fpos& operator=(const fpos&)
- */
-
- template <class stateT>
- inline fpos<stateT>&
- fpos<stateT>::operator=(const fpos<stateT>& str_pos)
- {
- if ( &str_pos != this )
- {
- pos_ = str_pos.pos_;
- fp_ = str_pos.fp_;
- state_ = str_pos.state_;
- status_ = str_pos.status_;
- }
-
- return *this;
- }
-
- /*
- * long pos() const
- */
-
- template <class stateT>
- inline long
- fpos<stateT>::pos() const
- {
- return fp_;
- }
-
-
- /*
- * long offset() const
- */
-
- template <class stateT>
- inline long
- fpos<stateT>::offset() const
- {
- return pos_;
- }
-
- /*
- * state_type state() const
- */
-
- template <class stateT>
- inline _TYPENAME fpos<stateT>::state_type
- fpos<stateT>::state() const
- {
- return state_;
- }
-
-
- /*
- * fpos& operator+=(const fpos&)
- */
-
- template <class stateT>
- inline fpos<stateT>&
- fpos<stateT>::operator+=(const fpos<stateT>& off)
- {
- pos_ += off.pos_ + off.fp_;
-
- return *this;
- }
-
- /*
- * fpos operator+(const fpos&) const
- */
-
- template <class stateT>
- inline fpos<stateT>
- fpos<stateT>::operator+(const fpos<stateT>& off) const
- {
- fpos<stateT> temp(*this);
- temp.pos_ += off.pos_ + off.fp_;
- return temp;
- }
-
- /*
- * fpos operator-(const fpos<stateT>& off) const
- */
-
- template <class stateT>
- inline fpos<stateT>
- fpos<stateT>::operator-(const fpos<stateT>& off) const
- {
- fpos<stateT> temp(*this);
- temp.pos_ -= (off.pos_ + off.fp_);
- return temp;
- }
-
-
- /*
- * fpos& operator-=(const fpos&)
- */
-
- template <class stateT>
- inline fpos<stateT>&
- fpos<stateT>::operator-=(const fpos<stateT>& off)
- {
- pos_ -= (off.pos_ + off.fp_);
-
- return *this;
- }
-
-
- /*
- * fpos& operator+=(int)
- */
-
- template <class stateT>
- inline fpos<stateT>&
- fpos<stateT>::operator+=(int off)
- {
- pos_ += off;
-
- return *this;
- }
-
- /*
- * fpos operator+(int) const
- */
-
- template <class stateT>
- inline fpos<stateT>
- fpos<stateT>::operator+(int off) const
- {
- fpos<stateT> temp(*this);
- temp.pos_ += off;
- return temp;
- }
-
- /*
- * fpos operator-(int off) const
- */
-
- template <class stateT>
- inline fpos<stateT>
- fpos<stateT>::operator-(int off) const
- {
- fpos<stateT> temp(*this);
- temp.pos_ -= off;
- return temp;
- }
-
-
- /*
- * fpos& operator-=(int)
- */
-
- template <class stateT>
- inline fpos<stateT>&
- fpos<stateT>::operator-=(int off)
- {
- pos_ -= off;
-
- return *this;
- }
-
- /*
- * fpos& operator-=(long)
- */
-
- template <class stateT>
- inline fpos<stateT>&
- fpos<stateT>::operator-=(long off)
- {
- pos_ -= off;
-
- return *this;
- }
-
- /*
- * fpos operator-(long off) const
- */
-
- template <class stateT>
- inline fpos<stateT>
- fpos<stateT>::operator-(long off) const
- {
- fpos<stateT> temp(*this);
- temp.pos_ -= off;
- return temp;
- }
-
- /*
- * fpos& operator+=(long)
- */
-
- template <class stateT>
- inline fpos<stateT>&
- fpos<stateT>::operator+=(long off)
- {
- pos_ += off;
-
- return *this;
- }
-
- /*
- * fpos operator+(long) const
- */
-
- template <class stateT>
- inline fpos<stateT>
- fpos<stateT>::operator+(long off) const
- {
- fpos<stateT> temp(*this);
- temp.pos_ += off;
- return temp;
- }
-
-
- /*
- * bool operator==(const fpos&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator==(const fpos<stateT>& pos) const
- {
- if ( !(status_ || pos.status_) ) return true;
- return ( ( (pos_+fp_) == (pos.pos_+pos.fp_) ) && ( state_ == pos.state_ )
- && ( status_ == pos.status_ ) );
- }
-
- /*
- * bool operator!=(const fpos&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator!=(const fpos<stateT>& pos) const
- {
- return !(*this == pos);
- }
-
-
- /*
- * bool operator< (const fpos&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator< (const fpos<stateT>& pos) const
- {
- return ( (pos_+fp_) < (pos.pos_ + pos.fp_) );
- }
-
- /*
- * bool operator> (const fpos&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator> (const fpos<stateT>& pos) const
- {
- return ( (pos_+fp_) > (pos.pos_ + pos.fp_) );
- }
-
- /*
- * bool operator<= (const fpos&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator<= (const fpos<stateT>& pos) const
- {
- return ( (pos_+fp_) <= (pos.pos_ + pos.fp_) );
- }
-
- /*
- * bool operator>= (const fpos&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator>= (const fpos<stateT>& pos) const
- {
- return ( (pos_+fp_) >= (pos.pos_ + pos.fp_) );
- }
-
-
- /*
- * bool operator==(const int&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator==(const int& pos) const
- {
- return ( (pos_+fp_) == pos );
- }
-
- /*
- * bool operator!=(const int&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator!=(const int& pos) const
- {
- return !(*this == pos);
- }
-
-
- /*
- * bool operator< (const int&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator< (const int& pos) const
- {
- return ( (pos_+fp_) < pos );
- }
-
- /*
- * bool operator> (const int&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator> (const int& pos) const
- {
- return ( (pos_+fp_) > pos );
- }
-
- /*
- * bool operator<= (const int&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator<= (const int& pos) const
- {
- return ( (pos_+fp_) <= pos );
- }
-
- /*
- * bool operator>= (const int&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator>= (const int& pos) const
- {
- return ( (pos_+fp_) >= pos );
- }
-
-
- /*
- * bool operator==(const long&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator==(const long& pos) const
- {
- return ( (pos_+fp_) == pos );
- }
-
- /*
- * bool operator!=(const long&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator!=(const long& pos) const
- {
- return !(*this == pos);
- }
-
- /*
- * bool operator< (const long&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator< (const long& pos) const
- {
- return ( (pos_+fp_) < pos );
- }
-
- /*
- * bool operator> (const long&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator> (const long& pos) const
- {
- return ( (pos_+fp_) > pos );
- }
-
- /*
- * bool operator<= (const long&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator<= (const long& pos) const
- {
- return ( (pos_+fp_) >= pos );
- }
-
- /*
- * bool operator>= (const long&) const
- */
-
- template <class stateT>
- inline bool
- fpos<stateT>::operator>= (const long& pos) const
- {
- return ( (pos_+fp_) <= pos );
- }
-
- #ifndef _RWSTD_NO_NAMESPACE
- }
- #endif
-
- #pragma option pop
- #endif // __RWSTD_IOTRAITS
-