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

ResDict.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_PAGE_RES_DICT_HEADER_INCLUDED__
00027 #define __PDF_PAGE_RES_DICT_HEADER_INCLUDED__
00028 
00029 #include <vector>
00030 #include <string>
00031 #include <boost/smart_ptr.hpp>
00032 #include <boost/iterator_adaptors.hpp>
00033 
00034 namespace pdf {
00035 
00036 namespace core
00037 {
00038     class CName ;
00039     class CObject ;
00040     class CFile ;
00041 }
00042 
00043 namespace font
00044 {
00045     class CFont ;
00046 }
00047 
00048 namespace graph
00049 {
00050     class CXObject ;
00051 }
00052 
00053 namespace page {
00054 
00060 class CResDict
00061 {
00062 private :
00063 
00064     template <typename T>
00065     class CResVec
00066     {
00067     private :
00068         typedef std::vector<boost::shared_ptr<T> >     CVec ;
00069         CVec m_vec ;
00070         int  m_counter ;
00071         const std::string m_prefix ;
00072 
00073     public :
00074         typedef typename
00075             boost::indirect_iterator_generator<typename CVec::const_iterator,
00076                                                T, const T&,
00077                                                std::random_access_iterator_tag,
00078                                                const T*>::type
00079             iterator ;
00080         
00081     public :
00082         CResVec( const std::string& prefix ) ;
00083         
00084         void Add( T *t ) ;
00085         core::CObject* Write( core::CFile& file ) const ;       
00086 
00087         bool Empty( ) const { return m_vec.empty( ) ; }
00088         
00089         bool Find( const T *t ) const ;
00090         
00091         iterator Begin( ) const ;
00092         iterator End( ) const ;
00093 
00094     private :
00095         const core::CName RegName( const std::string& prefix ) ;
00096     } ;
00097 
00098     CResVec<font::CFont>        m_fonts ;
00099     CResVec<graph::CXObject>    m_xobjs ;
00100 
00101 public :
00102     CResDict( ) ;
00103     ~CResDict( ) ;
00104     
00105     void AddFont( font::CFont *font ) ;
00106     void AddXObj( graph::CXObject *xobj ) ;
00107     
00108     core::CObject* Write( core::CFile& file ) const ;
00109 
00110     bool FindFont( const font::CFont *font ) const ;
00111     bool FindXObj( const graph::CXObject *xobj ) const ;
00112     
00113     bool HasFont( ) const ;
00114     bool HasXObj( ) const ;
00115 } ;
00116 
00117 } } // end of namespace
00118 
00119 #endif

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