lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*****************************************************************************/
// Copyright 2006-2007 Adobe Systems Incorporated
// All Rights Reserved.
//
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
// accordance with the terms of the Adobe license agreement accompanying it.
/*****************************************************************************/
 
/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_memory_stream.h#2 $ */ 
/* $DateTime: 2012/07/31 22:04:34 $ */
/* $Change: 840853 $ */
/* $Author: tknoll $ */
 
/** \file
 * Stream abstraction to/from in-memory data.
 */
 
/*****************************************************************************/
 
#ifndef __dng_memory_stream__
#define __dng_memory_stream__
 
/*****************************************************************************/
 
#include "dng_stream.h"
 
/*****************************************************************************/
 
/// \brief A dng_stream which can be read from or written to memory.
///
/// Stream is populated via writing and either read or accessed by asking for contents as a pointer.
 
class dng_memory_stream: public dng_stream
   {
   
   protected:
   
       dng_memory_allocator &fAllocator;
       
       uint32 fPageSize;
       
       uint32 fPageCount;
       uint32 fPagesAllocated;
       
       dng_memory_block **fPageList;
       
       uint64 fMemoryStreamLength;
       
   public:
 
       /// Construct a new memory-based stream.
       /// \param allocator Allocator to use to allocate memory in stream as needed.
       /// \param sniffer If non-NULL used to check for user cancellation.
       /// \param pageSize Unit of allocation for data stored in stream.
 
       dng_memory_stream (dng_memory_allocator &allocator,
                          dng_abort_sniffer *sniffer = NULL,
                          uint32 pageSize = 64 * 1024);
                          
       virtual ~dng_memory_stream ();
 
       /// Copy a specified number of bytes to a target stream.
       /// \param dstStream The target stream.
       /// \param count The number of bytes to copy.
       
       virtual void CopyToStream (dng_stream &dstStream,
                                  uint64 count);
       
   protected:
       
       virtual uint64 DoGetLength ();
   
       virtual void DoRead (void *data,
                            uint32 count,
                            uint64 offset);
                            
       virtual void DoSetLength (uint64 length);
                            
       virtual void DoWrite (const void *data,
                             uint32 count,
                             uint64 offset);
       
   private:
   
       // Hidden copy constructor and assignment operator.
   
       dng_memory_stream (const dng_memory_stream &stream);
       
       dng_memory_stream & operator= (const dng_memory_stream &stream);
       
   };
 
/*****************************************************************************/
 
#endif
   
/*****************************************************************************/