Magick++  6.9.3
CoderInfo.cpp
Go to the documentation of this file.
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 
16 using namespace std;
17 
19  : _name(),
20  _description(),
21  _mimeType(),
22  _isReadable(false),
23  _isWritable(false),
24  _isMultiFrame(false)
25 {
26 }
27 
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 
38 Magick::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 
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 
68 {
69 }
70 
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 
86 std::string Magick::CoderInfo::description(void) const
87 {
88  return(_description);
89 }
90 
92 {
93  return(_isReadable);
94 }
95 
97 {
98  return(_isWritable);
99 }
100 
102 {
103  return(_isMultiFrame);
104 }
105 
106 std::string Magick::CoderInfo::mimeType(void) const
107 {
108  return(_mimeType);
109 }
110 
111 std::string Magick::CoderInfo::name(void) const
112 {
113  return(_name);
114 }
115 
117 {
118  return(UnregisterMagickInfo(_name.c_str()) != MagickFalse);
119 }
120 
121 Magick::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 }
bool unregister(void) const
Definition: CoderInfo.cpp:116
std::string name(void) const
Definition: CoderInfo.cpp:111
CoderInfo & operator=(const CoderInfo &coder_)
Definition: CoderInfo.cpp:71
STL namespace.
std::string mimeType(void) const
Definition: CoderInfo.cpp:106
bool isMultiFrame(void) const
Definition: CoderInfo.cpp:101
std::string description(void) const
Definition: CoderInfo.cpp:86
bool isReadable(void) const
Definition: CoderInfo.cpp:91
MagickPPExport void throwExceptionExplicit(const MagickCore::ExceptionType severity_, const char *reason_, const char *description_=(char *) NULL)
#define ThrowPPException(quiet)
Definition: Include.h:1510
bool isWritable(void) const
Definition: CoderInfo.cpp:96
#define GetPPException
Definition: Include.h:1506