summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Glacier/StarterI.cpp2
-rw-r--r--cpp/src/Ice/BasicStream.cpp13
-rw-r--r--cpp/src/Ice/EndpointFactoryManager.cpp2
-rw-r--r--cpp/src/Ice/Object.cpp10
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp2
-rw-r--r--cpp/src/Ice/PropertiesI.cpp4
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp5
-rw-r--r--cpp/src/Ice/TcpEndpoint.cpp7
-rw-r--r--cpp/src/Ice/TcpEndpoint.h2
-rw-r--r--cpp/src/Ice/UdpEndpoint.cpp7
-rw-r--r--cpp/src/Ice/UdpEndpoint.h2
-rw-r--r--cpp/src/IcePatch/ClientUtil.cpp4
-rw-r--r--cpp/src/IcePatch/Util.cpp2
-rw-r--r--cpp/src/IceSSL/OpenSSLUtils.cpp74
-rw-r--r--cpp/src/IceSSL/SslEndpoint.cpp7
-rw-r--r--cpp/src/IceSSL/SslEndpoint.h2
-rw-r--r--cpp/src/IceUtil/InputUtil.cpp30
-rw-r--r--cpp/src/IceUtil/OutputUtil.cpp4
-rw-r--r--cpp/src/IceXML/StreamI.cpp25
-rw-r--r--cpp/src/XMLTransform/XMLTransform.cpp88
20 files changed, 133 insertions, 159 deletions
diff --git a/cpp/src/Glacier/StarterI.cpp b/cpp/src/Glacier/StarterI.cpp
index 6813a22ae43..00672a14552 100644
--- a/cpp/src/Glacier/StarterI.cpp
+++ b/cpp/src/Glacier/StarterI.cpp
@@ -234,7 +234,7 @@ Glacier::StarterI::startRouter(const string& userId, const string& password, Byt
string::size_type end = 0;
while(end != string::npos)
{
- static const string delim = " \t\r\n";
+ const string delim = " \t\r\n";
string::size_type beg = overwrite.find_first_not_of(delim, end);
if(beg == string::npos)
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index 271ce95ad26..48b0ec5f15a 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -23,6 +23,10 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
+const string IceInternal::BasicStream::_emptyString;
+const string IceInternal::BasicStream::_iceObjectId("::Ice::Object");
+const string IceInternal::BasicStream::_userExceptionId("::Ice::UserException");
+
IceInternal::BasicStream::BasicStream(const InstancePtr& instance) :
_instance(instance),
_currentReadEncaps(0),
@@ -837,8 +841,7 @@ IceInternal::BasicStream::write(const ObjectPtr& v)
}
else
{
- static const string empty;
- write(empty);
+ write(_emptyString);
}
}
}
@@ -865,7 +868,6 @@ IceInternal::BasicStream::read(const string& signatureType, const ObjectFactoryP
}
else
{
- static const string iceObject("::Ice::Object");
string id;
read(id);
@@ -874,7 +876,7 @@ IceInternal::BasicStream::read(const string& signatureType, const ObjectFactoryP
v = 0;
return;
}
- else if(id == iceObject)
+ else if(id == _iceObjectId)
{
v = new ::Ice::Object;
}
@@ -925,8 +927,7 @@ IceInternal::BasicStream::throwException(const string* throwsBegin, const string
}
catch(UserException& ex)
{
- static const string userException("::Ice::UserException");
- for(const string* p = ex.__getExceptionIds(); *p != userException != 0; ++p)
+ for(const string* p = ex.__getExceptionIds(); *p != _userExceptionId != 0; ++p)
{
if(binary_search(throwsBegin, throwsEnd, string(*p)))
{
diff --git a/cpp/src/Ice/EndpointFactoryManager.cpp b/cpp/src/Ice/EndpointFactoryManager.cpp
index 84f4e53eaa5..e068c147d8d 100644
--- a/cpp/src/Ice/EndpointFactoryManager.cpp
+++ b/cpp/src/Ice/EndpointFactoryManager.cpp
@@ -69,7 +69,7 @@ IceInternal::EndpointFactoryManager::create(const string& str) const
{
IceUtil::Mutex::Lock sync(*this); // TODO: Necessary?
- static const string delim = " \t\n\r";
+ const string delim = " \t\n\r";
string::size_type beg = str.find_first_not_of(delim);
if(beg == string::npos)
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index ac923c7485a..ae3a08265df 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -258,11 +258,7 @@ Ice::Object::__unmarshal(const ::Ice::StreamPtr& __is)
{
IceUtil::Mutex::Lock sync(_activeFacetMapMutex);
- static const string facetsName = "ice:facets";
- static const string keyName = "ice:key";
- static const string valueName = "ice:value";
-
- Int sz = __is->startReadDictionary(facetsName);
+ Int sz = __is->startReadDictionary("ice::facets");
_activeFacetMap.clear();
_activeFacetMapHint = _activeFacetMap.end();
@@ -271,8 +267,8 @@ Ice::Object::__unmarshal(const ::Ice::StreamPtr& __is)
{
__is->startReadDictionaryElement();
pair<string, ObjectPtr> v;
- v.first = __is->readString(keyName);
- v.second = __is->readObject(valueName, "", 0);
+ v.first = __is->readString("ice:key");
+ v.second = __is->readObject("ice::value", "", 0);
_activeFacetMapHint = _activeFacetMap.insert(_activeFacetMapHint, v);
__is->endReadDictionaryElement();
}
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 23102d5690c..a0916e4c077 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -477,7 +477,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
while(end < s.length())
{
- static const string delim = " \t\n\r";
+ const string delim = " \t\n\r";
beg = s.find_first_not_of(delim, end);
if(beg == string::npos)
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index 2d5da7376fb..8273ad5598c 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -247,7 +247,7 @@ Ice::PropertiesI::PropertiesI(int& argc, char* argv[])
void
Ice::PropertiesI::parseLine(const string& line)
{
- static const string delim = " \t\r\n";
+ const string delim = " \t\r\n";
string s = line;
string::size_type idx = s.find('#');
@@ -310,7 +310,7 @@ Ice::PropertiesI::loadConfig()
if(!value.empty())
{
- static const string delim = " \t\r\n";
+ const string delim = " \t\r\n";
string::size_type beg = value.find_first_not_of(delim);
while(beg != string::npos)
{
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index 9b397c36527..aeca6d1a091 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -32,14 +32,13 @@ IceInternal::ProxyFactory::stringToProxy(const string& str) const
string
IceInternal::ProxyFactory::proxyToString(const ObjectPrx& proxy) const
{
- static const string nilProxy("");
if(proxy)
{
return proxy->__reference()->toString();
}
else
{
- return nilProxy;
+ return "";
}
}
@@ -99,7 +98,7 @@ IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) :
while(true)
{
- static const string delim = " \t";
+ const string delim = " \t";
beg = str.find_first_not_of(delim, end);
if(beg == string::npos)
diff --git a/cpp/src/Ice/TcpEndpoint.cpp b/cpp/src/Ice/TcpEndpoint.cpp
index 8faec7c0648..71cc62db29e 100644
--- a/cpp/src/Ice/TcpEndpoint.cpp
+++ b/cpp/src/Ice/TcpEndpoint.cpp
@@ -35,7 +35,7 @@ IceInternal::TcpEndpoint::TcpEndpoint(const InstancePtr& instance, const string&
_port(0),
_timeout(-1)
{
- static const string delim = " \t\n\r";
+ const string delim = " \t\n\r";
string::size_type beg;
string::size_type end = 0;
@@ -354,11 +354,10 @@ IceInternal::TcpEndpointFactory::type() const
return TcpEndpointType;
}
-const string&
+string
IceInternal::TcpEndpointFactory::protocol() const
{
- const static string result = "tcp";
- return result;
+ return "tcp";
}
EndpointPtr
diff --git a/cpp/src/Ice/TcpEndpoint.h b/cpp/src/Ice/TcpEndpoint.h
index d86eb3c3ead..ac29c50f3e8 100644
--- a/cpp/src/Ice/TcpEndpoint.h
+++ b/cpp/src/Ice/TcpEndpoint.h
@@ -64,7 +64,7 @@ public:
virtual ~TcpEndpointFactory();
virtual ::Ice::Short type() const;
- virtual const ::std::string& protocol() const;
+ virtual ::std::string protocol() const;
virtual EndpointPtr create(const std::string&) const;
virtual EndpointPtr read(BasicStream*) const;
virtual void destroy();
diff --git a/cpp/src/Ice/UdpEndpoint.cpp b/cpp/src/Ice/UdpEndpoint.cpp
index d7d132c293e..4ebb4f1fd7b 100644
--- a/cpp/src/Ice/UdpEndpoint.cpp
+++ b/cpp/src/Ice/UdpEndpoint.cpp
@@ -33,7 +33,7 @@ IceInternal::UdpEndpoint::UdpEndpoint(const InstancePtr& instance, const string&
_port(0),
_connect(false)
{
- static const string delim = " \t\n\r";
+ const string delim = " \t\n\r";
string::size_type beg;
string::size_type end = 0;
@@ -347,11 +347,10 @@ IceInternal::UdpEndpointFactory::type() const
return UdpEndpointType;
}
-const string&
+string
IceInternal::UdpEndpointFactory::protocol() const
{
- const static string result = "udp";
- return result;
+ return "udp";
}
EndpointPtr
diff --git a/cpp/src/Ice/UdpEndpoint.h b/cpp/src/Ice/UdpEndpoint.h
index 8cd827194f6..cc556bb0004 100644
--- a/cpp/src/Ice/UdpEndpoint.h
+++ b/cpp/src/Ice/UdpEndpoint.h
@@ -64,7 +64,7 @@ public:
virtual ~UdpEndpointFactory();
virtual ::Ice::Short type() const;
- virtual const ::std::string& protocol() const;
+ virtual ::std::string protocol() const;
virtual EndpointPtr create(const std::string&) const;
virtual EndpointPtr read(BasicStream*) const;
virtual void destroy();
diff --git a/cpp/src/IcePatch/ClientUtil.cpp b/cpp/src/IcePatch/ClientUtil.cpp
index d715d471893..452893e88c2 100644
--- a/cpp/src/IcePatch/ClientUtil.cpp
+++ b/cpp/src/IcePatch/ClientUtil.cpp
@@ -69,7 +69,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB)
while(posBZ2 < totalBZ2)
{
- static const Int numBZ2 = 64 * 1024;
+ const Int numBZ2 = 64 * 1024;
ByteSeq bytesBZ2 = regular->getBZ2(posBZ2, numBZ2);
if(bytesBZ2.empty())
@@ -132,7 +132,7 @@ IcePatch::getRegular(const RegularPrx& regular, ProgressCB& progressCB)
throw ex;
}
- static const Int numBZ2 = 64 * 1024;
+ const Int numBZ2 = 64 * 1024;
Byte bytesBZ2[numBZ2];
progressCB.startUncompress(totalBZ2, 0);
diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp
index 296f8d54b5b..1dd4eaf402b 100644
--- a/cpp/src/IcePatch/Util.cpp
+++ b/cpp/src/IcePatch/Util.cpp
@@ -633,7 +633,7 @@ IcePatch::createBZ2(const string& path)
throw ex;
}
- static const Int num = 64 * 1024;
+ const Int num = 64 * 1024;
Byte bytes[num];
while(!file.eof())
diff --git a/cpp/src/IceSSL/OpenSSLUtils.cpp b/cpp/src/IceSSL/OpenSSLUtils.cpp
index 1f436921870..2e264cfb791 100644
--- a/cpp/src/IceSSL/OpenSSLUtils.cpp
+++ b/cpp/src/IceSSL/OpenSSLUtils.cpp
@@ -137,7 +137,7 @@ static ::IceUtil::Mutex sslErrorsMutex;
// are routines that have been abducted from the OpenSSL X509 library,
// and modified to work with the STL basic_string template.
-static const char *mon[12]=
+static const char* mon[12]=
{
"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"
@@ -408,45 +408,45 @@ IceSSL::sslGetErrors()
return errorMessage;
}
+static char* errorStrings[] =
+{
+ "Unable to get issuer's certificate.",
+ "Unable to get certificate revocation list.",
+ "Unable to decrypt certificate signature.",
+ "Unable to decrypt certificate revocation list signature.",
+ "Unable to decode issuer's public key.",
+ "Certificate signature failure.",
+ "Certificate revocation list signature failure.",
+ "Certificate not yet valid.",
+ "Certificate has expired.",
+ "Certificate revocation list not yet valid.",
+ "Certificate revocation list has expired.",
+ "Error in certificate's \"not before\" field",
+ "Error in certificate's \"not after\" field",
+ "Error in the certificate revocation list's \"last update\" field",
+ "Error in the certificate revocation list's \"next update\" field",
+ "Out of memory failure.",
+ "Encountered a zero-depth self-signed certificate.",
+ "Encountered self-signed certificate in the certificate chain.",
+ "Unable to get issuer certificate locally.",
+ "Unable to verify leaf signature.",
+ "Certificate chain too long.",
+ "Certificate has been revoked.",
+ "Invalid certificate authority.",
+ "Certificate Authority path length exceeded.",
+ "Invalid certificate purpose.",
+ "Certificate is untrusted.",
+ "Certificate is rejected.",
+ "Subject and Issuer do not match.",
+ "AKID/SKID mismatch.",
+ "AKID and Issuer Serial mismatch.",
+ "Key usage precludes certifiicate signing.",
+ "Application verification."
+};
+
string
IceSSL::getVerificationError(int errorCode)
{
- static char* errorStrings[] =
- {
- "Unable to get issuer's certificate.",
- "Unable to get certificate revocation list.",
- "Unable to decrypt certificate signature.",
- "Unable to decrypt certificate revocation list signature.",
- "Unable to decode issuer's public key.",
- "Certificate signature failure.",
- "Certificate revocation list signature failure.",
- "Certificate not yet valid.",
- "Certificate has expired.",
- "Certificate revocation list not yet valid.",
- "Certificate revocation list has expired.",
- "Error in certificate's \"not before\" field",
- "Error in certificate's \"not after\" field",
- "Error in the certificate revocation list's \"last update\" field",
- "Error in the certificate revocation list's \"next update\" field",
- "Out of memory failure.",
- "Encountered a zero-depth self-signed certificate.",
- "Encountered self-signed certificate in the certificate chain.",
- "Unable to get issuer certificate locally.",
- "Unable to verify leaf signature.",
- "Certificate chain too long.",
- "Certificate has been revoked.",
- "Invalid certificate authority.",
- "Certificate Authority path length exceeded.",
- "Invalid certificate purpose.",
- "Certificate is untrusted.",
- "Certificate is rejected.",
- "Subject and Issuer do not match.",
- "AKID/SKID mismatch.",
- "AKID and Issuer Serial mismatch.",
- "Key usage precludes certifiicate signing.",
- "Application verification."
- };
-
string errString;
if(errorCode > X509_V_ERR_KEYUSAGE_NO_CERTSIGN)
diff --git a/cpp/src/IceSSL/SslEndpoint.cpp b/cpp/src/IceSSL/SslEndpoint.cpp
index 71096443372..fbfdaf7245e 100644
--- a/cpp/src/IceSSL/SslEndpoint.cpp
+++ b/cpp/src/IceSSL/SslEndpoint.cpp
@@ -35,7 +35,7 @@ IceSSL::SslEndpoint::SslEndpoint(const OpenSSLPluginIPtr& plugin, const string&
_port(0),
_timeout(-1)
{
- static const string delim = " \t\n\r";
+ const string delim = " \t\n\r";
string::size_type beg;
string::size_type end = 0;
@@ -354,11 +354,10 @@ IceSSL::SslEndpointFactory::type() const
return SslEndpointType;
}
-const string&
+string
IceSSL::SslEndpointFactory::protocol() const
{
- const static string result = "ssl";
- return result;
+ return "ssl";
}
EndpointPtr
diff --git a/cpp/src/IceSSL/SslEndpoint.h b/cpp/src/IceSSL/SslEndpoint.h
index ba3a10558e5..8ca53330a22 100644
--- a/cpp/src/IceSSL/SslEndpoint.h
+++ b/cpp/src/IceSSL/SslEndpoint.h
@@ -66,7 +66,7 @@ public:
virtual ~SslEndpointFactory();
virtual ::Ice::Short type() const;
- virtual const ::std::string& protocol() const;
+ virtual ::std::string protocol() const;
virtual IceInternal::EndpointPtr create(const std::string&) const;
virtual IceInternal::EndpointPtr read(IceInternal::BasicStream*) const;
virtual void destroy();
diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp
index 322dc195955..5234054c5b0 100644
--- a/cpp/src/IceUtil/InputUtil.cpp
+++ b/cpp/src/IceUtil/InputUtil.cpp
@@ -14,6 +14,20 @@
using namespace std;
+static const string allDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+//
+// Table to convert ASCII digits/letters into their value (100 for unused slots)
+//
+static const char digitVal[] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // '0' - '9'
+ 100, 100, 100, 100, 100, 100, 100, // punctuation
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, // 'A' - 'J'
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, // 'K' - 'T'
+ 30, 31, 32, 33, 34, 35 // 'U' - 'Z'
+};
+
namespace IceUtil
{
@@ -88,23 +102,9 @@ strToInt64(const char* s, char** endptr, int base)
return 0;
}
- static const string allDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- const string validDigits(allDigits.begin(), allDigits.begin() + base);
-
- //
- // Table to convert ASCII digits/letters into their value (100 for unused slots)
- //
- static const char digitVal[] =
- {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // '0' - '9'
- 100, 100, 100, 100, 100, 100, 100, // punctuation
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, // 'A' - 'J'
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, // 'K' - 'T'
- 30, 31, 32, 33, 34, 35 // 'U' - 'Z'
- };
-
Int64 result = 0;
bool overflow = false;
+ const string validDigits(allDigits.begin(), allDigits.begin() + base);
while(*s && validDigits.find_first_of(toupper(*s)) != validDigits.npos)
{
if(!overflow)
diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp
index b29ecd1a9be..8d41b73bc32 100644
--- a/cpp/src/IceUtil/OutputUtil.cpp
+++ b/cpp/src/IceUtil/OutputUtil.cpp
@@ -481,7 +481,7 @@ IceUtil::XMLOutput::escape(const string& input) const
// Find out whether there is a reserved character to avoid
// conversion if not necessary.
//
- static const string allReserved = "<>'\"&";
+ const string allReserved = "<>'\"&";
if(v.find_first_of(allReserved) != string::npos)
{
//
@@ -497,7 +497,7 @@ IceUtil::XMLOutput::escape(const string& input) const
//
// Next convert remaining reserved characters.
//
- static const string reserved = "<>'\"";
+ const string reserved = "<>'\"";
pos = 0;
while((pos = v.find_first_of(reserved, pos)) != string::npos)
{
diff --git a/cpp/src/IceXML/StreamI.cpp b/cpp/src/IceXML/StreamI.cpp
index 0dd8abaa73b..916a61aaff6 100644
--- a/cpp/src/IceXML/StreamI.cpp
+++ b/cpp/src/IceXML/StreamI.cpp
@@ -999,8 +999,7 @@ IceXML::StreamI::readString(const string& name)
}
else
{
- static const string empty("");
- value = empty;
+ value = "";
}
endRead();
@@ -1169,9 +1168,7 @@ IceXML::StreamI::readObject(const string& name, const string& signatureType, con
}
else
{
- static const string iceObject("::Ice::Object");
-
- if(type == iceObject)
+ if(type == "::Ice::Object")
{
value = new ::Ice::Object;
}
@@ -1316,8 +1313,8 @@ IceXML::StreamI::writeObjectData(const string& name, const string& id, const Ice
//
typeId = obj->ice_id();
- static const string xsdPrefix = "_internal.";
- static const string xsdSuffix = "Type";
+ const string xsdPrefix = "_internal.";
+ const string xsdSuffix = "Type";
xsdType.reserve(typeId.size() + xsdPrefix.size() + xsdSuffix.size());
xsdType += xsdPrefix;
unsigned int i = 0;
@@ -1362,25 +1359,21 @@ IceXML::StreamI::writeObjectData(const string& name, const string& id, const Ice
void
IceXML::StreamI::readAttributes(::std::string& id, ::std::string& type, ::std::string& href)
{
- static const string idStr("id");
- static const string typeStr("type");
- static const string hrefStr("href");
-
DOMNamedNodeMap* attributes = _input->current->getAttributes();
int attrCount = attributes->getLength();
for(int i = 0; i < attrCount; i++)
{
DOMNode* attribute = attributes->item(i);
string name = toString(attribute->getNodeName());
- if(name == idStr)
+ if(name == "id")
{
id = toString(attribute->getNodeValue());
}
- else if(name == typeStr)
+ else if(name == "type")
{
type = toString(attribute->getNodeValue());
}
- else if(name == hrefStr)
+ else if(name == "href")
{
href = toString(attribute->getNodeValue());
}
@@ -1390,15 +1383,13 @@ IceXML::StreamI::readAttributes(::std::string& id, ::std::string& type, ::std::s
::Ice::Int
IceXML::StreamI::readLength()
{
- static const string lengthStr("length");
-
DOMNamedNodeMap* attributes = _input->current->getAttributes();
int attrCount = attributes->getLength();
for(int i = 0; i < attrCount; i++)
{
DOMNode* attribute = attributes->item(i);
string name = toString(attribute->getNodeName());
- if(name == lengthStr)
+ if(name == "length")
{
return atoi(toString(attribute->getNodeValue()).c_str());
}
diff --git a/cpp/src/XMLTransform/XMLTransform.cpp b/cpp/src/XMLTransform/XMLTransform.cpp
index 32e26f71743..02e72eb744d 100644
--- a/cpp/src/XMLTransform/XMLTransform.cpp
+++ b/cpp/src/XMLTransform/XMLTransform.cpp
@@ -261,15 +261,13 @@ getAttributeByName(DOMNode* node, const string& name)
static string
getTypeAttribute(DOMNode* node)
{
- static const string typeName = "type";
- return getAttributeByName(node, typeName);
+ return getAttributeByName(node, "type");
}
static string
getNameAttribute(DOMNode* node)
{
- static const string nameName = "name";
- return getAttributeByName(node, nameName);
+ return getAttributeByName(node, "name");
}
//
@@ -316,16 +314,13 @@ XMLTransform::DocumentInfo::DocumentInfo(DOMDocument* document, bool releaseDocu
_releaseDocument(releaseDocument),
_targetNamespace(targetNamespace)
{
- static const string targetNamespaceAttrName = "targetNamespace";
- static const string xmlnsAttrName = "xmlns";
-
DOMNamedNodeMap* attributes = root->getAttributes();
unsigned int max = attributes->getLength();
for(unsigned int i = 0; i < max; ++i)
{
DOMNode* attribute = attributes->item(i);
string attrName = toString(attribute->getNodeName());
- if(attrName.substr(0, 5) == xmlnsAttrName)
+ if(attrName.substr(0, 5) == "xmlns")
{
string ns;
if(attrName.size() > 5)
@@ -335,7 +330,7 @@ XMLTransform::DocumentInfo::DocumentInfo(DOMDocument* document, bool releaseDocu
string uri = toString(attribute->getNodeValue());
_nsMap.insert(make_pair(ns, uri));
}
- else if(attrName == targetNamespaceAttrName)
+ else if(attrName == "targetNamespace")
{
_targetNamespace = toString(attribute->getNodeValue());
}
@@ -788,9 +783,8 @@ public:
continue;
}
- static const string sequenceElementName = "e";
string nodeName = toString(child->getLocalName());
- if(l == 0 || nodeName != sequenceElementName)
+ if(l == 0 || nodeName != "e")
{
throw SchemaViolation(__FILE__, __LINE__);
}
@@ -906,8 +900,7 @@ public:
// as-is. The referenced object, which is a child of the
// root node, will be transformed automatically.
//
- static const string hrefAttrName = "href";
- string id = getAttributeByName(node, hrefAttrName);
+ string id = getAttributeByName(node, "href");
if(!id.empty())
{
os << node;
@@ -917,8 +910,7 @@ public:
//
// Otherwise, xsi:type must be present.
//
- static const string xsitypeAttrName = "xsi:type";
- string type = getAttributeByName(node, xsitypeAttrName);
+ string type = getAttributeByName(node, "xsi:type");
if(type.empty())
{
throw SchemaViolation(__FILE__, __LINE__);
@@ -1523,27 +1515,27 @@ struct StringTypeTable
}
+static const StringTypeTable items[] =
+{
+ { "enumeration", TypeEnumeration },
+ { "struct", TypeStruct },
+ { "class", TypeClass },
+ { "exception", TypeException },
+ { "dictionary", TypeDictionary },
+ { "sequence", TypeSequence },
+ { "proxy", TypeProxy },
+ { "reference", TypeReference },
+ { "internal", TypeInternal }
+};
+static const StringTypeTable* itemsBegin = &items[0];
+static const StringTypeTable* itemsEnd = &items[sizeof(items)/sizeof(items[0])];
+
TransformFactory::Type
XMLTransform::TransformFactory::getType(DOMNode* node)
{
//
// Check the appinfo element for the actual type.
//
- static const StringTypeTable items[] =
- {
- { "enumeration", TypeEnumeration },
- { "struct", TypeStruct },
- { "class", TypeClass },
- { "exception", TypeException },
- { "dictionary", TypeDictionary },
- { "sequence", TypeSequence },
- { "proxy", TypeProxy },
- { "reference", TypeReference },
- { "internal", TypeInternal }
- };
- static const StringTypeTable* begin = &items[0];
- static const StringTypeTable* end = &items[sizeof(items)/sizeof(items[0])];
-
string type;
//
@@ -1567,7 +1559,7 @@ XMLTransform::TransformFactory::getType(DOMNode* node)
}
}
- const StringTypeTable* p = find(begin, end, type);
+ const StringTypeTable* p = find(itemsBegin, itemsEnd, type);
if(p == end)
{
InvalidSchema ex(__FILE__, __LINE__);
@@ -1578,6 +1570,19 @@ XMLTransform::TransformFactory::getType(DOMNode* node)
return p->type;
}
+static const StringTypeTable itemsByName[] =
+{
+ { "xs:byte", TypeInteger },
+ { "xs:short", TypeInteger },
+ { "xs:int", TypeInteger },
+ { "xs:long", TypeInteger },
+ { "xs:float", TypeFloat },
+ { "xs:double", TypeFloat },
+ { "xs:string", TypeString },
+};
+static const StringTypeTable* itemsByNameBegin = &itemsByName[0];
+static const StringTypeTable* itemsByNameEnd = &itemsByName[sizeof(itemsByName)/sizeof(itemsByName[0])];
+
TransformFactory::Type
XMLTransform::TransformFactory::getTypeByName(const DocumentMap& docs, const DocumentInfoPtr& info, const string& type,
DOMNode*& n, DocumentInfoPtr& nInfo)
@@ -1585,20 +1590,7 @@ XMLTransform::TransformFactory::getTypeByName(const DocumentMap& docs, const Doc
//
// First check to see if the type is a primitive schema type.
//
- static const StringTypeTable items[] =
- {
- { "xs:byte", TypeInteger },
- { "xs:short", TypeInteger },
- { "xs:int", TypeInteger },
- { "xs:long", TypeInteger },
- { "xs:float", TypeFloat },
- { "xs:double", TypeFloat },
- { "xs:string", TypeString },
- };
- static const StringTypeTable* begin = &items[0];
- static const StringTypeTable* end = &items[sizeof(items)/sizeof(items[0])];
-
- const StringTypeTable* p = find(begin, end, type);
+ const StringTypeTable* p = find(itemsByNameBegin, itemsByNameEnd, type);
if(p != end)
{
return p->type;
@@ -1977,8 +1969,6 @@ XMLTransform::TransformFactory::createClassContentTransform(const DocumentInfoPt
const DocumentInfoPtr& toInfo, DOMNode* to,
vector<ElementTransformPtr>& v)
{
- static const string baseAttrName = "base";
-
DOMNode* fromContent = findChild(from, complexContentElementName);
DOMNode* toContent = findChild(to, complexContentElementName);
@@ -2006,8 +1996,8 @@ XMLTransform::TransformFactory::createClassContentTransform(const DocumentInfoPt
throw InvalidSchema(__FILE__, __LINE__);
}
- string fromBaseName = getAttributeByName(fromExtension, baseAttrName);
- string toBaseName = getAttributeByName(toExtension, baseAttrName);
+ string fromBaseName = getAttributeByName(fromExtension, "base");
+ string toBaseName = getAttributeByName(toExtension, "base");
//
// It's not legal to change the base class.