| 
|  |  |  | XML Security Library Reference Manual |  | 
 
 
The XML Security Library is written in C but it uses some OOP techniques:
	the objects in the library have "klasses" and there is "klasses" inheritance.
	(see signature and
	encryption klasses 
	diagrams). The "klass" is different from C++ "class" (btw, this is 
	one of the reasons why it is spelled differently). The idea of "klasses" 
	used in XML Security Library are close to one in the GLIB/GTK/GNOME
	and many other C projects. If you ever seen an OOP code written in C
	you should find everything familiar.
	 XML Security Library "klass" includes three main parts:
	 
"Klass" declaration structure that defines "klass" interfaces
	and global constant data (for example, the human-readable name of 
	the "klass").
	 
Example 6. Base transform "klass" and its child XPath transform "klass" structure. struct _xmlSecTransformKlass {
    /* data */
    size_t				klassSize;
    size_t				objSize;
    const xmlChar*			name;
    const xmlChar*			href;
    xmlSecTransformUsage		usage;
    /* methods */
    xmlSecTransformInitializeMethod	initialize;
    xmlSecTransformFinalizeMethod	finalize;
    xmlSecTransformNodeReadMethod	readNode;
    xmlSecTransformNodeWriteMethod	writeNode;
    ...
};
...
static xmlSecTransformKlass xmlSecTransformXPathKlass = {
    /* klass/object sizes */
    sizeof(xmlSecTransformKlass),	/* size_t klassSize */
    xmlSecXPathTransformSize,		/* size_t objSize */
    xmlSecNameXPath,			/* const xmlChar* name; */
    xmlSecXPathNs, 			/* const xmlChar* href; */
    xmlSecTransformUsageDSigTransform,	/* xmlSecTransformUsage	usage; */
    xmlSecTransformXPathInitialize,	/* xmlSecTransformInitializeMethod initialize; */
    xmlSecTransformXPathFinalize,	/* xmlSecTransformFinalizeMethod finalize; */
    xmlSecTransformXPathNodeRead,	/* xmlSecTransformNodeReadMethod readNode; */
    NULL,				/* xmlSecTransformNodeWriteMethod writeNode; */
    
    ...
};
	    
"Klass" id which is simply a pointer to the "klass"
	declaration strucutre. "Klass" id is used to bind "klass" objects 
	to the "klass" declaration and to pass "klass" strucutre to functions.
	 
Example 7. Base transform "klass" id declaration and its child XPath transform "klass" id implementation. typedef const struct _xmlSecTransformKlass		xmlSecTransformKlass, *xmlSecTransformId;
...
#define xmlSecTransformXPathId 		xmlSecTransformXPathGetKlass()
...
xmlSecTransformId 
xmlSecTransformXPathGetKlass(void) {
    return(&xmlSecTransformXPathKlass);
}
	    
"Klass" object structure that contains object specific
	data. The child object specific data are placed after the parent "klass"
	object data.
	 
Example 8. Base transform object strucutre and its child XPath transform object. struct _xmlSecTransform {
    xmlSecTransformId 			id; 
    xmlSecTransformOperation		operation;
    xmlSecTransformStatus		status;
    xmlNodePtr				hereNode;
    /* transforms chain */
    xmlSecTransformPtr			next;
    xmlSecTransformPtr			prev;
    
    ...
};
...
/******************************************************************************
 *
 * XPath/XPointer transforms
 *
 * xmlSecPtrList with XPath expressions is located after xmlSecTransform structure
 * 
 *****************************************************************************/
#define xmlSecXPathTransformSize	\
    (sizeof(xmlSecTransform) + sizeof(xmlSecPtrList))
#define xmlSecXPathTransformGetDataList(transform) \
    ((xmlSecTransformCheckSize((transform), xmlSecXPathTransformSize)) ? \
	(xmlSecPtrListPtr)(((unsigned char*)(transform)) + sizeof(xmlSecTransform)) : \
	(xmlSecPtrListPtr)NULL)
	     |