3 #include "ACEXML/common/AttributesImpl.h"
5 #if !defined (__ACEXML_INLINE__)
6 # include "ACEXML/common/AttributesImpl.inl"
7 #endif /* __ACEXML_INLINE__ */
9 ACEXML_AttributesImpl::ACEXML_AttributesImpl (int size
)
12 this->attrs_
.size (0); // attrs array contains nothing
15 ACEXML_AttributesImpl::ACEXML_AttributesImpl (const
16 ACEXML_AttributesImpl
&attrs
)
17 : ACEXML_Attributes (attrs
),
18 attrs_ (attrs
.attrs_
.size ())
20 for (size_t i
= 0; i
< attrs
.attrs_
.size (); i
++)
21 this->attrs_
[i
] = attrs
.attrs_
[i
];
24 ACEXML_AttributesImpl::~ACEXML_AttributesImpl ()
29 ACEXML_AttributesImpl::addAttribute (const ACEXML_Char
*uri
,
30 const ACEXML_Char
*localName
,
31 const ACEXML_Char
*qName
,
32 const ACEXML_Char
*type
,
33 const ACEXML_Char
*value
)
35 if (this->isDuplicate (uri
, localName
, qName
))
37 size_t length
= this->attrs_
.size ();
38 this->attrs_
.size (length
+1);
39 this->setAttribute (length
,
45 return static_cast<int> (length
);
49 ACEXML_AttributesImpl::addAttribute (const ACEXML_Attribute
&att
)
51 if (this->isDuplicate (att
.uri(), att
.localName(), att
.qName()))
53 size_t length
= this->attrs_
.size ();
54 this->attrs_
.size (length
+1);
55 this->attrs_
[length
] = att
;
56 return static_cast<int> (length
);
60 ACEXML_AttributesImpl::isDuplicate (const ACEXML_Char
*uri
,
61 const ACEXML_Char
*localName
,
62 const ACEXML_Char
*qName
)
64 for (size_t i
= 0; i
< this->attrs_
.size(); ++i
)
66 if (ACE_OS::strcmp (this->attrs_
[i
].localName(), localName
) == 0)
68 if (qName
!= 0 && this->attrs_
[i
].qName() != 0
69 && ACE_OS::strcmp (this->attrs_
[i
].qName(), qName
) == 0)
71 if (uri
!= 0 && this->attrs_
[i
].uri() != 0
72 && ACE_OS::strcmp (this->attrs_
[i
].uri(), uri
) == 0)
81 ACEXML_AttributesImpl::removeAttribute (size_t index
)
83 size_t length
= this->attrs_
.size ();
88 this->attrs_
[index
] = this->attrs_
[length
- 1];
89 this->attrs_
.size (length
- 1);
96 ACEXML_AttributesImpl::getIndex (const ACEXML_Char
*qName
)
98 for (size_t i
= 0; i
< this->attrs_
.size (); i
++)
99 if (ACE_OS::strcmp (qName
, this->attrs_
[i
].qName ()) == 0)
100 return static_cast<int> (i
);
106 ACEXML_AttributesImpl::getIndex (const ACEXML_Char
*uri
,
107 const ACEXML_Char
*localPart
)
109 for (size_t i
= 0; i
< this->attrs_
.size (); i
++)
110 if (ACE_OS::strcmp (uri
, this->attrs_
[i
].uri ()) == 0 &&
111 ACE_OS::strcmp (localPart
, this->attrs_
[i
].localName ()) == 0)
112 return static_cast<int> (i
);
118 ACEXML_AttributesImpl::getLength ()
120 return this->attrs_
.size ();
124 ACEXML_AttributesImpl::getLocalName (size_t index
)
126 if (index
< this->attrs_
.size ())
127 return this->attrs_
[index
].localName ();
133 ACEXML_AttributesImpl::getQName (size_t index
)
135 if (index
< this->attrs_
.size ())
136 return this->attrs_
[index
].qName ();
141 ACEXML_AttributesImpl::getType (size_t index
)
143 if (index
< this->attrs_
.size ())
144 return this->attrs_
[index
].type ();
150 ACEXML_AttributesImpl::getType (const ACEXML_Char
*qName
)
152 for (size_t i
= 0; i
< this->attrs_
.size (); i
++)
153 if (ACE_OS::strcmp (qName
, this->attrs_
[i
].qName ()) == 0)
154 return this->attrs_
[i
].type ();
160 ACEXML_AttributesImpl::getType (const ACEXML_Char
*uri
,
161 const ACEXML_Char
*localPart
)
163 for (size_t i
= 0; i
< this->attrs_
.size (); i
++)
164 if (ACE_OS::strcmp (uri
, this->attrs_
[i
].uri ()) == 0 &&
165 ACE_OS::strcmp (localPart
, this->attrs_
[i
].localName ()) == 0)
166 return this->attrs_
[i
].type ();
173 ACEXML_AttributesImpl::getURI (size_t index
)
175 if (index
< this->attrs_
.size ())
176 return this->attrs_
[index
].uri ();
182 ACEXML_AttributesImpl::getValue (size_t index
)
184 if (index
< this->attrs_
.size ())
185 return this->attrs_
[index
].value ();
190 ACEXML_AttributesImpl::getValue (const ACEXML_Char
*qName
)
192 for (size_t i
= 0; i
< this->attrs_
.size (); i
++)
193 if (ACE_OS::strcmp (qName
, this->attrs_
[i
].qName ()) == 0)
194 return this->attrs_
[i
].value ();
200 ACEXML_AttributesImpl::getValue (const ACEXML_Char
*uri
,
201 const ACEXML_Char
*localPart
)
203 for (size_t i
= 0; i
< this->attrs_
.size (); i
++)
204 if (ACE_OS::strcmp (uri
, this->attrs_
[i
].uri ()) == 0 &&
205 ACE_OS::strcmp (localPart
, this->attrs_
[i
].localName ()) == 0)
206 return this->attrs_
[i
].value ();
212 ACEXML_AttributesImpl::setAttribute (size_t index
,
213 const ACEXML_Char
*uri
,
214 const ACEXML_Char
*localName
,
215 const ACEXML_Char
*qName
,
216 const ACEXML_Char
*type
,
217 const ACEXML_Char
*value
)
219 if (index
< this->attrs_
.size ())
221 this->attrs_
[index
].setAttribute (uri
,
234 ACEXML_AttributesImpl::setLocalName (size_t index
,
235 const ACEXML_Char
*localName
)
237 if (index
< this->attrs_
.size ())
239 this->attrs_
[index
].localName (localName
);
246 ACEXML_AttributesImpl::setQName (size_t index
,
247 const ACEXML_Char
*qName
)
249 if (index
< this->attrs_
.size ())
251 this->attrs_
[index
].qName (qName
);
259 ACEXML_AttributesImpl::setURI (size_t index
,
260 const ACEXML_Char
*uri
)
262 if (index
< this->attrs_
.size ())
264 this->attrs_
[index
].uri (uri
);
271 ACEXML_AttributesImpl::setType (size_t index
,
272 const ACEXML_Char
*type
)
274 if (index
< this->attrs_
.size ())
276 this->attrs_
[index
].type (type
);
283 ACEXML_AttributesImpl::setValue (size_t index
,
284 const ACEXML_Char
*value
)
286 if (index
< this->attrs_
.size ())
288 this->attrs_
[index
].value (value
);