mirror of
https://github.com/zoriya/xmlParser.git
synced 2026-05-26 23:56:32 +00:00
Adding a get bool
This commit is contained in:
@@ -41,4 +41,5 @@ int xml_gethexaprop(node *n, const char *key);
|
||||
float xml_getfloatprop(node *n, const char *key);
|
||||
int xml_getchildcount(node *n);
|
||||
int xml_getchildcount_filtered(node *n, char *name);
|
||||
bool xml_getbool(node *n, const char *key, bool default_value);
|
||||
void xml_destroy(node *n);
|
||||
@@ -45,4 +45,19 @@ bool xml_propcontains(node *n, const char *key, const char *tofind)
|
||||
char *tmp = xml_gettempprop(n, key);
|
||||
|
||||
return tmp && my_strstr(tmp, tofind);
|
||||
}
|
||||
|
||||
bool xml_getbool(node *n, const char *key, bool default_value)
|
||||
{
|
||||
char *tmp = xml_gettempprop(n, key);
|
||||
|
||||
if (tmp && !my_strcmp(tmp, "true"))
|
||||
return (true);
|
||||
if (tmp && !my_strcmp(tmp, "True"))
|
||||
return (true);
|
||||
if (tmp && !my_strcmp(tmp, "false"))
|
||||
return (false);
|
||||
if (tmp && !my_strcmp(tmp, "False"))
|
||||
return (false);
|
||||
return (default_value);
|
||||
}
|
||||
Reference in New Issue
Block a user