40 lines
877 B
C
40 lines
877 B
C
#include <blue/ds/string.h>
|
|
#include <mie/attribute/attribute-definition.h>
|
|
#include <mie/dialect/dialect.h>
|
|
|
|
struct mie_attribute_definition *mie_attribute_definition_create(
|
|
struct mie_dialect *parent, const char *name)
|
|
{
|
|
struct mie_attribute_definition *out = malloc(sizeof *out);
|
|
if (!out) {
|
|
return NULL;
|
|
}
|
|
|
|
memset(out, 0x0, sizeof *out);
|
|
|
|
out->a_name = b_strdup(name);
|
|
if (!out->a_name) {
|
|
free(out);
|
|
return NULL;
|
|
}
|
|
|
|
out->a_parent = parent;
|
|
|
|
b_rope name_rope = B_ROPE_CSTR(name);
|
|
mie_id_map_put(&parent->d_attributes, &out->a_id, &name_rope);
|
|
|
|
return out;
|
|
}
|
|
|
|
bool mie_attribute_definition_check_name(
|
|
const struct mie_attribute_definition *def, const char *dialect_name,
|
|
const char *attrib_name)
|
|
{
|
|
if (!def || !def->a_parent) {
|
|
return false;
|
|
}
|
|
|
|
return (!strcmp(def->a_name, attrib_name)
|
|
&& !strcmp(def->a_parent->d_name, dialect_name));
|
|
}
|