00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00026 #ifndef __PDF_CORE_OBJECT_HEADER_INCLUDED__
00027 #define __PDF_CORE_OBJECT_HEADER_INCLUDED__
00028
00029 #include <boost/smart_ptr.hpp>
00030
00031 #include <iosfwd>
00032 #include <string>
00033
00034 namespace pdf { namespace core {
00035
00036 typedef int pdfid_t ;
00037
00050 class CObject
00051 {
00052 public :
00054 virtual ~CObject( ) ;
00055
00057 virtual std::ostream& Write( std::ostream& os ) const = 0 ;
00058
00060 virtual CObject* Dup( ) const = 0 ;
00061 } ;
00062
00073 class CObjRef : public CObject
00074 {
00075 private :
00077 pdfid_t m_id ;
00078
00079 public :
00081 explicit CObjRef( pdfid_t id ) : m_id( id ) { }
00082
00084 ~CObjRef( ) { }
00085
00086 std::ostream& Write( std::ostream& os ) const ;
00087
00088 CObject* Dup( ) const ;
00089
00091 pdfid_t ID( ) const { return m_id ; }
00092 } ;
00093
00101 class CRefObj : public CObject
00102 {
00103 private :
00104 pdfid_t m_id ;
00105 boost::scoped_ptr<CObject> m_object ;
00106
00107
00108 public :
00109 CRefObj( pdfid_t id, CObject *object ) ;
00110 ~CRefObj( ) ;
00111
00112 CRefObj( const CRefObj& obj ) ;
00113
00114 std::ostream& Write( std::ostream& os ) const ;
00115
00117 const CObjRef GetRef( ) const { return CObjRef( m_id ) ; }
00118
00119 CObject* Dup( ) const ;
00120 } ;
00121
00127 class CBoolean : public CObject
00128 {
00129 private :
00130 bool m_bool ;
00131
00132 public :
00134 explicit CBoolean( bool b = false ) : m_bool( b ) { }
00135
00136 std::ostream& Write( std::ostream& os ) const ;
00137
00138 CObject* Dup( ) const ;
00139 } ;
00140
00146 class CNumber : public CObject
00147 {
00148 private :
00149 double m_number ;
00150
00151 public :
00153 explicit CNumber( double number = 0.0 ) : m_number( number ) { }
00154
00155 std::ostream& Write( std::ostream& os ) const ;
00156
00157 CObject* Dup( ) const ;
00158 } ;
00159
00165 class CString : public CObject
00166 {
00167 private :
00168 std::string m_string ;
00169
00170 public :
00172 explicit CString( const std::string& str = std::string( ) )
00173 : m_string( str ) { }
00175 ~CString( ) { }
00176
00177 std::ostream& Write( std::ostream& os ) const ;
00178
00179 CObject* Dup( ) const ;
00180 } ;
00181
00190 class CName : public CObject
00191 {
00192 private :
00193 std::string m_name ;
00194
00195 public :
00199 explicit CName( const std::string& name ) : m_name( name ) { }
00200
00201 CName( ) { }
00202
00204 ~CName( ) { }
00205
00206 CName& operator=( const CName& name )
00207 {
00208 m_name = name.m_name ;
00209 return *this ;
00210 }
00211
00212 std::ostream& Write( std::ostream& os ) const ;
00213
00214 CObject* Dup( ) const ;
00215
00217 bool empty( ) const { return m_name.empty( ) ; }
00218
00220 bool operator==( const CName& n ) const { return m_name == n.m_name ; }
00221
00223 bool operator!=( const CName& n ) const { return !operator==( n ) ; }
00224 } ;
00225
00231 inline std::ostream& operator<<( std::ostream& os, const CObject& object )
00232 {
00233 return object.Write( os ) ;
00234 }
00235
00236 } }
00237
00238 #endif