summaryrefslogtreecommitdiff
path: root/ACEXML/common/AttributesImpl.cpp
diff options
context:
space:
mode:
authorkitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-06-24 08:42:35 +0000
committerkitty <kitty@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-06-24 08:42:35 +0000
commit36a5a3e8f48ec265bca4a18673eebf5043586d61 (patch)
treed66d13bb6e29e53eff73a02552399ecfa9d5214c /ACEXML/common/AttributesImpl.cpp
parent55035a3f42ff5f6d08ccacc270b93c7c8cf35a5b (diff)
downloadATCD-36a5a3e8f48ec265bca4a18673eebf5043586d61.tar.gz
ChangeLogTag: Mon Jun 24 03:26:10 2002 Krishnakumar B <kitty@cs.wustl.edu>
Diffstat (limited to 'ACEXML/common/AttributesImpl.cpp')
-rw-r--r--ACEXML/common/AttributesImpl.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/ACEXML/common/AttributesImpl.cpp b/ACEXML/common/AttributesImpl.cpp
index e010dd49cc9..95eb4c2742b 100644
--- a/ACEXML/common/AttributesImpl.cpp
+++ b/ACEXML/common/AttributesImpl.cpp
@@ -32,11 +32,9 @@ ACEXML_AttributesImpl::addAttribute (const ACEXML_Char *uri,
const ACEXML_Char *type,
const ACEXML_Char *value)
{
- // @@ How do I check for the name here? Which name should
- // I use to check for duplication?
-
+ if (this->isDuplicate (uri, localName, qName))
+ return -1;
int length = this->attrs_.size ();
-
this->attrs_.size (length+1);
this->setAttribute (length,
uri,
@@ -50,17 +48,36 @@ ACEXML_AttributesImpl::addAttribute (const ACEXML_Char *uri,
int
ACEXML_AttributesImpl::addAttribute (const ACEXML_Attribute &att)
{
- // @@ How do I check for the name here? Which name should
- // I use to check for duplication?
-
+ if (this->isDuplicate (att.uri(), att.localName(), att.qName()))
+ return -1;
int length = this->attrs_.size ();
-
this->attrs_.size (length+1);
this->attrs_[length] = att;
return 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 ();