Magick++ 7.1.1
Loading...
Searching...
No Matches
Blob.h
1// This may look like C code, but it is really -*- C++ -*-
2//
3// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
4//
5// Copyright @ 2015 ImageMagick Studio LLC, a non-profit organization
6// dedicated to making software imaging solutions freely available.
7//
8// Reference counted container class for Binary Large Objects (BLOBs)
9//
10
11#if !defined(Magick_BlobRef_header)
12#define Magick_BlobRef_header
13
14#include "Magick++/Include.h"
15#include <string>
16
17namespace Magick
18{
19 // Forward decl
20 class BlobRef;
21
22 class MagickPPExport Blob
23 {
24 public:
25
26 enum Allocator
27 {
28 MallocAllocator,
29 NewAllocator
30 };
31
32 // Default constructor
33 Blob(void);
34
35 // Construct object with data, making a copy of the supplied data.
36 Blob(const void* data_,const size_t length_);
37
38 // Copy constructor (reference counted)
39 Blob(const Blob& blob_);
40
41 // Destructor (reference counted)
42 virtual ~Blob();
43
44 // Assignment operator (reference counted)
45 Blob& operator=(const Blob& blob_);
46
47 // Update object contents from Base64-encoded string representation.
48 void base64(const std::string base64_);
49 // Return Base64-encoded string representation.
50 std::string base64(void) const;
51
52 // Obtain pointer to data. The user should never try to modify or
53 // free this data since the Blob class manages its own data. The
54 // user must be finished with the data before allowing the Blob to
55 // be destroyed since the pointer is invalid once the Blob is
56 // destroyed.
57 const void* data(void) const;
58
59 // Obtain data length.
60 size_t length(void) const;
61
62 // Update object contents, making a copy of the supplied data.
63 // Any existing data in the object is deallocated.
64 void update(const void* data_,const size_t length_);
65
66 // Update object contents, using supplied pointer directly (no
67 // copy). Any existing data in the object is deallocated. The user
68 // must ensure that the pointer supplied is not deleted or
69 // otherwise modified after it has been supplied to this method.
70 // Specify allocator_ as "MallocAllocator" if memory is allocated
71 // via the C language malloc() function, or "NewAllocator" if
72 // memory is allocated via C++ 'new'.
73 void updateNoCopy(void* data_,const size_t length_,
74 const Allocator allocator_=NewAllocator);
75
76 private:
77 BlobRef *_blobRef;
78 };
79
80} // namespace Magick
81
82#endif // Magick_BlobRef_header