Magick++ 7.1.1
Loading...
Searching...
No Matches
Magick::Blob Class Reference
Inheritance diagram for Magick::Blob:
Collaboration diagram for Magick::Blob:

Public Types

enum  Allocator { MallocAllocator , NewAllocator }
 

Public Member Functions

 Blob (const void *data_, const size_t length_)
 
 Blob (const Blob &blob_)
 
Bloboperator= (const Blob &blob_)
 
void base64 (const std::string base64_)
 
std::string base64 (void) const
 
const void * data (void) const
 
size_t length (void) const
 
void update (const void *data_, const size_t length_)
 
void updateNoCopy (void *data_, const size_t length_, const Allocator allocator_=NewAllocator)
 

Private Attributes

BlobRef_blobRef
 

Detailed Description

Definition at line 22 of file Blob.h.

Member Enumeration Documentation

◆ Allocator

enum Magick::Blob::Allocator

Definition at line 26 of file Blob.h.

27 {
28 MallocAllocator,
29 NewAllocator
30 };

Constructor & Destructor Documentation

◆ Blob() [1/3]

Magick::Blob::Blob ( void  )

Definition at line 21 of file Blob.cpp.

22 : _blobRef(new Magick::BlobRef(0,0))
23{
24}

◆ Blob() [2/3]

Magick::Blob::Blob ( const void *  data_,
const size_t  length_ 
)

Definition at line 26 of file Blob.cpp.

27 : _blobRef(new Magick::BlobRef(data_, length_))
28{
29}

◆ Blob() [3/3]

Magick::Blob::Blob ( const Blob blob_)

Definition at line 31 of file Blob.cpp.

32 : _blobRef(blob_._blobRef)
33{
34 // Increase reference count
35 _blobRef->increase();
36}

◆ ~Blob()

Magick::Blob::~Blob ( )
virtual

Definition at line 38 of file Blob.cpp.

39{
40 try
41 {
42 if (_blobRef->decrease() == 0)
43 delete _blobRef;
44 }
45 catch(Magick::Exception&)
46 {
47 }
48
49 _blobRef=(Magick::BlobRef *) NULL;
50}

Member Function Documentation

◆ base64() [1/2]

void Magick::Blob::base64 ( const std::string  base64_)

Definition at line 65 of file Blob.cpp.

66{
67 size_t
68 length;
69
70 unsigned char
71 *decoded;
72
73 decoded=Base64Decode(base64_.c_str(),&length);
74
75 if(decoded)
76 updateNoCopy(static_cast<void*>(decoded),length,
77 Magick::Blob::MallocAllocator);
78}

◆ base64() [2/2]

std::string Magick::Blob::base64 ( void  ) const

Definition at line 80 of file Blob.cpp.

81{
82 size_t
83 encoded_length;
84
85 char
86 *encoded;
87
88 std::string
89 result;
90
91 encoded_length=0;
92 encoded=Base64Encode(static_cast<const unsigned char*>(data()),length(),
93 &encoded_length);
94
95 if(encoded)
96 {
97 result=std::string(encoded,encoded_length);
98 encoded=(char *) RelinquishMagickMemory(encoded);
99 return result;
100 }
101
102 return(std::string());
103}

◆ data()

const void * Magick::Blob::data ( void  ) const

Definition at line 105 of file Blob.cpp.

106{
107 return(_blobRef->data);
108}

◆ length()

size_t Magick::Blob::length ( void  ) const

Definition at line 110 of file Blob.cpp.

111{
112 return(_blobRef->length);
113}

◆ operator=()

Magick::Blob & Magick::Blob::operator= ( const Blob blob_)

Definition at line 52 of file Blob.cpp.

53{
54 if (this != &blob_)
55 {
56 blob_._blobRef->increase();
57 if (_blobRef->decrease() == 0)
58 delete _blobRef;
59
60 _blobRef=blob_._blobRef;
61 }
62 return(*this);
63}

◆ update()

void Magick::Blob::update ( const void *  data_,
const size_t  length_ 
)

Definition at line 115 of file Blob.cpp.

116{
117 if (_blobRef->decrease() == 0)
118 delete _blobRef;
119
120 _blobRef=new Magick::BlobRef(data_,length_);
121}

◆ updateNoCopy()

void Magick::Blob::updateNoCopy ( void *  data_,
const size_t  length_,
const Allocator  allocator_ = NewAllocator 
)

Definition at line 123 of file Blob.cpp.

125{
126 if (_blobRef->decrease() == 0)
127 delete _blobRef;
128
129 _blobRef=new Magick::BlobRef((const void*) NULL,0);
130 _blobRef->data=data_;
131 _blobRef->length=length_;
132 _blobRef->allocator=allocator_;
133}

Member Data Documentation

◆ _blobRef

BlobRef* Magick::Blob::_blobRef
private

Definition at line 77 of file Blob.h.


The documentation for this class was generated from the following files: