1 // This may look like C code, but it is really -*- C++ -*-
3 // Copyright Bob Friesenhahn, 2001, 2002
5 // CoderInfo implementation
8 #define MAGICKCORE_IMPLEMENTATION 1
9 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11 #include "Magick++/Include.h"
12 #include "Magick++/CoderInfo.h"
13 #include "Magick++/Exception.h"
17 // Default constructor
18 Magick::CoderInfo::CoderInfo ( void )
29 Magick::CoderInfo::CoderInfo ( const Magick::CoderInfo &coder_ )
32 _description = coder_._description;
33 _mimeType = coder_._mimeType;
34 _isReadable = coder_._isReadable;
35 _isWritable = coder_._isWritable;
36 _isMultiFrame = coder_._isMultiFrame;
39 Magick::CoderInfo::CoderInfo ( const std::string &name_ )
47 ExceptionInfo exceptionInfo;
48 GetExceptionInfo( &exceptionInfo );
49 const Magick::MagickInfo *magickInfo = GetMagickInfo( name_.c_str(),
51 throwException( exceptionInfo );
52 (void) DestroyExceptionInfo( &exceptionInfo );
55 throwExceptionExplicit(OptionError, "Coder not found", name_.c_str() );
59 _name = string(magickInfo->name);
60 _description = string(magickInfo->description);
61 _mimeType = string(magickInfo->mime_type ? magickInfo->mime_type : "");
62 _isReadable = ((magickInfo->decoder == 0) ? false : true);
63 _isWritable = ((magickInfo->encoder == 0) ? false : true);
64 _isMultiFrame = ((magickInfo->adjoin == 0) ? false : true);
68 Magick::CoderInfo::~CoderInfo ( void )
74 std::string Magick::CoderInfo::description( void ) const
80 bool Magick::CoderInfo::isReadable( void ) const
85 // Format is writeable
86 bool Magick::CoderInfo::isWritable( void ) const
91 // Format supports multiple frames
92 bool Magick::CoderInfo::isMultiFrame( void ) const
98 std::string Magick::CoderInfo::mimeType( void ) const
104 std::string Magick::CoderInfo::name( void ) const
109 // Assignment operator
110 Magick::CoderInfo& Magick::CoderInfo::operator= ( const CoderInfo &coder_ )
112 // If not being set to ourself
115 _name = coder_._name;
116 _description = coder_._description;
117 _mimeType = coder_._mimeType;
118 _isReadable = coder_._isReadable;
119 _isWritable = coder_._isWritable;
120 _isMultiFrame = coder_._isMultiFrame;
125 // Construct from MagickCore::MagickInfo*
126 Magick::CoderInfo::CoderInfo ( const MagickCore::MagickInfo *magickInfo_ )
127 : _name(string(magickInfo_->name ? magickInfo_->name : "")),
128 _description(string(magickInfo_->description ? magickInfo_->description : "")),
129 _mimeType(string(magickInfo_->mime_type ? magickInfo_->mime_type : "")),
130 _isReadable(magickInfo_->decoder ? true : false),
131 _isWritable(magickInfo_->encoder ? true : false),
132 _isMultiFrame(magickInfo_->adjoin ? true : false)
134 // Nothing more to do