![]() |
PDS_JP2
|
A JP2_Box contains JP2 file format box data. More...
#include <JP2_Box.hh>
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_Box & | type_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_Box & | type_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_Box & | content (const unsigned char *data, unsigned int amount=0) |
Set the box data content. | |
JP2_Box & | content (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_Box & | attach_content (unsigned char *data, unsigned int amount=0) |
Set the box data content. | |
JP2_Box & | append_content (const unsigned char *data, unsigned int amount) |
Append data to the box data content. | |
JP2_Box & | append_content (const std::string &text) |
Append text to the box data content. | |
JP2_Box & | add (JP2_Box *sub_box) |
Add a sub-box to this box. | |
JP2_Box & | add (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_List & | sub_boxes () |
Get the list of sub-boxes contained in this box. | |
JP2_Box * | container () 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 = "UA::HiRISE::JP2_Box (1.6 2010/11/24 03:32:14)" |
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_Box * | Container |
Pointer to the JP2_Box that contains this box. | |
JP2_Box_List | Sub_Boxes |
List of boxes contained in this box. |
A JP2_Box contains JP2 file format box data.
typedef std::vector<JP2_Box*> JP2_Box_List |
List of JP2 boxes.
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.
box_type | The 32-bit integer box type code value. |
amount | The number of data content bytes. If zero the box will be emptied and the data will be ignored. |
data | A 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. |
invalid_argument | If a type code byte value does not correspond to a printable character (<32 or >126). |
length_error | If insufficient memory is available to allocate the data content buffer. |
References box_name().
JP2_Box | ( | unsigned int | box_type, |
const std::string & | text | ||
) | [explicit] |
Construct a JP2_Box of some type with text content.
box_type | The 32-bit integer box type code value. |
text | The text string to be set as the box content. |
References box_name().
~JP2_Box | ( | ) | [virtual] |
Destroy this JP2_Box.
Any locally owned content data is freed.
References JP2_Box::Content, JP2_Box::Locally_Owned_Content, and JP2_Box::Sub_Boxes.
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.
invalid_argument | If the type code is an invalid value. |
References JP2_Box::Type, and JP2_Box::type_name().
Referenced by JP2_Box::add(), and JP2_Box::type_name().
JP2_Box & type_name | ( | const std::string & | name ) |
Set the type name of the box.
name | The type name to be applied to the JP2 box. |
invalid_argument | If the string does not contain exactly four characters or any character is not printable (<32 or >126). |
unsigned int type_code | ( | ) | const [inline] |
Get the type code of the box.
The type code is the second value of each JP2 box.
References JP2_Box::Type.
Referenced by JP2_Encoder::write_user_boxes().
JP2_Box & type_code | ( | unsigned int | box_type ) |
Set the type code of the box.
box_type | The 32-bit integer box type code value. |
invalid_argument | If a type code byte value does not correspond to a printable character (<32 or >126). |
References box_type().
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.
References JP2_Box::Content_Amount.
unsigned char* content | ( | ) | const [inline] |
Get the box data content.
References JP2_Box::Content.
JP2_Box & content | ( | const unsigned char * | data, |
unsigned int | amount = 0 |
||
) |
Set the box data content.
Any current content is replaced.
data | A 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. |
amount | The number of data bytes. If zero the box will be emptied and the data will be ignored. |
length_error | If insufficient memory is available to allocate the data content buffer. |
References ID.
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.
text | The text string to be set as the box content. |
length_error | If insufficient memory is available to allocate the data content buffer. |
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.
References JP2_Box::Locally_Owned_Content.
JP2_Box & attach_content | ( | unsigned char * | data, |
unsigned int | amount = 0 |
||
) |
Set the box data content.
Any current content is replaced.
data | A 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. |
amount | The number of data bytes. If zero the box will be emptied and the data will be ignored. |
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.
amount | The number of data bytes. If zero nothing is done. |
data | A pointer (const unsigned char*) to the additional data content. If NULL nothing is done. |
logic_error | If there is a non-zero amount of content that is not locally owned. |
length_error | If insufficient memory is available to allocate the data content buffer. |
References box_type(), and ID.
Referenced by PDS_Projection_Data::JP2_GeoTIFF().
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.
text | The text string to be appended to the box content. |
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.
sub_box | A pointer to the JP2_Box that is to be added to this box. If NULL nothing is done. |
invalid_argument | If the sub-box is this JP2_Box. |
References box_name(), JP2_Box::Container, ID, JP2_Box::remove(), JP2_Box::Type, and JP2_Box::type_name().
Referenced by PDS_Projection_Data::JP2_GML().
Add a sub-box to this box.
sub_box | A pointer to the JP2_Box that is to be added to this box. If NULL nothing is done. |
invalid_argument | If the sub-box is this JP2_Box. |
References JP2_Box::add().
Referenced by JP2_Box::add().
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.
sub_box | A 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. |
References JP2_Box::Container.
Referenced by JP2_Box::add().
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.
References JP2_Box::Sub_Boxes.
JP2_Box* container | ( | ) | const [inline] |
Get the container of this box.
References JP2_Box::Container.
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.
box_type | The box type code value to be converted. |
invalid_argument | If a type code byte value does not correspond to a printable character (<32 or >126). |
References ID.
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.
name | The type name string to be converted. |
invalid_argument | If the string does not contain exactly four characters or any character is not printable (<32 or >126). |
References ID.
const char *const ID = "UA::HiRISE::JP2_Box (1.6 2010/11/24 03:32:14)" [static] |
Class identification name with source code version and date.
const unsigned int UUID_BOX_TYPE = 0x75756964 [static] |
UUID box type.
Referenced by PDS_Projection_Data::JP2_GeoTIFF().
const unsigned int UUID_SIZE = 16 [static] |
Size of the UUID data content.
const unsigned int UUID_INFO_BOX_TYPE = 0x75696E66 [static] |
UUID Info box type.
const unsigned int UUID_LIST_BOX_TYPE = 0x756C7374 [static] |
UUID List box type.
const unsigned int URL_BOX_TYPE = 0x75726C20 [static] |
URL box type.
const unsigned int XML_BOX_TYPE = 0x786D6C20 [static] |
XML box type.
Referenced by PDS_Projection_Data::JP2_GML().
const unsigned int ASSOCIATION_BOX_TYPE = 0X61736F63 [static] |
Association box type.
Referenced by PDS_Projection_Data::JP2_GML().
const unsigned int LABEL_BOX_TYPE = 0X6C626C20 [static] |
Label box type.
Referenced by PDS_Projection_Data::JP2_GML().
const unsigned int INTELLECTUAL_PROPERTY_BOX_TYPE = 0x6A703269 [static] |
Intellectual Property box type.
unsigned int Type [protected] |
The JP2 box type code.
Referenced by JP2_Box::add(), JP2_Box::type_code(), and JP2_Box::type_name().
unsigned char* Content [protected] |
The data content buffer.
Referenced by JP2_Box::content(), and JP2_Box::~JP2_Box().
unsigned int Content_Amount [protected] |
The amount (bytes) of content data.
Referenced by JP2_Box::content_amount().
bool Locally_Owned_Content [protected] |
Flag for a locally owned data content buffer.
Referenced by JP2_Box::locally_owned_content(), and JP2_Box::~JP2_Box().
Pointer to the JP2_Box that contains this box.
Referenced by JP2_Box::add(), JP2_Box::container(), and JP2_Box::remove().
JP2_Box_List Sub_Boxes [protected] |
List of boxes contained in this box.
Referenced by JP2_Box::sub_boxes(), and JP2_Box::~JP2_Box().