WIP: devel : travail du mois de mars/avril #28
42
src/model.c
42
src/model.c
|
@ -112,6 +112,48 @@ int model_modify_node(xmlHashTablePtr hashTable,
|
|||
return 0; // Node not found or unable to modify
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the value of an attribute for a node identified by its path.
|
||||
*
|
||||
* @param hashTable The hash table containing nodes indexed by their paths.
|
||||
* @param nodePath The path to the node.
|
||||
* @param attributeName The name of the attribute.
|
||||
* @return The value of the attribute, or NULL if not found.
|
||||
*/
|
||||
char* model_get_attribute (xmlHashTablePtr hashTable,
|
||||
const char* nodePath,
|
||||
const char* attributeName)
|
||||
{
|
||||
xmlNodePtr node = (xmlNodePtr)xmlHashLookup(hashTable, (const xmlChar*)nodePath);
|
||||
if (node) {
|
||||
return getAttributeValue(node, attributeName);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or updates the value of an attribute for a node identified by its path.
|
||||
*
|
||||
* @param hashTable The hash table containing nodes indexed by their paths.
|
||||
* @param nodePath The path to the node.
|
||||
* @param attributeName The name of the attribute to set.
|
||||
* @param attributeValue The value to set for the attribute.
|
||||
* @return 1 on success, 0 on failure.
|
||||
*/
|
||||
int model_set_attribute (xmlHashTablePtr hashTable,
|
||||
const char* nodePath,
|
||||
const char* attributeName,
|
||||
const char* attributeValue)
|
||||
{
|
||||
xmlNodePtr node = (xmlNodePtr)xmlHashLookup(hashTable, (const xmlChar*)nodePath);
|
||||
if (node) {
|
||||
return setAttributeValue(node, attributeName, attributeValue);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
char model_get_dim (struct model_t *self)
|
||||
|
|
Loading…
Reference in New Issue