1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
|
// -*- C++ -*- $Id: AttributesImpl.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ACEXML/common/AttributesImpl.h"
#if !defined (__ACEXML_INLINE__)
# include "ACEXML/common/AttributesImpl.inl"
#endif /* __ACEXML_INLINE__ */
ACEXML_AttributesImpl::ACEXML_AttributesImpl (int size)
: attrs_ (size)
{
this->attrs_.size (0); // attrs array contains nothing
}
ACEXML_AttributesImpl::ACEXML_AttributesImpl (const
ACEXML_AttributesImpl &attrs)
: ACEXML_Attributes (attrs),
attrs_ (attrs.attrs_.size ())
{
for (size_t i = 0; i < attrs.attrs_.size (); i++)
this->attrs_[i] = attrs.attrs_[i];
}
ACEXML_AttributesImpl::~ACEXML_AttributesImpl (void)
{
}
int
ACEXML_AttributesImpl::addAttribute (const ACEXML_Char *uri,
const ACEXML_Char *localName,
const ACEXML_Char *qName,
const ACEXML_Char *type,
const ACEXML_Char *value)
{
if (this->isDuplicate (uri, localName, qName))
return -1;
size_t length = this->attrs_.size ();
this->attrs_.size (length+1);
this->setAttribute (length,
uri,
localName,
qName,
type,
value);
return static_cast<int> (length);
}
int
ACEXML_AttributesImpl::addAttribute (const ACEXML_Attribute &att)
{
if (this->isDuplicate (att.uri(), att.localName(), att.qName()))
return -1;
size_t length = this->attrs_.size ();
this->attrs_.size (length+1);
this->attrs_[length] = att;
return static_cast<int> (length);
}
int
ACEXML_AttributesImpl::isDuplicate (const ACEXML_Char *uri,
const ACEXML_Char *localName,
const ACEXML_Char *qName)
{
for (size_t i = 0; i < this->attrs_.size(); ++i)
{
if (ACE_OS::strcmp (this->attrs_[i].localName(), localName) == 0)
{
if (qName != 0 && this->attrs_[i].qName() != 0
&& ACE_OS::strcmp (this->attrs_[i].qName(), qName) == 0)
{
if (uri != 0 && this->attrs_[i].uri() != 0
&& ACE_OS::strcmp (this->attrs_[i].uri(), uri) == 0)
return 1;
}
}
}
return 0;
}
int
ACEXML_AttributesImpl::removeAttribute (size_t index)
{
size_t length = this->attrs_.size ();
if (index >= length)
return -1;
this->attrs_[index] = this->attrs_[length - 1];
this->attrs_.size (length - 1);
return 0;
}
int
ACEXML_AttributesImpl::getIndex (const ACEXML_Char *qName)
{
for (size_t i = 0; i < this->attrs_.size (); i++)
if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
return static_cast<int> (i);
return -1;
}
int
ACEXML_AttributesImpl::getIndex (const ACEXML_Char *uri,
const ACEXML_Char *localPart)
{
for (size_t i = 0; i < this->attrs_.size (); i++)
if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
return static_cast<int> (i);
return -1;
}
size_t
ACEXML_AttributesImpl::getLength (void)
{
return this->attrs_.size ();
}
const ACEXML_Char *
ACEXML_AttributesImpl::getLocalName (size_t index)
{
if (index < this->attrs_.size ())
return this->attrs_[index].localName ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getQName (size_t index)
{
if (index < this->attrs_.size ())
return this->attrs_[index].qName ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getType (size_t index)
{
if (index < this->attrs_.size ())
return this->attrs_[index].type ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getType (const ACEXML_Char *qName)
{
for (size_t i = 0; i < this->attrs_.size (); i++)
if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
return this->attrs_[i].type ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getType (const ACEXML_Char *uri,
const ACEXML_Char *localPart)
{
for (size_t i = 0; i < this->attrs_.size (); i++)
if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
return this->attrs_[i].type ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getURI (size_t index)
{
if (index < this->attrs_.size ())
return this->attrs_[index].uri ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getValue (size_t index)
{
if (index < this->attrs_.size ())
return this->attrs_[index].value ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getValue (const ACEXML_Char *qName)
{
for (size_t i = 0; i < this->attrs_.size (); i++)
if (ACE_OS::strcmp (qName, this->attrs_[i].qName ()) == 0)
return this->attrs_[i].value ();
return 0;
}
const ACEXML_Char *
ACEXML_AttributesImpl::getValue (const ACEXML_Char *uri,
const ACEXML_Char *localPart)
{
for (size_t i = 0; i < this->attrs_.size (); i++)
if (ACE_OS::strcmp (uri, this->attrs_[i].uri ()) == 0 &&
ACE_OS::strcmp (localPart, this->attrs_[i].localName ()) == 0)
return this->attrs_[i].value ();
return 0;
}
int
ACEXML_AttributesImpl::setAttribute (size_t index,
const ACEXML_Char *uri,
const ACEXML_Char *localName,
const ACEXML_Char *qName,
const ACEXML_Char *type,
const ACEXML_Char *value)
{
if (index < this->attrs_.size ())
{
this->attrs_[index].setAttribute (uri,
localName,
qName,
type,
value);
return 0;
}
return -1;
}
int
ACEXML_AttributesImpl::setLocalName (size_t index,
const ACEXML_Char *localName)
{
if (index < this->attrs_.size ())
{
this->attrs_[index].localName (localName);
return 0;
}
return -1;
}
int
ACEXML_AttributesImpl::setQName (size_t index,
const ACEXML_Char *qName)
{
if (index < this->attrs_.size ())
{
this->attrs_[index].qName (qName);
return 0;
}
return -1;
}
int
ACEXML_AttributesImpl::setURI (size_t index,
const ACEXML_Char *uri)
{
if (index < this->attrs_.size ())
{
this->attrs_[index].uri (uri);
return 0;
}
return -1;
}
int
ACEXML_AttributesImpl::setType (size_t index,
const ACEXML_Char *type)
{
if (index < this->attrs_.size ())
{
this->attrs_[index].type (type);
return 0;
}
return -1;
}
int
ACEXML_AttributesImpl::setValue (size_t index,
const ACEXML_Char *value)
{
if (index < this->attrs_.size ())
{
this->attrs_[index].value (value);
return 0;
}
return -1;
}
|