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