Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

Array.hh

Go to the documentation of this file.
00001 /*
00002     libpdf++: a C++ Free library to generate PDF file
00003     Copyright (C) 2002 Nestal Wan
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2.1 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00026 #ifndef __PDF_CORE_ARRAY_HEADER_INCLUDED__
00027 #define __PDF_CORE_ARRAY_HEADER_INCLUDED__
00028 
00029 #ifndef __PDF_CORE_OBJECT_HEADER_INCLUDED__
00030 #include "Object.hh"
00031 #endif
00032 
00033 #ifndef __PDF_CORE_TYPE_HEADER_INCLUDED__
00034 #include "Type.hh"
00035 #endif
00036 
00037 // boost headers
00038 #include <boost/smart_ptr.hpp>
00039 #include <boost/iterator_adaptors.hpp>
00040 
00041 // standard headers
00042 #include <vector>
00043 #include <iterator>
00044 #include <iosfwd>
00045 
00046 namespace pdf { namespace core {
00047 
00059 class CArray : public CObject
00060 {
00061 private :
00063     typedef boost::shared_ptr<CObject> CObjPtr ;
00064     typedef std::vector<CObjPtr> CObjVec ;
00065 
00067     CObjVec m_objects ;
00068 
00069 public :
00070     typedef 
00071         boost::indirect_iterator_generator<CObjVec::const_iterator,
00072                                            CObject, const CObject&,
00073                                            std::random_access_iterator_tag,
00074                                            const CObject*>::type
00075         iterator ;
00076 
00077     typedef iterator::value_type value_type ;
00078     typedef iterator::reference  reference ;
00079     typedef iterator::reference  const_reference ;
00080     typedef CObjVec::size_type   size_type ;
00081 
00082 public :
00083     CArray( ) ;
00084     CArray( const CArray& array ) ;
00085     CArray( CObject *object ) ;
00086     ~CArray( ) ;
00087 
00096     template <typename InputIt>
00097     CArray( InputIt first, InputIt last )
00098     {
00099         typedef typename std::iterator_traits<InputIt>::value_type CRealType ;
00100         typedef typename CType2PDF<CRealType>::result CPDFType ;
00101 
00102         while ( first != last )
00103         {
00104             m_objects.push_back( CObjPtr( new CPDFType( *first ) ) ) ;
00105             ++first ;
00106         }
00107     }
00108 
00109     void push_back( CObject *object ) ;
00110 
00111     // STL style functions
00112     iterator begin( ) const ;
00113     iterator end( ) const ;
00114     size_type size( ) const ;
00115     bool empty( ) const ;
00116     void clear( ) ;
00117 
00118     std::ostream& Write( std::ostream& os ) const ;
00119 
00120     CObject* Dup( ) const ;
00121 } ;
00122 
00123 } } // end of namespace
00124 
00125 #endif

Generated on Sun Feb 2 09:16:04 2003 for libpdf++ by doxygen1.2.16