dng_stream Class Reference

#include <dng_stream.h>

Inheritance diagram for dng_stream:

dng_file_stream dng_memory_stream

List of all members.


Public Types

enum  { kSmallBufferSize = 4 * 1024, kBigBufferSize = 64 * 1024, kDefaultBufferSize = kSmallBufferSize }

Public Member Functions

 dng_stream (const void *data, uint32 count, uint64 offsetInOriginalFile=kDNGStreamInvalidOffset)
bool SwapBytes () const
void SetSwapBytes (bool swapBytes)
bool BigEndian () const
void SetBigEndian (bool bigEndian=true)
bool LittleEndian () const
void SetLittleEndian (bool littleEndian=true)
uint32 BufferSize () const
 Returns the size of the buffer used by the stream.
uint64 Length ()
uint64 Position () const
uint64 PositionInOriginalFile () const
uint64 OffsetInOriginalFile () const
const void * Data () const
dng_memory_blockAsMemoryBlock (dng_memory_allocator &allocator)
void SetReadPosition (uint64 offset)
 Seek to a new position in stream for reading.
void Skip (uint64 delta)
void Get (void *data, uint32 count)
void SetWritePosition (uint64 offset)
 Seek to a new position in stream for writing.
void Flush ()
 Force any stored data in stream to be written to underlying storage.
void SetLength (uint64 length)
void Put (const void *data, uint32 count)
uint8 Get_uint8 ()
void Put_uint8 (uint8 x)
uint16 Get_uint16 ()
void Put_uint16 (uint16 x)
uint32 Get_uint32 ()
void Put_uint32 (uint32 x)
uint64 Get_uint64 ()
void Put_uint64 (uint64 x)
int8 Get_int8 ()
void Put_int8 (int8 x)
int16 Get_int16 ()
void Put_int16 (int16 x)
int32 Get_int32 ()
void Put_int32 (int32 x)
int64 Get_int64 ()
void Put_int64 (int64 x)
real32 Get_real32 ()
void Put_real32 (real32 x)
real64 Get_real64 ()
void Put_real64 (real64 x)
void Get_CString (char *data, uint32 maxLength)
void Get_UString (char *data, uint32 maxLength)
void PutZeros (uint64 count)
void PadAlign2 ()
 Writes zeros to align the stream position to a multiple of 2.
void PadAlign4 ()
 Writes zeros to align the stream position to a multiple of 4.
uint32 TagValue_uint32 (uint32 tagType)
int32 TagValue_int32 (uint32 tagType)
dng_urational TagValue_urational (uint32 tagType)
dng_srational TagValue_srational (uint32 tagType)
real64 TagValue_real64 (uint32 tagType)
dng_abort_snifferSniffer () const
void SetSniffer (dng_abort_sniffer *sniffer)
virtual void CopyToStream (dng_stream &dstStream, uint64 count)
void DuplicateStream (dng_stream &dstStream)

Protected Member Functions

 dng_stream (dng_abort_sniffer *sniffer=NULL, uint32 bufferSize=kDefaultBufferSize, uint64 offsetInOriginalFile=kDNGStreamInvalidOffset)
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)

Detailed Description

Base stream abstraction. Has support for going between stream and pointer abstraction.

Constructor & Destructor Documentation

dng_stream::dng_stream ( const void *  data,
uint32  count,
uint64  offsetInOriginalFile = kDNGStreamInvalidOffset 
)

Construct a stream with initial data.

Parameters:
data Pointer to initial contents of stream.
count Number of bytes data is valid for.
offsetInOriginalFile If data came from a file originally, offset can be saved here for later use.


Member Function Documentation

dng_memory_block * dng_stream::AsMemoryBlock ( dng_memory_allocator allocator  ) 

Return the entire stream as a single memory block. This works for all streams, but requires copying the data to a new buffer.

Parameters:
allocator Allocator used to allocate memory.

References dng_memory_allocator::Allocate(), Flush(), Get(), Length(), SetReadPosition(), and ThrowProgramError().

Referenced by dng_iptc::Spool().

bool dng_stream::BigEndian (  )  const

Getter for whether data in stream is big endian.

Return values:
If true, data in stream is big endian.

Referenced by LittleEndian(), dng_image_writer::WriteDNG(), and dng_image_writer::WriteTIFFWithProfile().

