#include <mmstafffile.h>
Public Member Functions | |
MMSTaffFile (string taff_filename, TAFF_DESCRIPTION *taff_desc, string external_filename="", MMSTAFF_EXTERNAL_TYPE external_type=MMSTAFF_EXTERNAL_TYPE_XML, bool ignore_blank_values=false, bool trace=false, bool print_warnings=false, bool force_rewrite_taff=false, bool auto_rewrite_taff=true) | |
Constructor of class MMSTaffFile. | |
~MMSTaffFile () | |
Destructor of class MMSTaffFile. | |
bool | convertExternal2TAFF () |
Convert external file to TAFF. | |
bool | convertTAFF2External () |
Convert TAFF to external. | |
bool | readFile () |
Read the TAFF file. This will normally done in the constructor. | |
bool | isLoaded () |
Is TAFF buffer filled? | |
bool | checkVersion () |
Has the TAFF file the correct version described in TAFF description? | |
void | setExternal (string external_filename="", MMSTAFF_EXTERNAL_TYPE external_type=MMSTAFF_EXTERNAL_TYPE_XML) |
Set or reset the external file and type. | |
void | setTrace (bool trace) |
Switch trace on/off. | |
void | setPrintWarnings (bool print_warnings) |
Switch print warnings on/off. | |
void | setDestinationPixelFormat (MMSTAFF_PF pixelformat=MMSTAFF_PF_ARGB, bool premultiplied=true) |
Set the final pixelformat for the convertion (type MMSTAFF_EXTERNAL_TYPE_IMAGE). | |
void | setMirrorEffect (int size) |
Set the mirror effect (type MMSTAFF_EXTERNAL_TYPE_IMAGE). | |
void | rotate180 (bool rotate_180) |
Rotate the image by 180 degree (type MMSTAFF_EXTERNAL_TYPE_IMAGE). | |
int | getFirstTag () |
Get the first tag id. | |
int | getNextTag (bool &eof) |
Get the next tag id. | |
int | getCurrentTag (const char **name=NULL) |
Get the id of the current tag. | |
const char * | getCurrentTagName () |
Get the name of the current tag. | |
MMSTaffFile * | copyCurrentTag () |
Copy the complete current tag into a new MMSTaffFile. | |
bool | hasAttributes () |
Determine if the current tag has attributes. | |
int | getFirstAttribute (char **value_str, int *value_int, char **name=NULL) |
Get the first attribute of the current tag. | |
int | getNextAttribute (char **value_str, int *value_int, char **name=NULL) |
Get the next attributes of the current tag. | |
bool | getAttribute (int id, char **value_str, int *value_int) |
Searching for an attribute id within the current tag. | |
char * | getAttributeString (int id) |
Searching for an attribute id within the current tag. | |
bool | convertString2TaffAttributeType (TAFF_ATTRTYPE attrType, char *attrValStr, bool *attrValStr_valid, bool *int_val_set, bool *byte_val_set, int *int_val, const char *attrname=NULL, int attrid=-1, const char *nodename=0, int nodeline=-1) |
Convert a value given as string into binary format and check ranges. | |
Private Member Functions | |
bool | writeBuffer (MMSFile *file, void *ptr, size_t *ritems, size_t size, size_t nitems, bool *write_status=NULL) |
Internal method: Writes a buffer to a file. | |
bool | postprocessImage (void **buf, int *width, int *height, int *pitch, int *size, bool *alphachannel) |
Internal method: Create mirror effect, rotate and convert to target pixelformat. | |
bool | readPNG (const char *filename, void **buf, int *width, int *height, int *pitch, int *size, bool *alphachannel) |
Internal method: Read a PNG Image. | |
bool | readJPEG (const char *filename, void **buf, int *width, int *height, int *pitch, int *size, bool *alphachannel) |
Internal method: Read a JPEG Image. | |
bool | readTIFF (const char *filename, void **buf, int *width, int *height, int *pitch, int *size, bool *alphachannel) |
Internal method: Read a TIFF Image. | |
bool | convertXML2TAFF_throughDoc (int depth, void *void_node, MMSFile *taff_file) |
Internal method: Recursive called method for XML to TAFF conversion. | |
bool | convertXML2TAFF () |
Internal method: XML to TAFF conversion. | |
bool | convertIMAGE2TAFF () |
Internal method: IMAGE to TAFF conversion. | |
bool | convertTAFF2XML_throughDoc (int depth, int tagid, MMSFile *external_file) |
Internal method: Recursive called method for TAFF to XML conversion. | |
bool | convertTAFF2XML () |
Internal method: TAFF to XML conversion. | |
Private Attributes | |
string | taff_filename |
taff filename | |
TAFF_DESCRIPTION * | taff_desc |
describe the tags and attributes | |
unsigned char * | taff_buf |
binary presentation data | |
int | taff_buf_size |
size of the buffer | |
int | taff_buf_pos |
current read position | |
string | external_filename |
name of the external file for conversion | |
MMSTAFF_EXTERNAL_TYPE | external_type |
type of the external file | |
bool | ignore_blank_values |
ignore blank values during the conversion from external file | |
bool | trace |
print trace messages? | |
bool | print_warnings |
print warnings? | |
MMSTAFF_PF | destination_pixelformat |
convert image to this pixelformat | |
bool | destination_premultiplied |
should the destination pixels premultiplied? | |
int | mirror_size |
size of the mirror in pixel | |
bool | rotate_180 |
rotate by 180 degree? | |
bool | loaded |
is the TAFF buffer loaded? | |
bool | correct_version |
has the TAFF file the correct version? | |
int | current_tag |
id of the current tag | |
int | current_tag_pos |
buffer postion of the current tag |
This class is written to generate an simple to parse binary presentation of high level markup languages such as XML. For now the conversion XML to TAFF or vice versa and PNG/JPEG/TIFF to TAFF is supported. The user of this class must specify a description of which tags and attributes are allowed. Further he specifies the type of an attribute. With this informations this class also checks the types and ranges of attributes during the conversion. For example the MMSGUI works completely with TAFF.
Definition at line 149 of file mmstafffile.h.
MMSTaffFile::MMSTaffFile | ( | string | taff_filename, | |
TAFF_DESCRIPTION * | taff_desc, | |||
string | external_filename = "" , |
|||
MMSTAFF_EXTERNAL_TYPE | external_type = MMSTAFF_EXTERNAL_TYPE_XML , |
|||
bool | ignore_blank_values = false , |
|||
bool | trace = false , |
|||
bool | print_warnings = false , |
|||
bool | force_rewrite_taff = false , |
|||
bool | auto_rewrite_taff = true | |||
) |
Constructor of class MMSTaffFile.
taff_filename | under this name the converted TAFF buffer is/will be stored | |
taff_desc | the user of this class have to support this tag/attribute description, use NULL here if you use the external type MMSTAFF_EXTERNAL_TYPE_IMAGE | |
external_filename | name of the external file for conversion set to blank if no conversion is to be done in the constructor | |
external_type | type of the external file | |
ignore_blank_values | ignore blank values during the conversion from external file | |
trace | print trace messages? | |
print_warnings | print warnings? | |
force_rewrite_taff | (re-)convert from external file before loading TAFF | |
auto_rewrite_taff | (re-)convert from external file if the TAFF file is older than the external file |
Definition at line 60 of file mmstafffile.cpp.
MMSTaffFile::~MMSTaffFile | ( | ) |
bool MMSTaffFile::writeBuffer | ( | MMSFile * | file, | |
void * | ptr, | |||
size_t * | ritems, | |||
size_t | size, | |||
size_t | nitems, | |||
bool * | write_status = NULL | |||
) | [private] |
bool MMSTaffFile::postprocessImage | ( | void ** | buf, | |
int * | width, | |||
int * | height, | |||
int * | pitch, | |||
int * | size, | |||
bool * | alphachannel | |||
) | [private] |
Internal method: Create mirror effect, rotate and convert to target pixelformat.
Definition at line 134 of file mmstafffile.cpp.
bool MMSTaffFile::readPNG | ( | const char * | filename, | |
void ** | buf, | |||
int * | width, | |||
int * | height, | |||
int * | pitch, | |||
int * | size, | |||
bool * | alphachannel | |||
) | [private] |
bool MMSTaffFile::readJPEG | ( | const char * | filename, | |
void ** | buf, | |||
int * | width, | |||
int * | height, | |||
int * | pitch, | |||
int * | size, | |||
bool * | alphachannel | |||
) | [private] |
Internal method: Read a JPEG Image.
< Output row buffer
< physical row width in output buffer
< setting output colorspace to RGB
Definition at line 559 of file mmstafffile.cpp.
bool MMSTaffFile::readTIFF | ( | const char * | filename, | |
void ** | buf, | |||
int * | width, | |||
int * | height, | |||
int * | pitch, | |||
int * | size, | |||
bool * | alphachannel | |||
) | [private] |
bool MMSTaffFile::convertXML2TAFF_throughDoc | ( | int | depth, | |
void * | void_node, | |||
MMSFile * | taff_file | |||
) | [private] |
Internal method: Recursive called method for XML to TAFF conversion.
Definition at line 920 of file mmstafffile.cpp.
bool MMSTaffFile::convertXML2TAFF | ( | ) | [private] |
bool MMSTaffFile::convertIMAGE2TAFF | ( | ) | [private] |
bool MMSTaffFile::convertTAFF2XML_throughDoc | ( | int | depth, | |
int | tagid, | |||
MMSFile * | external_file | |||
) | [private] |
Internal method: Recursive called method for TAFF to XML conversion.
Definition at line 1414 of file mmstafffile.cpp.
bool MMSTaffFile::convertTAFF2XML | ( | ) | [private] |
bool MMSTaffFile::convertExternal2TAFF | ( | ) |
bool MMSTaffFile::convertTAFF2External | ( | ) |
bool MMSTaffFile::readFile | ( | ) |
Read the TAFF file. This will normally done in the constructor.
Definition at line 1566 of file mmstafffile.cpp.
bool MMSTaffFile::isLoaded | ( | ) |
Is TAFF buffer filled?
Definition at line 1662 of file mmstafffile.cpp.
bool MMSTaffFile::checkVersion | ( | ) |
Has the TAFF file the correct version described in TAFF description?
Definition at line 1666 of file mmstafffile.cpp.
void MMSTaffFile::setExternal | ( | string | external_filename = "" , |
|
MMSTAFF_EXTERNAL_TYPE | external_type = MMSTAFF_EXTERNAL_TYPE_XML | |||
) |
Set or reset the external file and type.
external_filename | name of the external file for conversion | |
external_type | type of the external file |
Definition at line 1670 of file mmstafffile.cpp.
void MMSTaffFile::setTrace | ( | bool | trace | ) |
Switch trace on/off.
trace | print trace messages? |
Definition at line 1675 of file mmstafffile.cpp.
void MMSTaffFile::setPrintWarnings | ( | bool | print_warnings | ) |
Switch print warnings on/off.
print_warnings | print warnings? |
Definition at line 1679 of file mmstafffile.cpp.
void MMSTaffFile::setDestinationPixelFormat | ( | MMSTAFF_PF | pixelformat = MMSTAFF_PF_ARGB , |
|
bool | premultiplied = true | |||
) |
Set the final pixelformat for the convertion (type MMSTAFF_EXTERNAL_TYPE_IMAGE).
pixelformat | final pixelformat | |
premultiplied | the image will be premultiplied during the conversion |
Definition at line 1683 of file mmstafffile.cpp.
void MMSTaffFile::setMirrorEffect | ( | int | size | ) |
Set the mirror effect (type MMSTAFF_EXTERNAL_TYPE_IMAGE).
size | size of the mirror effect in pixel |
Definition at line 1688 of file mmstafffile.cpp.
void MMSTaffFile::rotate180 | ( | bool | rotate_180 | ) |
Rotate the image by 180 degree (type MMSTAFF_EXTERNAL_TYPE_IMAGE).
Definition at line 1692 of file mmstafffile.cpp.
int MMSTaffFile::getFirstTag | ( | ) |
Get the first tag id.
Definition at line 1696 of file mmstafffile.cpp.
int MMSTaffFile::getNextTag | ( | bool & | eof | ) |
Get the next tag id.
eof | if eof set to true after calling this method, the end of file is reached |
Definition at line 1709 of file mmstafffile.cpp.
int MMSTaffFile::getCurrentTag | ( | const char ** | name = NULL |
) |
Get the id of the current tag.
name | optional, with this parameter you can get the name of the current tag |
Definition at line 1758 of file mmstafffile.cpp.
const char * MMSTaffFile::getCurrentTagName | ( | ) |
Get the name of the current tag.
Definition at line 1763 of file mmstafffile.cpp.
MMSTaffFile * MMSTaffFile::copyCurrentTag | ( | ) |
Copy the complete current tag into a new MMSTaffFile.
Definition at line 1767 of file mmstafffile.cpp.
bool MMSTaffFile::hasAttributes | ( | ) |
Determine if the current tag has attributes.
Definition at line 1830 of file mmstafffile.cpp.
int MMSTaffFile::getFirstAttribute | ( | char ** | value_str, | |
int * | value_int, | |||
char ** | name = NULL | |||
) |
Get the first attribute of the current tag.
value_str | return pointer to null terminated value string or NULL if value is returned by value_int parameter | |
value_int | a few types of attributes will be directly stored in binary format and will be returned by this parameter | |
name | optional, with this parameter you can get the name of the attribute |
Definition at line 1838 of file mmstafffile.cpp.
int MMSTaffFile::getNextAttribute | ( | char ** | value_str, | |
int * | value_int, | |||
char ** | name = NULL | |||
) |
Get the next attributes of the current tag.
value_str | return pointer to null terminated value string or NULL if value is returned by value_int parameter | |
value_int | a few types of attributes will be directly stored in binary format and will be returned by this parameter | |
name | optional, with this parameter you can get the name of the attribute |
Definition at line 1853 of file mmstafffile.cpp.
bool MMSTaffFile::getAttribute | ( | int | id, | |
char ** | value_str, | |||
int * | value_int | |||
) |
Searching for an attribute id within the current tag.
id | attribute id to search for | |
value_str | return pointer to null terminated value string or NULL if value is returned by value_int parameter | |
value_int | a few types of attributes will be directly stored in binary format and will be returned by this parameter |
Definition at line 1925 of file mmstafffile.cpp.
char * MMSTaffFile::getAttributeString | ( | int | id | ) |
Searching for an attribute id within the current tag.
id | attribute id to search for |
Definition at line 1936 of file mmstafffile.cpp.
bool MMSTaffFile::convertString2TaffAttributeType | ( | TAFF_ATTRTYPE | attrType, | |
char * | attrValStr, | |||
bool * | attrValStr_valid, | |||
bool * | int_val_set, | |||
bool * | byte_val_set, | |||
int * | int_val, | |||
const char * | attrname = NULL , |
|||
int | attrid = -1 , |
|||
const char * | nodename = 0 , |
|||
int | nodeline = -1 | |||
) |
Convert a value given as string into binary format and check ranges.
attrType | type of the attribute value string | |
attrValStr | attribute value string | |
attrValStr_valid | returns if attribute value string is valid | |
int_val_set | returns true if the value is an integer (int) | |
byte_val_set | returns true if the value is an byte (unsigned char) | |
int_val | binary presentation of the value if int_val_set or byte_val_set set to true | |
attrname | optional attribute name needed for error messages | |
attrid | optional attribute id needed for error messages | |
nodename | optional tag name needed for error messages | |
nodeline | optional line needed for error messages |
Definition at line 739 of file mmstafffile.cpp.
string MMSTaffFile::taff_filename [private] |
TAFF_DESCRIPTION* MMSTaffFile::taff_desc [private] |
unsigned char* MMSTaffFile::taff_buf [private] |
int MMSTaffFile::taff_buf_size [private] |
int MMSTaffFile::taff_buf_pos [private] |
string MMSTaffFile::external_filename [private] |
bool MMSTaffFile::ignore_blank_values [private] |
ignore blank values during the conversion from external file
Definition at line 173 of file mmstafffile.h.
bool MMSTaffFile::trace [private] |
bool MMSTaffFile::print_warnings [private] |
bool MMSTaffFile::destination_premultiplied [private] |
int MMSTaffFile::mirror_size [private] |
bool MMSTaffFile::rotate_180 [private] |
bool MMSTaffFile::loaded [private] |
bool MMSTaffFile::correct_version [private] |
int MMSTaffFile::current_tag [private] |
int MMSTaffFile::current_tag_pos [private] |