HiRISE
 PDS_JP2

JP2_Box Class Reference

A JP2_Box contains JP2 file format box data. More...

#include <JP2_Box.hh>

Collaboration diagram for JP2_Box:

Public Types

typedef std::vector< JP2_Box * > JP2_Box_List
 List of JP2 boxes.

Public Member Functions

 JP2_Box ()
 Construct a JP2_Box with no data content.
 JP2_Box (unsigned int box_type, const unsigned char *data=NULL, unsigned int amount=0)
 Construct a JP2_Box of some type and with optional data content.
 JP2_Box (unsigned int box_type, const std::string &text)
 Construct a JP2_Box of some type with text content.
virtual ~JP2_Box ()
 Destroy this JP2_Box.
std::string type_name () const
 Get the type name of the box.
JP2_Boxtype_name (const std::string &name)
 Set the type name of the box.
unsigned int type_code () const
 Get the type code of the box.
JP2_Boxtype_code (unsigned int box_type)
 Set the type code of the box.
unsigned int content_amount () const
 Get the box data content amount.
unsigned char * content () const
 Get the box data content.
JP2_Boxcontent (const unsigned char *data, unsigned int amount=0)
 Set the box data content.
JP2_Boxcontent (const std::string &text)
 Set the box data content.
bool locally_owned_content () const
 Test if the box data content buffer is locally owned.
JP2_Boxattach_content (unsigned char *data, unsigned int amount=0)
 Set the box data content.
JP2_Boxappend_content (const unsigned char *data, unsigned int amount)
 Append data to the box data content.
JP2_Boxappend_content (const std::string &text)
 Append text to the box data content.
JP2_Boxadd (JP2_Box *sub_box)
 Add a sub-box to this box.
JP2_Boxadd (JP2_Box &sub_box)
 Add a sub-box to this box.
bool remove (JP2_Box *sub_box)
 Remove a sub-box from this box.
JP2_Box_Listsub_boxes ()
 Get the list of sub-boxes contained in this box.
JP2_Boxcontainer () const
 Get the container of this box.

Static Public Member Functions

static std::string type_name (unsigned int box_type)
 Convert a JP2 box type code to a string.
static unsigned int type_code (const std::string &name)
 Convert a JP2 box type string to an integer code.

Static Public Attributes

static const char *const ID
 Class identification name with source code version and date.
static const unsigned int UUID_BOX_TYPE = 0x75756964
 UUID box type.
static const unsigned int UUID_SIZE = 16
 Size of the UUID data content.
static const unsigned int UUID_INFO_BOX_TYPE = 0x75696E66
 UUID Info box type.
static const unsigned int UUID_LIST_BOX_TYPE = 0x756C7374
 UUID List box type.
static const unsigned int URL_BOX_TYPE = 0x75726C20
 URL box type.
static const unsigned int XML_BOX_TYPE = 0x786D6C20
 XML box type.
static const unsigned int ASSOCIATION_BOX_TYPE = 0X61736F63
 Association box type.
static const unsigned int LABEL_BOX_TYPE = 0X6C626C20
 Label box type.
static const unsigned int INTELLECTUAL_PROPERTY_BOX_TYPE = 0x6A703269
 Intellectual Property box type.

Protected Attributes

unsigned int Type
 The JP2 box type code.
unsigned char * Content
 The data content buffer.
unsigned int Content_Amount
 The amount (bytes) of content data.
bool Locally_Owned_Content
 Flag for a locally owned data content buffer.
JP2_BoxContainer
 Pointer to the JP2_Box that contains this box.
JP2_Box_List Sub_Boxes
 List of boxes contained in this box.

Detailed Description

A JP2_Box contains JP2 file format box data.

Author
Bradford Castalia; UA/HiROC
Version
1.4

Member Typedef Documentation

◆ JP2_Box_List

typedef std::vector<JP2_Box*> JP2_Box_List

List of JP2 boxes.

Constructor & Destructor Documentation

◆ JP2_Box() [1/3]

JP2_Box ( )

Construct a JP2_Box with no data content.

Construct JP2_Box with no content.

◆ JP2_Box() [2/3]

JP2_Box ( unsigned int box_type,
const unsigned char * data = NULL,
unsigned int amount = 0 )
explicit

Construct a JP2_Box of some type and with optional data content.

Parameters
box_typeThe 32-bit integer box type code value.
amountThe number of data content bytes. If zero the box will be emptied and the data will be ignored.
dataA pointer (const unsigned char*) to the data content. N.B.: The data will be copied to a locally owned data buffer. If NULL the box will be emptied and the amount will be ignored.
Exceptions
invalid_argumentIf a type code byte value does not correspond to a printable character (<32 or >126).
length_errorIf insufficient memory is available to allocate the data content buffer.
See also
content(unsigned int, const unsigned char*)

◆ JP2_Box() [3/3]

JP2_Box ( unsigned int box_type,
const std::string & text )
explicit

Construct a JP2_Box of some type with text content.