void dng_stream::CopyToStream ( dng_stream dstStream,
uint64  count 
) [virtual]

Copy a specified number of bytes to a target stream.

Parameters:
dstStream The target stream.
count The number of bytes to copy.

Reimplemented in dng_memory_stream.

References dng_memory_data::Buffer(), Get(), and Put().

Referenced by DuplicateStream().

const void * dng_stream::Data (  )  const

Return pointer to stream contents if the stream is entirely available as a single memory block, NULL otherwise.

void dng_stream::DuplicateStream ( dng_stream dstStream  ) 

Makes the target stream a copy of this stream.

Parameters:
dstStream The target stream.

References CopyToStream(), Flush(), Length(), SetLength(), SetReadPosition(), and SetWritePosition().

void dng_stream::Get ( void *  data,
uint32  count 
)

Get data from stream. Exception is thrown and no data is read if insufficient data available in stream.

Parameters:
data Buffer to put data into. Must be valid for count bytes.
count Bytes of data to read.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Flush(), Length(), dng_abort_sniffer::SniffForAbort(), and ThrowEndOfFile().

Referenced by AsMemoryBlock(), CopyToStream(), Get_real64(), Get_uint16(), Get_uint32(), Get_uint64(), Get_uint8(), and dng_iptc::Parse().

void dng_stream::Get_CString ( char *  data,
uint32  maxLength 
)

Get an 8-bit character string from stream and advance read position. Routine always reads until a NUL character (8-bits of zero) is read. (That is, only maxLength bytes will be returned in buffer, but the stream is always advanced until a NUL is read or EOF is reached.)

Parameters:
data Buffer in which string is returned.
maxLength Maximum number of bytes to place in buffer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if stream runs out before NUL is seen.

References Get_uint8().

int16 dng_stream::Get_int16 (  )  [inline]

Get one 16-bit integer from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One 16-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_uint16().

Referenced by TagValue_int32().

int32 dng_stream::Get_int32 (  )  [inline]

Get one 32-bit integer from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One 32-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_uint32().

Referenced by TagValue_int32(), TagValue_real64(), TagValue_srational(), and TagValue_urational().

int64 dng_stream::Get_int64 (  )  [inline]

Get one 64-bit integer from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One 64-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_uint64().

int8 dng_stream::Get_int8 (  )  [inline]

Get one 8-bit integer from stream and advance read position.

Return values:
One 8-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_uint8().

Referenced by dng_iptc::Parse(), and TagValue_int32().

real32 dng_stream::Get_real32 (  ) 

Get one 32-bit IEEE floating-point number from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One 32-bit IEEE floating-point number.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_uint32().

Referenced by dng_camera_profile::Parse(), and TagValue_real64().

real64 dng_stream::Get_real64 (  ) 

Get one 64-bit IEEE floating-point number from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One 64-bit IEEE floating-point number .
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get(), and Get_uint32().

Referenced by TagValue_real64().

uint16 dng_stream::Get_uint16 (  ) 

Get an unsigned 16-bit integer from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One unsigned 16-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get().

Referenced by Get_int16(), Get_UString(), dng_iptc::Parse(), dng_info::Parse(), and TagValue_uint32().

uint32 dng_stream::Get_uint32 (  ) 

Get an unsigned 32-bit integer from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One unsigned 32-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get().

Referenced by Get_int32(), Get_real32(), Get_real64(), Get_uint64(), dng_info::Parse(), TagValue_real64(), TagValue_uint32(), and TagValue_urational().

uint64 dng_stream::Get_uint64 (  ) 

Get an unsigned 64-bit integer from stream and advance read position. Byte swap if byte swapping is turned on.

Return values:
One unsigned 64-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get(), and Get_uint32().

Referenced by Get_int64().

uint8 dng_stream::Get_uint8 (  )  [inline]

Get an unsigned 8-bit integer from stream and advance read position.

Return values:
One unsigned 8-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get().

Referenced by Get_CString(), Get_int8(), dng_iptc::Parse(), and TagValue_uint32().

void dng_stream::Get_UString ( char *  data,
uint32  maxLength 
)

Get a 16-bit character string from stream and advance read position. 16-bit characters are truncated to 8-bits. Routine always reads until a NUL character (16-bits of zero) is read. (That is, only maxLength bytes will be returned in buffer, but the stream is always advanced until a NUL is read or EOF is reached.)

