Magick++ 6.9.13
Loading...
Searching...
No Matches
CoderInfo.cpp
1// This may look like C code, but it is really -*- C++ -*-
2//
3// Copyright Bob Friesenhahn, 2001, 2002
4// Copyright Dirk Lemstra 2013-2015
5//
6// CoderInfo implementation
7//
8
9#define MAGICKCORE_IMPLEMENTATION 1
10#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11
12#include "Magick++/Include.h"
13#include "Magick++/CoderInfo.h"
14#include "Magick++/Exception.h"
15
16using namespace std;
17
18Magick::CoderInfo::CoderInfo(void)
19 : _name(),
20 _description(),
21 _mimeType(),
22 _isReadable(false),
23 _isWritable(false),
24 _isMultiFrame(false)
25{
26}
27
28Magick::CoderInfo::CoderInfo(const Magick::CoderInfo &coder_)
29{
30 _name=coder_._name;
31 _description=coder_._description;
32 _mimeType=coder_._mimeType;
33 _isReadable=coder_._isReadable;
34 _isWritable=coder_._isWritable;
35 _isMultiFrame=coder_._isMultiFrame;
36}
37
38Magick::CoderInfo::CoderInfo(const std::string &name_)
39 : _name(),
40 _description(),
41 _mimeType(),
42 _isReadable(false),
43 _isWritable(false),
44 _isMultiFrame(false)
45{
46 const Magick::MagickInfo
47 *magickInfo;
48
49 GetPPException;
50 magickInfo=GetMagickInfo(name_.c_str(),exceptionInfo);
51 ThrowPPException(false);
52 if (magickInfo == 0)
53 {
54 throwExceptionExplicit(OptionError,"Coder not found",name_.c_str());
55 }
56 else
57 {
58 _name=std::string(magickInfo->name);
59 _description=std::string(magickInfo->description);
60 _mimeType=std::string(magickInfo->mime_type ? magickInfo->mime_type : "");
61 _isReadable=((magickInfo->decoder == 0) ? false : true);
62 _isWritable=((magickInfo->encoder == 0) ? false : true);
63 _isMultiFrame=((magickInfo->adjoin == 0) ? false : true);
64 }
65}
66
67Magick::CoderInfo::~CoderInfo(void)
68{
69}
70
71Magick::CoderInfo& Magick::CoderInfo::operator=(const CoderInfo &coder_)
72{
73 // If not being set to ourself
74 if (this != &coder_)
75 {
76 _name=coder_._name;
77 _description=coder_._description;
78 _mimeType=coder_._mimeType;
79 _isReadable=coder_._isReadable;
80 _isWritable=coder_._isWritable;
81 _isMultiFrame=coder_._isMultiFrame;
82 }
83 return(*this);
84}
85
86std::string Magick::CoderInfo::description(void) const
87{
88 return(_description);
89}
90
91bool Magick::CoderInfo::isReadable(void) const
92{
93 return(_isReadable);
94}
95
96bool Magick::CoderInfo::isWritable(void) const
97{
98 return(_isWritable);
99}
100
101bool Magick::CoderInfo::isMultiFrame(void) const
102{
103 return(_isMultiFrame);
104}
105
106std::string Magick::CoderInfo::mimeType(void) const
107{
108 return(_mimeType);
109}
110
111std::string Magick::CoderInfo::name(void) const
112{
113 return(_name);
114}
115
116bool Magick::CoderInfo::unregister(void) const
117{
118 return(UnregisterMagickInfo(_name.c_str()) != MagickFalse);
119}
120
121Magick::CoderInfo::CoderInfo(const MagickCore::MagickInfo *magickInfo_)
122 : _name(std::string(magickInfo_->name ? magickInfo_->name : "")),
123 _description(std::string(magickInfo_->description ? magickInfo_->description : "")),
124 _mimeType(std::string(magickInfo_->mime_type ? magickInfo_->mime_type : "")),
125 _isReadable(magickInfo_->decoder ? true : false),
126 _isWritable(magickInfo_->encoder ? true : false),
127 _isMultiFrame(magickInfo_->adjoin ? true : false)
128{
129}