~ubuntu-branches/ubuntu/intrepid/graphicsmagick/intrepid

« back to all changes in this revision

Viewing changes to Magick++/lib/Magick++/Blob.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2006-05-06 16:28:08 UTC
  • Revision ID: james.westby@ubuntu.com-20060506162808-vt2ni3r5nytcszms
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This may look like C code, but it is really -*- C++ -*-
 
2
//
 
3
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
 
4
//
 
5
// Reference counted container class for Binary Large Objects (BLOBs)
 
6
//
 
7
 
 
8
#if !defined(Magick_BlobRef_header)
 
9
#define Magick_BlobRef_header
 
10
 
 
11
#include "Magick++/Include.h"
 
12
#include <string>
 
13
 
 
14
namespace Magick
 
15
{
 
16
  // Forward decl
 
17
  class BlobRef;
 
18
 
 
19
  class MagickDLLDecl Blob
 
20
  {
 
21
 
 
22
  public:
 
23
 
 
24
    enum Allocator
 
25
    {
 
26
      MallocAllocator,
 
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_, 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
    // Update object contents, making a copy of the supplied data.
 
51
    // Any existing data in the object is deallocated.
 
52
    void          update ( const void* data_, size_t length_ );
 
53
 
 
54
    // Update object contents, using supplied pointer directly (no
 
55
    // copy). Any existing data in the object is deallocated.  The user
 
56
    // must ensure that the pointer supplied is not deleted or
 
57
    // otherwise modified after it has been supplied to this method.
 
58
    // Specify allocator_ as "MallocAllocator" if memory is allocated
 
59
    // via the C language malloc() function, or "NewAllocator" if
 
60
    // memory is allocated via C++ 'new'.
 
61
    void          updateNoCopy ( void* data_, size_t length_,
 
62
                                 Allocator allocator_ = NewAllocator );
 
63
 
 
64
    // Obtain pointer to data. The user should never try to modify or
 
65
    // free this data since the Blob class manages its own data. The
 
66
    // user must be finished with the data before allowing the Blob to
 
67
    // be destroyed since the pointer is invalid once the Blob is
 
68
    // destroyed.
 
69
    const void*   data ( void ) const;
 
70
 
 
71
    // Obtain data length
 
72
    size_t length ( void ) const;
 
73
 
 
74
  protected:
 
75
 
 
76
  private:
 
77
    BlobRef * _blobRef;
 
78
  };
 
79
 
 
80
} // namespace Magick
 
81
 
 
82
#endif // Magick_BlobRef_header