set.hpp

См. документацию.
00001 /*
00002 
00003 oess_1: Object Entity Serialization & Stability
00004 Yauheni A. Akhotnikau (C) 2002-2006
00005 eao197@yahoo.com
00006 -------------------------------------------------
00007 
00008 Permission is granted to anyone to use this software for any purpose on any
00009 computer system, and to redistribute it freely, subject to the following
00010 restrictions:
00011 
00012 1. This software is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00015 
00016 2. The origin of this software must not be misrepresented, either by
00017    explicit claim or by omission.
00018 
00019 3. Altered versions must be plainly marked as such, and must not be
00020    misrepresented as being the original software.
00021 
00022 -------------------------------------------------
00023 
00024 */
00025 
00032 #if !defined( OESS_1__IO__CUSTOM__STL__SET_HPP )
00033 #define OESS_1__IO__CUSTOM__STL__SET_HPP
00034 
00035 #include <set>
00036 
00037 #include <oess_1/defs/h/quantity.hpp>
00038 
00039 #include <oess_1/io/h/stream.hpp>
00040 
00041 namespace oess_1
00042 {
00043 
00044 namespace io
00045 {
00046 
00051 template< class T >
00052 oess_1::io::istream_t &
00053 operator>>( oess_1::io::istream_t & s, std::set< T > & o )
00054   {
00055     oess_1::defs::quantity_t q;
00056     s >> q;
00057     std::set< T > tmp;
00058     for( oess_1::uint_t c = q.value(); c; --c )
00059       {
00060         T next;
00061         s >> next;
00062         tmp.insert( next );
00063       }
00064 
00065     tmp.swap( o );
00066 
00067     return s;
00068   }
00069 
00074 template< class T >
00075 oess_1::io::istream_t &
00076 operator>>( oess_1::io::istream_t & s, std::multiset< T > & o )
00077   {
00078     oess_1::defs::quantity_t q;
00079     s >> q;
00080     std::multiset< T > tmp;
00081     for( oess_1::uint_t c = q.value(); c; --c )
00082       {
00083         T next;
00084         s >> next;
00085         tmp.insert( next );
00086       }
00087 
00088     tmp.swap( o );
00089 
00090     return s;
00091   }
00092 
00097 template< class T >
00098 oess_1::io::ostream_t &
00099 operator<<( oess_1::io::ostream_t & s, const std::set< T > & o )
00100   {
00101     oess_1::defs::quantity_t q( o.size() );
00102     s << q;
00103     for( typename std::set< T >::const_iterator i = o.begin(), end = o.end();
00104         i != end; ++i )
00105       {
00106         s << *i;
00107       }
00108     return s;
00109   }
00110 
00115 template< class T >
00116 oess_1::io::ostream_t &
00117 operator<<( oess_1::io::ostream_t & s, const std::multiset< T > & o )
00118   {
00119     oess_1::defs::quantity_t q( o.size() );
00120     s << q;
00121     for( typename std::multiset< T >::const_iterator i = o.begin(), end = o.end();
00122         i != end; ++i )
00123       {
00124         s << *i;
00125       }
00126     return s;
00127   }
00128 
00129 } /* namespace io */
00130 
00131 } /* namespace oess_1 */
00132 
00133 #endif
00134 

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:36 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz