prestonf 2005/03/04 06:55:12
Modified: c/src/soap HeaderBlock.cpp
Log:
Hi All,
I think this will complete what needs to be done for AXISCPP-486.
Regards,
Fred Preston.
Revision Changes Path
1.60 +61 -22 ws-axis/c/src/soap/HeaderBlock.cpp
Index: HeaderBlock.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/HeaderBlock.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- HeaderBlock.cpp 4 Mar 2005 14:06:29 -0000 1.59
+++ HeaderBlock.cpp 4 Mar 2005 14:55:12 -0000 1.60
@@ -609,42 +609,81 @@
/**
* The localname must be specified, but all other input parameters are optional.
*/
-IAttribute* HeaderBlock::createAttribute(const AxisChar *localname,
- const AxisChar *prefix,
- const AxisChar *uri,
- const AxisChar *value)
+IAttribute* HeaderBlock::createAttribute(const AxisChar * pLocalName,
+ const AxisChar * pPrefix,
+ const AxisChar * pURI,
+ const AxisChar * pValue)
{
- Attribute* pAttribute=NULL;
- if(!localname)
+// Check that the contents of the passed parameters are valid.
+ if( pLocalName == NULL || pPrefix == NULL)
{
return NULL;
}
- if(!prefix)
+ else if( strlen( pLocalName) == 0 || strlen( pPrefix) == 0)
{
- prefix="";
+ return NULL;
}
- if(!uri)
+
+ if( !pURI)
{
- uri="";
+ pURI = "";
}
- if(!value)
+
+ if( !pValue)
{
- value = "";
+ pValue = "";
}
-
-
- list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
- while(itCurrAttribute != m_attributes.end())
+
+// Check that the local name and prefix have not already been defined. If
+// they have, then return NULL indicating that the prefix/localname pair have
+// already been defined.
+ list<Attribute*>::iterator itCurrAttribute= m_attributes.begin();
+
+ while( itCurrAttribute != m_attributes.end())
+ {
+ if( (strcmp( (*itCurrAttribute)->getLocalName(), pLocalName) == 0) &&
+ (strcmp( (*itCurrAttribute)->getPrefix(), pPrefix) == 0))
+ {
+ return NULL;
+ }
+ else
+ {
+ itCurrAttribute++;
+ }
+ }
+
+// Check that the prefix has not already been defined in the namespace
+// declarations. If it has, then return NULL indicating that the
+// prefix/localname pair has already been defined and 'copy down' the
+// namespace decl into the attribute list as this will help in the
+// serialisation.
+ list<Namespace*>::iterator itCurrNamespaceDecls = m_namespaceDecls.begin();
+
+ while( itCurrNamespaceDecls != m_namespaceDecls.end())
{
- if ((strcmp((*itCurrAttribute)->getLocalName(), localname) ==0) &&
- (strcmp((*itCurrAttribute)->getPrefix(), prefix) ==0))
+ if( !strcmp( (*itCurrNamespaceDecls)->getPrefix(), pPrefix))
+ {
+ Attribute * pAttribute = new Attribute( pLocalName,
+ pPrefix,
+ (*itCurrNamespaceDecls)->getURI(),
+ pValue);
+
+ m_attributes.push_back( pAttribute);
+
return NULL;
+ }
else
- itCurrAttribute++;
+ {
+ itCurrNamespaceDecls++;
+ }
}
-
- pAttribute = new Attribute(localname, prefix, uri, value);
- m_attributes.push_back(pAttribute);
+
+// If the prefix/localname pair have not previously been defined, then create
+// and return the attribute.
+ Attribute * pAttribute = new Attribute( pLocalName, pPrefix, pURI, pValue);
+
+ m_attributes.push_back( pAttribute);
+
return pAttribute;
}
|