source: trunk/src/core/scew/attribute.c @ 5673

Last change on this file since 5673 was 5673, checked in by ldelgass, 9 years ago

Fix line endings, set eol-style to native on all C/C++ sources.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1/**
2 *
3 * @file     attribute.c
4 * @author   Aleix Conchillo Flaque <aleix@member.fsf.org>
5 * @date     Mon Nov 25, 2002 00:41
6 * @brief    SCEW attribute type implementation
7 *
8 * $Id: attribute.c,v 1.1 2004/01/28 00:43:21 aleix Exp $
9 *
10 * @if copyright
11 *
12 * Copyright (C) 2002, 2003 Aleix Conchillo Flaque
13 *
14 * SCEW is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * SCEW is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
27 *
28 * @endif
29 */
30
31#include "xattribute.h"
32
33#include "xerror.h"
34#include "xelement.h"
35
36#include "str.h"
37
38#include <assert.h>
39#include <string.h>
40
41
42scew_attribute*
43scew_attribute_create(XML_Char const* name, XML_Char const* value)
44{
45    return attribute_create(name, value);
46}
47
48void
49scew_attribute_free(scew_attribute* attribute)
50{
51    attribute_free(attribute);
52}
53
54unsigned int
55scew_attribute_count(scew_element const* element)
56{
57    assert(element != NULL);
58
59    return element->attributes->size;
60}
61
62scew_attribute*
63scew_attribute_next(scew_element const* element,
64                    scew_attribute const* attribute)
65{
66    scew_attribute *next_attribute;
67
68    if (attribute == NULL)
69    {
70        if (element == NULL)
71        {
72            return NULL;
73        }
74        next_attribute = element->attributes->first;
75    }
76    else
77    {
78        next_attribute = attribute->next;
79    }
80
81    return next_attribute;
82}
83
84scew_attribute*
85scew_attribute_by_index(scew_element const* element, unsigned int idx)
86{
87    return attribute_by_index(element->attributes, idx);
88}
89
90scew_attribute*
91scew_attribute_by_name(scew_element const* element, XML_Char const* name)
92{
93    return attribute_by_name(element->attributes, name);
94}
95
96XML_Char const*
97scew_attribute_name(scew_attribute const* attribute)
98{
99    assert(attribute != NULL);
100
101    return attribute->name;
102}
103
104XML_Char const*
105scew_attribute_value(scew_attribute const* attribute)
106{
107    assert(attribute != NULL);
108
109    return attribute->value;
110}
111
112XML_Char const*
113scew_attribute_set_name(scew_attribute* attribute, XML_Char const* name)
114{
115    assert(attribute != NULL);
116    assert(name != NULL);
117
118    free(attribute->name);
119    attribute->name = scew_strdup(name);
120
121    return attribute->name;
122}
123
124XML_Char const*
125scew_attribute_set_value(scew_attribute* attribute, XML_Char const* value)
126{
127    assert(attribute != NULL);
128    assert(value != NULL);
129
130    free(attribute->value);
131    attribute->value = scew_strdup(value);
132
133    return attribute->value;
134}
Note: See TracBrowser for help on using the repository browser.