MMSTaffFile Class Reference

A data access class for Tagged Attributes File Format (TAFF). More...

#include <mmstafffile.h>

List of all members.


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.
MMSTaffFilecopyCurrentTag ()
 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_DESCRIPTIONtaff_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

Detailed Description

A data access class for Tagged Attributes File Format (TAFF).

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.

Author:
Jens Schneider

Definition at line 149 of file mmstafffile.h.


Constructor & Destructor Documentation

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.

Parameters:
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 (  ) 

Destructor of class MMSTaffFile.

Definition at line 107 of file mmstafffile.cpp.


Member Function Documentation

bool MMSTaffFile::writeBuffer ( MMSFile file,
void *  ptr,
size_t *  ritems,
size_t  size,
size_t  nitems,
bool *  write_status = NULL 
) [private]

Internal method: Writes a buffer to a file.

Definition at line 112 of file mmstafffile.cpp.

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]

Internal method: Read a PNG Image.

Definition at line 364 of file mmstafffile.cpp.

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]

Internal method: Read a TIFF Image.

Definition at line 688 of file mmstafffile.cpp.

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]

Internal method: XML to TAFF conversion.

Definition at line 1140 of file mmstafffile.cpp.

bool MMSTaffFile::convertIMAGE2TAFF (  )  [private]

Internal method: IMAGE to TAFF conversion.

Definition at line 1211 of file mmstafffile.cpp.

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]

Internal method: TAFF to XML conversion.

Definition at line 1534 of file mmstafffile.cpp.

bool MMSTaffFile::convertExternal2TAFF (  ) 

Convert external file to TAFF.

Definition at line 1404 of file mmstafffile.cpp.

bool MMSTaffFile::convertTAFF2External (  ) 

Convert TAFF to external.

Definition at line 1555 of file mmstafffile.cpp.

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?

Returns:
true if successfully loaded

Definition at line 1662 of file mmstafffile.cpp.

bool MMSTaffFile::checkVersion (  ) 

Has the TAFF file the correct version described in TAFF description?

Returns:
true if correct version

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.

Parameters:
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.

Parameters:
trace print trace messages?

Definition at line 1675 of file mmstafffile.cpp.

void MMSTaffFile::setPrintWarnings ( bool  print_warnings  ) 

Switch print warnings on/off.

Parameters:
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).

Parameters:
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).

Parameters:
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.

Returns:
id of the tag or -1 if an error has occurred

Definition at line 1696 of file mmstafffile.cpp.

int MMSTaffFile::getNextTag ( bool &  eof  ) 

Get the next tag id.

Parameters:
eof if eof set to true after calling this method, the end of file is reached
Returns:
id of the tag or -1 in case of close tag or eof

Definition at line 1709 of file mmstafffile.cpp.

int MMSTaffFile::getCurrentTag ( const char **  name = NULL  ) 

Get the id of the current tag.

Parameters:
name optional, with this parameter you can get the name of the current tag
Returns:
id of the current tag

Definition at line 1758 of file mmstafffile.cpp.

const char * MMSTaffFile::getCurrentTagName (  ) 

Get the name of the current tag.

Returns:
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.

Returns:
pointer to the new MMSTaffFile or NULL in case of errors

Definition at line 1767 of file mmstafffile.cpp.

bool MMSTaffFile::hasAttributes (  ) 

Determine if the current tag has attributes.

Returns:
true if the current tag has at least one attribute

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.

Parameters:
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
Returns:
id of the attribute or -1 in case of close tag has reached

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.

Parameters:
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
Returns:
id of the attribute or -1 in case of close tag has reached

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.

Parameters:
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
Returns:
true if attribute was found

Definition at line 1925 of file mmstafffile.cpp.

char * MMSTaffFile::getAttributeString ( int  id  ) 

Searching for an attribute id within the current tag.

Parameters:
id attribute id to search for
Returns:
pointer to null terminated value string or NULL

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.

Parameters:
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
Returns:
true if conversion was successful
Note:
If method returns true the attrValStr can be invalid anyway (see attrValStr_valid)

Definition at line 739 of file mmstafffile.cpp.


Member Data Documentation

string MMSTaffFile::taff_filename [private]

taff filename

Definition at line 152 of file mmstafffile.h.

describe the tags and attributes

Definition at line 155 of file mmstafffile.h.

unsigned char* MMSTaffFile::taff_buf [private]

binary presentation data

Definition at line 158 of file mmstafffile.h.

size of the buffer

Definition at line 161 of file mmstafffile.h.

current read position

Definition at line 164 of file mmstafffile.h.

name of the external file for conversion

Definition at line 167 of file mmstafffile.h.

type of the external file

Definition at line 170 of file mmstafffile.h.

ignore blank values during the conversion from external file

Definition at line 173 of file mmstafffile.h.

bool MMSTaffFile::trace [private]

print trace messages?

Definition at line 176 of file mmstafffile.h.

print warnings?

Definition at line 179 of file mmstafffile.h.

convert image to this pixelformat

Definition at line 182 of file mmstafffile.h.

should the destination pixels premultiplied?

Definition at line 185 of file mmstafffile.h.

int MMSTaffFile::mirror_size [private]

size of the mirror in pixel

Definition at line 188 of file mmstafffile.h.

bool MMSTaffFile::rotate_180 [private]

rotate by 180 degree?

Definition at line 191 of file mmstafffile.h.

bool MMSTaffFile::loaded [private]

is the TAFF buffer loaded?

Definition at line 194 of file mmstafffile.h.

has the TAFF file the correct version?

Definition at line 197 of file mmstafffile.h.

int MMSTaffFile::current_tag [private]

id of the current tag

Definition at line 200 of file mmstafffile.h.

buffer postion of the current tag

Definition at line 203 of file mmstafffile.h.


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