vector.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__VECTOR_HPP )
00033 #define OESS_1__IO__CUSTOM__STL__VECTOR_HPP
00034 
00035 #include <vector>
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::vector< T > & o )
00054   {
00055     oess_1::defs::quantity_t q;
00056     s >> q;
00057     std::vector< T > tmp;
00058     if( q.value() )
00059       {
00060         tmp.reserve( q.value() );
00061         for( oess_1::uint_t c = q.value(); c; --c )
00062           {
00063             T next;
00064             s >> next;
00065             tmp.push_back( next );
00066           }
00067       }
00068 
00069     tmp.swap( o );
00070 
00071     return s;
00072   }
00073 
00078 template< class T >
00079 oess_1::io::ostream_t &
00080 operator<<( oess_1::io::ostream_t & s, const std::vector< T > & o )
00081   {
00082     oess_1::defs::quantity_t q( o.size() );
00083     s << q;
00084     for( typename std::vector< T >::const_iterator i = o.begin(), end = o.end();
00085         i != end; ++i )
00086       {
00087         s << *i;
00088       }
00089     return s;
00090   }
00091 
00092 } /* namespace io */
00093 
00094 } /* namespace oess_1 */
00095 
00096 #endif
00097 

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