Class ImageLib
#include <ImageLib.h >
The ImageLib class manages stored images in the ImageLib DB table.
This class holds a reference to and then ultimately delivers the binary content of an image in the Image Library (the ImageLib table). This class holds the image id, name, category, image type, height and width of the image.
ImageLibId id |
If specified, the DB record id of the image. Default value: 0 |
Constructor. Existing image in DB table.
const string& name |
the name for the image |
const string& category |
the category for the image (provide by your app architect) |
Constructor. Create a new image by name and category
const string& data |
a serialized ImageLib object data, represented as a string |
Convert a serialized ImageLib object into the object.
const HashArray& data |
a HashArray of ImageLib data |
Convert a HashArray of an ImageLib object into an object.
const ImageLib& p |
the image to copy |
Copy constructor
Reset/Clear the contents of this class
Determine if this instance is valid data or not.
Get the DB table record number for the image.
Return value: the record id
Get the name of the image.
Return value: the image name
Get the category (grouping name) for the image, e.g. icon, custom.
A category is app-specific, not system defined.
Return value: the image's category
Get the image type, e.g. gif, jpg, pdf, etc
Return value: the image type
Get the data that is the image.
Return value: data for the image
Get the checksum for the image
Return value: the image's checksum
Get the height of the image (in pixels), if known.
Return value: image height if known, otherwise 0
Get the width of the image (in pixels), if known.
Return value: image width if known, otherwise 0
Get the User DB record id of the owner of the image.
Return value: the owner id
Get the size of the image (in bytes).
Return value: image size
ImageLibId newId |
ImageLib record id |
Set the ImageLib DB record id for this image
const string& newName |
new name for the image |
Set the name for this image. A name should be unique within a category.
const string& newCategory |
new category for the image |
Set the category for this image. This is handy for grouping images.
const string& newType |
new image type for the image, e.g. jpg, gif, pdf, etc. |
Set the image type for this image.
const RawData& newImage |
new image for this instance |
Set the image data for this image.
unsigned int newChecksum |
new checksum for the image |
Set the checksum for this image.
int newHeight |
new height for the image |
Set the height for this image.
int newWidth |
new width for the image |
Set the width for this image.
DbRecNum newOwnerId |
new User id for the image |
Set the owner's User id for this image.
const HashArray& data |
data to copy (unknown keys ignored) |
Given a HashArray of properties, assign those properties into this
instance. This is the complement of toHashArray().
const ImageLib& other |
the other ImageLib image for comparison |
Compare two images to determine if they are the same.
Return value: true if images are the same, false if they are different
const ImageLib& other |
the other ImageLib image for comparison |
Compare two images to determine if they are not the same
Return value: true if images are the different, false if they are same
const string& data |
a string (generated by toString()) |
Given a serialized ImageLib image, reconstruct this ImageLib instance to it.
Return value: true if the image was reconstructed, false if not
Create a serialized string of this ImageLib.
Return value: a string representation of this object
Calculate the image's checksum
Return value: the checksum
Recalculate the image's checksum (after a new image is loaded)
ImageLibId id |
the ImageLib record id to query |
Query image name without pulling it into memory.
Return value: the name of the image
ImageLibId id |
the ImageLib record id to query |
int& height |
(output) the height of the object (in pixels) |
int& width |
(output) the width of the object (in pixels) |
Query image height and width without pulling it into memory.
Return value: true upon success, false upon failure (invalid id or DB issue)
ImageLibId id |
the ImageLib record id to query |
Query image type without pulling it into memory.
Return value: the type of the image, e.g. gif, jpg, pdf, etc
const string& name |
the image name to find within the category |
const string& category |
the category to search |
Given an image name and category, locate its ImageLib record id.
Return value: record id of ImageLib match, 0 if not found
bool forDB |
true if data is heading to Datastore, false for other communication Default value: false |
Convert structure data to HashArray.
Return value: a HashArray with the ImageLib data
bool forDB |
Default value: false |
Convert structure data to XML for communication.
Return value: an XML structure of the ImageLib
Save the record to the datastore.
Return value: 1+ upon success (the id), 0 upon failure
ImageLibId id |
the ImageLib record id to load |
Load data from db
Return value: true if loaded; false it not
ImageLibId id |
DB record if of this image |
string Name |
The name of the image (unique inside category) |
string Category |
The category for this image |
string Type |
The type of image, e.g. gif, jpg, pdf, etc |
RawData Image |
The data of the image itself |
unsigned int Checksum |
The checksum for the image |
int Height |
The height and width of the image |
int Width |
The height and width of the image |
DbRecNum Owner_id |
The User owner of the image |
bool changed |
Flag: true if data was changed and needs to be saved |
static Datastore db |
Our connection to DB table data |
Make sure we're connected to our table in the Datastore
Return value: true upon success, false upon failure
Add a new record to the Datastore.
If the Id is set, it will be used; if 0, a new Id will be assigned.
Return value: the new record's record Id