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

Dictionary.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_DICTIONARY_HEADER_INCLUDED__
00027 #define __PDF_CORE_DICTIONARY_HEADER_INCLUDED__
00028 
00029 #ifndef __PDF_CORE_OBJECT_HEADER_INCLUDED__
00030 #include "Object.hh"
00031 #endif
00032 
00033 #include <vector>
00034 #include <utility>
00035 #include <iosfwd>
00036 
00037 namespace pdf { namespace core {
00038 
00050 class CDictionary : public CObject
00051 {
00052 private :
00054     typedef boost::shared_ptr<CObject> CObjPtr ;
00055 
00057     typedef std::pair<CName, CObjPtr> CKeyPair ;
00058 
00060     typedef std::vector<CKeyPair> CPairVec ;
00061 
00063     CPairVec m_pairs ;
00064 
00065 public :
00066     typedef CPairVec::const_iterator iterator ;        
00067     typedef CPairVec::value_type     value_type ;      
00068 
00069 public :
00070     CDictionary( ) { }   
00071     ~CDictionary( ) { }  
00072 
00073 
00074     CDictionary( const CDictionary& dict ) ;
00075 
00079     template <typename InputIt>
00080     CDictionary( InputIt first, InputIt last )
00081         : m_pairs( first, last )
00082     {
00083     }
00084     
00085     CDictionary( const CName& name, CObject *object ) ;
00086     
00087     void AddPair( const CName& name, CObject *object ) ;
00088     
00090     void AddPair( const std::string& name, const std::string& val_name )
00091         { AddPair( CName( name ), new CName( val_name ) ) ; }
00092 
00094     void AddPair( const std::string& name, CObject *object )
00095         { AddPair( CName( name ), object ) ; }
00096 
00098     iterator begin( ) const { return m_pairs.begin( ) ; }
00099 
00101     iterator end( ) const { return m_pairs.end( ) ; }
00102 
00103     std::ostream& Write( std::ostream& os ) const ;
00104 
00105     CObject* Dup( ) const ;
00106 
00107     boost::shared_ptr<CObject>& operator[]( const std::string& name ) ;
00108 
00110     void clear( ) { m_pairs.clear( ) ; }
00111 } ;
00112 
00113 } } // end of namespace
00114 
00115 #endif

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