Parameters
box_typeThe 32-bit integer box type code value.
textThe text string to be set as the box content.
See also
content(const std::string&)

◆ ~JP2_Box()

~JP2_Box ( )
virtual

Destroy this JP2_Box.

Any locally owned content data is freed.

Member Function Documentation

◆ type_name() [1/3]

std::string type_name ( ) const
inline

Get the type name of the box.

The type name is the string representation of the type code bytes that are stored as the second value of each JP2 box.

Returns
The type name of the box. This will be the empty string if the box is undefined.
Exceptions
invalid_argumentIf the type code is an invalid value.
See also
type_name(unsigned int)

◆ type_name() [2/3]

JP2_Box & type_name ( const std::string & name)

Set the type name of the box.

Parameters
nameThe type name to be applied to the JP2 box.
Returns
This JP2_Box.
Exceptions
invalid_argumentIf the string does not contain exactly four characters or any character is not printable (<32 or >126).
See also
type_code(const std::string&)

◆ type_name() [3/3]

std::string type_name ( unsigned int box_type)
static

Convert a JP2 box type code to a string.

Each byte, starting with the most significant byte, of the type value is appended as a character to a string.

Parameters
box_typeThe box type code value to be converted.
Returns
The string repesentation of the type value.
Exceptions
invalid_argumentIf a type code byte value does not correspond to a printable character (<32 or >126).
See also
type_code(const std::string)

◆ type_code() [1/3]

unsigned int type_code ( ) const
inline

Get the type code of the box.

The type code is the second value of each JP2 box.

Returns
The JP2 box type code value. This will be zero if the box is undefined.

◆ type_code() [2/3]

JP2_Box & type_code ( unsigned int box_type)

Set the type code of the box.

Parameters
box_typeThe 32-bit integer box type code value.
Returns
This JP2_Box.
Exceptions
invalid_argumentIf a type code byte value does not correspond to a printable character (<32 or >126).

◆ type_code() [3/3]

unsigned int type_code ( const std::string & name)
static

Convert a JP2 box type string to an integer code.

Each character of the string is placed as a byte value in the corresponding location of the type code, starting with the most significant byte.

Parameters
nameThe type name string to be converted.
Returns
The integer type code value.
Exceptions
invalid_argumentIf the string does not contain exactly four characters or any character is not printable (<32 or >126).
See also
type_name(unsigned int)

◆ content_amount()

unsigned int content_amount ( ) const
inline

Get the box data content amount.

The box data content amount is the size of the content buffer, in bytes.

Returns
The size of the box data content data buffer, in bytes. This will be zero if the box has no data content.

◆ content() [1/3]

unsigned char * content ( ) const
inline

Get the box data content.

Returns
A pointer to the box data content as an unsigned char*. Caution: The box data content is not copied.

◆ content() [2/3]

JP2_Box & content ( const unsigned char * data,
unsigned int amount = 0 )

Set the box data content.

Any current content is replaced.

Parameters
dataA pointer (const unsigned char*) to the data content. N.B.: The data will be copied to a locally owned content buffer. If NULL the box will be emptied and the amount will be ignored.
amountThe number of data bytes. If zero the box will be emptied and the data will be ignored.
Returns
This JP2_Box.
Exceptions
length_errorIf insufficient memory is available to allocate the data content buffer.
See also
attach_content(unsigned int, unsigned char*)

◆ content() [3/3]

JP2_Box & content ( const std::string & text)

Set the box data content.

Any current content is replaced.

The characters of the string, plus a terminating zero-value character, are copied into the box content.

Parameters
textThe text string to be set as the box content.
Returns
This JP2_Box.
Exceptions
length_errorIf insufficient memory is available to allocate the data content buffer.
See also
content(unsigned int, const unsigned char*)

◆ locally_owned_content()

bool locally_owned_content ( ) const
inline

Test if the box data content buffer is locally owned.

A locally owned data content buffer has been allocated by the JP2_Box and will be deleted when the JP2_Box is destroyed. If the data content buffer was attached to the JP2_Box it is externally owned and will not be deleted when the JP2_Box is destroyed; in this case it is the responsibility of the data buffer owner to ensure that the buffer remains valid until the JP2_Box will no longer be used.

N.B.: Data content that is not locally owned will not be freed when the JP2_Box is destroyed.

Returns
true if the data content buffer is locally owned, false otherwise.

◆ attach_content()

JP2_Box & attach_content ( unsigned char * data,
unsigned int amount = 0 )

Set the box data content.

Any current content is replaced.

Parameters
dataA pointer (const unsigned char*) to the data content. N.B.: The data data will not be copied. If NULL the box will be emptied and the amount will be ignored.
amountThe number of data bytes. If zero the box will be emptied and the data will be ignored.
Returns
This JP2_Box.
See also
content(unsigned int, const unsigned char*)

◆ append_content() [1/2]

JP2_Box & append_content ( const unsigned char * data,
unsigned int amount )

Append data to the box data content.

N.B.: Data can only be appended to locally owned content.

A new data content buffer is provided that is the size of the current content amount plus the amount of new data. The current content and new data are copied into the new buffer. The previous buffer is deleted, the new buffer becomes the current content and content amount is updated.

Parameters
amountThe number of data bytes. If zero nothing is done.
dataA pointer (const unsigned char*) to the additional data content. If NULL nothing is done.
Returns
This JP2_Box.
Exceptions
logic_errorIf there is a non-zero amount of content that is not locally owned.
length_errorIf insufficient memory is available to allocate the data content buffer.

◆ append_content() [2/2]

JP2_Box & append_content ( const std::string & text)

Append text to the box data content.

N.B.: Data can only be appended to locally owned content.

The characters of the text string, plus a terminating null character, are appended to the current box content.

Parameters
textThe text string to be appended to the box content.
Returns
This JP2_Box.

◆ add() [1/2]

JP2_Box & add ( JP2_Box * sub_box)

Add a sub-box to this box.

If the sub-box is contained in another box it is removed from its container.

The sub-box is added to the end of the list of sub-boxes and its container is set to this JP2_Box.

Parameters
sub_boxA pointer to the JP2_Box that is to be added to this box. If NULL nothing is done.
Returns
This JP2_Box.
Exceptions
invalid_argumentIf the sub-box is this JP2_Box.
See also
remove(JP2_Box*)

◆ add() [2/2]

JP2_Box & add ( JP2_Box & sub_box)
inline

Add a sub-box to this box.

Parameters
sub_boxA pointer to the JP2_Box that is to be added to this box. If NULL nothing is done.
Returns
This JP2_Box.
Exceptions
invalid_argumentIf the sub-box is this JP2_Box.
See also
add(JP2_Box*)

◆ remove()

bool remove ( JP2_Box * sub_box)

Remove a sub-box from this box.

If the sub-box is found in the list of sub-boxes it is removed from the list and its container is set to NULL.

Parameters
sub_boxA pointer to the JP2_Box that is to be removed from this box. A NULL argument is allowed and will be used to remove a NULL entry if one is present, however this should not occur if the add method is always used to add sub-boxes to the box.
Returns
true if the sub-box was removed, or false if the sub-box was not found in this box.
See also
add(JP2_Box*)

◆ sub_boxes()

JP2_Box_List & sub_boxes ( )
inline

Get the list of sub-boxes contained in this box.

Caution: The JP2_Box_List is a vector of JP2_Box pointers which can be manipulated (re-ordered, etc.) as desired, however adding and removing entries should only be done with the add and remove methods to maintain the correct container relationships.

Returns
A reference to the JP2_Box_List for this box.

◆ container()

JP2_Box * container ( ) const
inline

Get the container of this box.

Returns
A pointer to the JP2_Box that has this box in its list of sub-boxes. This will be NULL if this box is not contained in another box.

Member Data Documentation

◆ ID

const char *const ID
static
Initial value:
=
"UA::HiRISE::JP2_Box (1.6 2010/11/24 03:32:14)"

Class identification name with source code version and date.

◆ UUID_BOX_TYPE

const unsigned int UUID_BOX_TYPE = 0x75756964
static

UUID box type.

◆ UUID_SIZE

const unsigned int UUID_SIZE = 16
static

Size of the UUID data content.

Referenced by usage().

◆ UUID_INFO_BOX_TYPE

const unsigned int UUID_INFO_BOX_TYPE = 0x75696E66
static

UUID Info box type.

◆ UUID_LIST_BOX_TYPE

const unsigned int UUID_LIST_BOX_TYPE = 0x756C7374
static

UUID List box type.

◆ URL_BOX_TYPE

const unsigned int URL_BOX_TYPE = 0x75726C20
static

URL box type.

◆ XML_BOX_TYPE

const unsigned int XML_BOX_TYPE = 0x786D6C20
static

XML box type.

◆ ASSOCIATION_BOX_TYPE

const unsigned int ASSOCIATION_BOX_TYPE = 0X61736F63
static

Association box type.

◆ LABEL_BOX_TYPE

const unsigned int LABEL_BOX_TYPE = 0X6C626C20
static

Label box type.

◆ INTELLECTUAL_PROPERTY_BOX_TYPE

const unsigned int INTELLECTUAL_PROPERTY_BOX_TYPE = 0x6A703269
static

Intellectual Property box type.

◆ Type

unsigned int Type
protected

The JP2 box type code.

◆ Content

unsigned char* Content
protected

The data content buffer.

◆ Content_Amount

unsigned int Content_Amount
protected

The amount (bytes) of content data.

◆ Locally_Owned_Content

bool Locally_Owned_Content
protected

Flag for a locally owned data content buffer.

◆ Container

JP2_Box* Container
protected

Pointer to the JP2_Box that contains this box.

◆ Sub_Boxes

JP2_Box_List Sub_Boxes
protected

List of boxes contained in this box.


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