Parameters:
data Buffer to place string in.
maxLength Maximum number of bytes to place in buffer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if stream runs out before NUL is seen.

References Get_uint16().

uint64 dng_stream::Length (  )  [inline]

bool dng_stream::LittleEndian (  )  const [inline]

Getter for whether data in stream is big endian.

Return values:
If true, data in stream is big endian.

References BigEndian().

uint64 dng_stream::OffsetInOriginalFile (  )  const

Getter for offset in original file.

Return values:
kInvalidOffset if no offset in original file is set, offset in original file otherwise.

uint64 dng_stream::Position (  )  const [inline]

Getter for current offset in stream.

Return values:
current offset from start of stream.

Referenced by dng_memory_stream::CopyToStream(), PadAlign2(), PadAlign4(), dng_iptc::Parse(), dng_info::Parse(), PositionInOriginalFile(), Skip(), dng_image_writer::WriteDNG(), and dng_image_writer::WriteTIFFWithProfile().

uint64 dng_stream::PositionInOriginalFile (  )  const

Getter for current position in original file, taking into account OffsetInOriginalFile stream data was taken from.

Return values:
kInvalidOffset if no offset in original file is set, sum of offset in original file and current position otherwise.

References Position().

Referenced by dng_info::Parse().

void dng_stream::Put ( const void *  data,
uint32  count 
)

Write data to stream.

Parameters:
data Buffer of data to write to stream.
count Bytes of in data.

References Flush(), Length(), and dng_abort_sniffer::SniffForAbort().

Referenced by CopyToStream(), dng_memory_stream::CopyToStream(), Put_real32(), Put_real64(), Put_uint16(), Put_uint32(), Put_uint64(), Put_uint8(), PutZeros(), and dng_iptc::Spool().

void dng_stream::Put_int16 ( int16  x  )  [inline]

Put one 16-bit integer to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One 16-bit integer.

References Put_uint16().

void dng_stream::Put_int32 ( int32  x  )  [inline]

Put one 32-bit integer to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One 32-bit integer.

References Put_uint32().

void dng_stream::Put_int64 ( int64  x  )  [inline]

Put one 64-bit integer to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One 64-bit integer.

References Put_uint64().

void dng_stream::Put_int8 ( int8  x  )  [inline]

Put one 8-bit integer to stream and advance write position.

Parameters:
x One 8-bit integer.

References Put_uint8().

void dng_stream::Put_real32 ( real32  x  ) 

Put one 32-bit IEEE floating-point number to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One 32-bit IEEE floating-point number.

References Put(), and Put_uint32().

void dng_stream::Put_real64 ( real64  x  ) 

Put one 64-bit IEEE floating-point number to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One64-bit IEEE floating-point number.

References Put(), and Put_uint32().

void dng_stream::Put_uint16 ( uint16  x  ) 

Put an unsigned 16-bit integer to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One unsigned 16-bit integer.

References Put().

Referenced by Put_int16(), dng_iptc::Spool(), dng_image_writer::WriteDNG(), and dng_image_writer::WriteTIFFWithProfile().

void dng_stream::Put_uint32 ( uint32  x  ) 

Put an unsigned 32-bit integer to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One unsigned 32-bit integer.

References Put().

Referenced by Put_int32(), Put_real32(), Put_real64(), Put_uint64(), dng_image_writer::WriteDNG(), and dng_image_writer::WriteTIFFWithProfile().

void dng_stream::Put_uint64 ( uint64  x  ) 

Put an unsigned 64-bit integer to stream and advance write position. Byte swap if byte swapping is turned on.

Parameters:
x One unsigned 64-bit integer.

References Put(), and Put_uint32().

Referenced by Put_int64().

void dng_stream::Put_uint8 ( uint8  x  )  [inline]

Put an unsigned 8-bit integer to stream and advance write position.

Parameters:
x One unsigned 8-bit integer.

References Length(), and Put().

Referenced by Put_int8(), PutZeros(), and dng_iptc::Spool().

void dng_stream::PutZeros ( uint64  count  ) 

Writes the specified number of zero bytes to stream.

Parameters:
count Number of zero bytes to write.

References dng_memory_data::Buffer(), Put(), and Put_uint8().

Referenced by PadAlign2(), and PadAlign4().

