From eac37c6a45837f7ea717c9fed8cb21e2d5665618 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Fri, 31 Jan 2020 17:36:15 +0300 Subject: [xift] Working. --- src/attribute.cpp | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/attribute.cpp') diff --git a/src/attribute.cpp b/src/attribute.cpp index 4458713..d6f928a 100644 --- a/src/attribute.cpp +++ b/src/attribute.cpp @@ -5,6 +5,23 @@ #include +XiftAttribute::XiftAttribute(): + name(0), nlen(0), nsize(0), value(0), vlen(0), vsize(0) +{} + +XiftAttribute::~XiftAttribute() +{ + if (name) free(name); + if (value) free(value); +} + + +bool XiftAttribute::MatchesForm(const XiftAttribute &form) const +{ + return !strcmp(name, form.name); +} + + XiftAttributes::XiftAttributes(): stack(0) {} @@ -18,7 +35,7 @@ XiftAttributes::~XiftAttributes() } -XiftAttributes::Attr &XiftAttributes::Attribute(const char *name) +XiftAttribute &XiftAttributes::Attribute(const char *name) { Stack *current = stack; while (current) { @@ -27,7 +44,7 @@ XiftAttributes::Attr &XiftAttributes::Attribute(const char *name) } current = current->next; } - Attr &res = New(); + XiftAttribute &res = New(); res.nlen = strlen(name); res.name = xift_str_create_copy(name, name + res.nlen); res.nsize = res.nlen + 1; @@ -49,24 +66,7 @@ void XiftAttributes::Remove(const char *name) } -XiftAttributes::Attr::Attr(): - name(0), nlen(0), nsize(0), value(0), vlen(0), vsize(0) -{} - -XiftAttributes::Attr::~Attr() -{ - if (name) free(name); - if (value) free(value); -} - - -bool XiftAttributes::Attr::MatchesForm(const XiftAttributes::Attr &form) const -{ - return !strcmp(name, form.name); -} - - -XiftAttributes::Attr *XiftAttributes::Top() +XiftAttribute *XiftAttributes::Top() { if (stack) { return &stack->item; @@ -84,7 +84,7 @@ void XiftAttributes::Pop() } } -XiftAttributes::Attr &XiftAttributes::New() +XiftAttribute &XiftAttributes::New() { Stack *old = stack; stack = new Stack; @@ -92,9 +92,7 @@ XiftAttributes::Attr &XiftAttributes::New() return stack->item; } -bool XiftAttributes::ContainsMatchedForm( - const XiftAttributes::Attr &attribute -) const +bool XiftAttributes::ContainsMatchedForm(const XiftAttribute &attribute) const { Stack *current = stack; while (current) { -- cgit v1.2.3