void dng_stream::SetBigEndian ( bool  bigEndian = true  ) 

Setter for whether data in stream is big endian.

Parameters:
bigEndian If true, data in stream is big endian.

Referenced by dng_iptc::Parse(), dng_info::Parse(), SetLittleEndian(), and dng_iptc::Spool().

void dng_stream::SetLength ( uint64  length  ) 

Set length of available data.

Parameters:
length Number of bytes of avialble data in stream.

References Flush(), and Length().

Referenced by DuplicateStream(), dng_image_writer::WriteDNG(), and dng_image_writer::WriteTIFFWithProfile().

void dng_stream::SetLittleEndian ( bool  littleEndian = true  )  [inline]

Setter for whether data in stream is big endian.

Parameters:
littleEndian If true, data in stream is big endian.

References SetBigEndian().

Referenced by dng_info::Parse().

void dng_stream::SetSniffer ( dng_abort_sniffer sniffer  )  [inline]

Putter for sniffer associated with stream.

Parameters:
sniffer The new sniffer to use (or NULL for none).

void dng_stream::SetSwapBytes ( bool  swapBytes  )  [inline]

Setter for whether stream is swapping byte order on input/output.

Parameters:
swapBytes If true, stream will swap byte order on input or output for future reads/writes.

void dng_stream::Skip ( uint64  delta  )  [inline]

Skip forward in stream.

Parameters:
delta Number of bytes to skip forward.

References Position(), and SetReadPosition().

dng_abort_sniffer* dng_stream::Sniffer (  )  const [inline]

Getter for sniffer associated with stream.

Return values:
The sniffer for this stream.

bool dng_stream::SwapBytes (  )  const [inline]

Getter for whether stream is swapping byte order on input/output.

Return values:
If true, data will be swapped on input/output.

int32 dng_stream::TagValue_int32 ( uint32  tagType  ) 

Get a value of size indicated by tag type from stream and advance read position. Byte swap if byte swapping is turned on and tag type is larger than a byte. Value is returned as a 32-bit integer.

Parameters:
tagType Tag type of data stored in stream.
Return values:
One 32-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_int16(), Get_int32(), Get_int8(), and TagValue_real64().

Referenced by TagValue_real64(), and TagValue_urational().

real64 dng_stream::TagValue_real64 ( uint32  tagType  ) 

Get a value of size indicated by tag type from stream and advance read position. Byte swap if byte swapping is turned on and tag type is larger than a byte. Value is returned as a 64-bit IEEE floating-point number.

Parameters:
tagType Tag type of data stored in stream.
Return values:
One 64-bit IEEE floating-point number.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_int32(), Get_real32(), Get_real64(), Get_uint32(), TagValue_int32(), and TagValue_uint32().

Referenced by TagValue_int32(), TagValue_srational(), TagValue_uint32(), and TagValue_urational().

dng_srational dng_stream::TagValue_srational ( uint32  tagType  ) 

Get a value of size indicated by tag type from stream and advance read position. Byte swap if byte swapping is turned on and tag type is larger than a byte. Value is returned as a dng_srational.

Parameters:
tagType Tag type of data stored in stream.
Return values:
One dng_srational.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_int32(), and TagValue_real64().

uint32 dng_stream::TagValue_uint32 ( uint32  tagType  ) 

Get a value of size indicated by tag type from stream and advance read position. Byte swap if byte swapping is turned on and tag type is larger than a byte. Value is returned as an unsigned 32-bit integer.

Parameters:
tagType Tag type of data stored in stream.
Return values:
One unsigned 32-bit integer.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_uint16(), Get_uint32(), Get_uint8(), and TagValue_real64().

Referenced by TagValue_real64(), and TagValue_urational().

dng_urational dng_stream::TagValue_urational ( uint32  tagType  ) 

Get a value of size indicated by tag type from stream and advance read position. Byte swap if byte swapping is turned on and tag type is larger than a byte. Value is returned as a dng_urational.

Parameters:
tagType Tag type of data stored in stream.
Return values:
One dng_urational.
Exceptions:
dng_exception with fErrorCode equal to dng_error_end_of_file if not enough data in stream.

References Get_int32(), Get_uint32(), TagValue_int32(), TagValue_real64(), and TagValue_uint32().


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

Copyright © 2006-2009 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google