diff options
author | Marc Laukien <marc@zeroc.com> | 2002-09-22 17:07:43 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-09-22 17:07:43 +0000 |
commit | ee9134f129672068403f488e9a326411ca9cc1b1 (patch) | |
tree | 5bd03a07398ed4ffd2fc8d929ab4a0ce97a843a1 | |
parent | fixes (diff) | |
download | ice-ee9134f129672068403f488e9a326411ca9cc1b1.tar.bz2 ice-ee9134f129672068403f488e9a326411ca9cc1b1.tar.xz ice-ee9134f129672068403f488e9a326411ca9cc1b1.zip |
removed several static's
31 files changed, 225 insertions, 227 deletions
diff --git a/cpp/demo/IceStorm/clock/Publisher.cpp b/cpp/demo/IceStorm/clock/Publisher.cpp index 751c730d0a9..103a2bbcb29 100644 --- a/cpp/demo/IceStorm/clock/Publisher.cpp +++ b/cpp/demo/IceStorm/clock/Publisher.cpp @@ -34,7 +34,7 @@ Publisher::run(int argc, char* argv[]) { Ice::PropertiesPtr properties = communicator()->getProperties(); - static const string proxyProperty = "IceStorm.TopicManager.Proxy"; + const string proxyProperty = "IceStorm.TopicManager.Proxy"; string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) { diff --git a/cpp/demo/IceStorm/clock/Subscriber.cpp b/cpp/demo/IceStorm/clock/Subscriber.cpp index 766df81d859..bb9cb8cca9b 100644 --- a/cpp/demo/IceStorm/clock/Subscriber.cpp +++ b/cpp/demo/IceStorm/clock/Subscriber.cpp @@ -37,7 +37,7 @@ Subscriber::run(int argc, char* argv[]) { Ice::PropertiesPtr properties = communicator()->getProperties(); - static const string proxyProperty = "IceStorm.TopicManager.Proxy"; + const string proxyProperty = "IceStorm.TopicManager.Proxy"; string proxy = properties->getProperty(proxyProperty); if(proxy.empty()) { diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h index 35fb2817043..9a47ea11896 100644 --- a/cpp/include/Ice/BasicStream.h +++ b/cpp/include/Ice/BasicStream.h @@ -138,6 +138,10 @@ private: std::vector<WriteEncaps> _writeEncapsStack; ReadEncaps* _currentReadEncaps; WriteEncaps* _currentWriteEncaps; + + static const std::string _emptyString; + static const std::string _iceObjectId; + static const std::string _userExceptionId; }; } diff --git a/cpp/include/Ice/EndpointFactory.h b/cpp/include/Ice/EndpointFactory.h index 709d64f0d8b..5780b370477 100644 --- a/cpp/include/Ice/EndpointFactory.h +++ b/cpp/include/Ice/EndpointFactory.h @@ -27,7 +27,7 @@ public: virtual ~EndpointFactory(); virtual ::Ice::Short type() const = 0; - virtual const ::std::string& protocol() const = 0; + virtual ::std::string protocol() const = 0; virtual EndpointPtr create(const std::string&) const = 0; virtual EndpointPtr read(BasicStream*) const = 0; virtual void destroy() = 0; 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. diff --git a/cpp/test/Freeze/complex/Client.cpp b/cpp/test/Freeze/complex/Client.cpp index 650507431fe..f479733cb9d 100644 --- a/cpp/test/Freeze/complex/Client.cpp +++ b/cpp/test/Freeze/complex/Client.cpp @@ -51,19 +51,19 @@ validate(const DBPtr& db) return EXIT_SUCCESS; } +static const char* expressions[] = +{ + "2", + "10", + "2+(5*3)", + "5*(2+3)", + "10+(10+(20+(8*(2*(3*2+4+5+6)))))" +}; +static const int nexpressions = sizeof(expressions)/sizeof(expressions[0]); + static int populate(const DBPtr& db) { - static const char* expressions[] = - { - "2", - "10", - "2+(5*3)", - "5*(2+3)", - "10+(10+(20+(8*(2*(3*2+4+5+6)))))" - }; - static int nexpressions = sizeof(expressions)/sizeof(expressions[0]); - Complex::ComplexDict m(db); cout << "populating the database... "; diff --git a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp index 3c0c0d2b6bf..97d2b75847f 100644 --- a/cpp/test/IceUtil/thread/MonitorMutexTest.cpp +++ b/cpp/test/IceUtil/thread/MonitorMutexTest.cpp @@ -33,7 +33,7 @@ public: Monitor<Mutex>::TryLock lock(_monitor); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -119,7 +119,7 @@ MonitorMutexTest::run() Monitor<Mutex>::TryLock lock(monitor); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } diff --git a/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp b/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp index 64c016610b2..911ade1f8df 100644 --- a/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/MonitorRecMutexTest.cpp @@ -33,7 +33,7 @@ public: Monitor<RecMutex>::TryLock lock(_monitor); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -121,7 +121,7 @@ MonitorRecMutexTest::run() { Monitor<RecMutex>::TryLock lock(monitor); } - catch(const LockedException&) + catch(const ThreadLockedException&) { test(false); } diff --git a/cpp/test/IceUtil/thread/MutexTest.cpp b/cpp/test/IceUtil/thread/MutexTest.cpp index c0aaf437760..f1c3f4a8e36 100644 --- a/cpp/test/IceUtil/thread/MutexTest.cpp +++ b/cpp/test/IceUtil/thread/MutexTest.cpp @@ -35,7 +35,7 @@ public: Mutex::TryLock lock(_mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -90,7 +90,7 @@ MutexTest::run() Mutex::TryLock lock2(mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } diff --git a/cpp/test/IceUtil/thread/RWRecMutexTest.cpp b/cpp/test/IceUtil/thread/RWRecMutexTest.cpp index 9987970f235..353314080cd 100644 --- a/cpp/test/IceUtil/thread/RWRecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/RWRecMutexTest.cpp @@ -67,7 +67,7 @@ public: RWRecMutex::TryRLock lock(_mutex); // Expected } - catch(const LockedException&) + catch(const ThreadLockedException&) { test(false); } @@ -96,7 +96,7 @@ public: RWRecMutex::TryRLock lock(_mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -258,7 +258,7 @@ public: RWRecMutex::TryWLock lock(_mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -292,7 +292,7 @@ RWRecMutexTest::run() { RWRecMutex::TryRLock rlock2(mutex); } - catch(const LockedException&) + catch(const ThreadLockedException&) { test(false); } @@ -302,7 +302,7 @@ RWRecMutexTest::run() RWRecMutex::TryWLock wlock(mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -312,7 +312,7 @@ RWRecMutexTest::run() RWRecMutex::TryWLock wlock(mutex, Time::milliSeconds(10)); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -328,7 +328,7 @@ RWRecMutexTest::run() RWRecMutex::TryRLock rlock(mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -337,7 +337,7 @@ RWRecMutexTest::run() RWRecMutex::TryRLock rlock(mutex, Time::milliSeconds(10)); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -346,7 +346,7 @@ RWRecMutexTest::run() RWRecMutex::TryWLock wlock(mutex); // Expected } - catch(const LockedException&) + catch(const ThreadLockedException&) { test(false); } @@ -355,7 +355,7 @@ RWRecMutexTest::run() RWRecMutex::TryWLock wlock(mutex, Time::milliSeconds(10)); // Expected } - catch(const LockedException&) + catch(const ThreadLockedException&) { test(false); } @@ -418,7 +418,7 @@ RWRecMutexTest::run() RWRecMutex::TryRLock rlock2(mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -496,7 +496,7 @@ RWRecMutexTest::run() RWRecMutex::TryRLock rlock2(mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } @@ -509,7 +509,7 @@ RWRecMutexTest::run() RWRecMutex::TryWLock rlock2(mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } diff --git a/cpp/test/IceUtil/thread/RecMutexTest.cpp b/cpp/test/IceUtil/thread/RecMutexTest.cpp index 488eb9f2d87..3e3ec1a2ee2 100644 --- a/cpp/test/IceUtil/thread/RecMutexTest.cpp +++ b/cpp/test/IceUtil/thread/RecMutexTest.cpp @@ -35,7 +35,7 @@ public: RecMutex::TryLock lock(_mutex); test(false); } - catch(const LockedException&) + catch(const ThreadLockedException&) { // Expected } diff --git a/cpp/test/IceXML/encoding/Client.cpp b/cpp/test/IceXML/encoding/Client.cpp index e8bebff5b8d..4a1a29a5da9 100644 --- a/cpp/test/IceXML/encoding/Client.cpp +++ b/cpp/test/IceXML/encoding/Client.cpp @@ -16,29 +16,33 @@ using namespace std; -static string header = "<ice:data xmlns=\"http://www.noorg.org/schemas\"" - " xmlns:ice=\"http://www.mutablerealms.com/schemas\"" - " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" - " xsi:schemaLocation=\"http://www.noorg.org/schemas Test.xsd\">"; -static string footer = "</ice:data>"; +static string header = +"<ice:data xmlns=\"http://www.noorg.org/schemas\"" +" xmlns:ice=\"http://www.mutablerealms.com/schemas\"" +" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +" xsi:schemaLocation=\"http://www.noorg.org/schemas Test.xsd\">"; + +static string footer = +"</ice:data>"; + +static const string element = "s"; +static const string strings[] = +{ + "hello world", + "hello & world", + "\"hello world\"", + "'hello world'", + "hello <world", + "hello >world", + "hello >>world", + "hello <<>>world", + "hello &&''\"\"<<>>world", + "" +}; void TestString(const Ice::CommunicatorPtr& communicator) { - static const string element = "s"; - static const string strings[] = - { - "hello world", - "hello & world", - "\"hello world\"", - "'hello world'", - "hello <world", - "hello >world", - "hello >>world", - "hello <<>>world", - "hello &&''\"\"<<>>world", - "" - }; for(int i = 0; !strings[i].empty(); ++i) { ostringstream os; @@ -57,7 +61,8 @@ TestString(const Ice::CommunicatorPtr& communicator) void TestStruct1(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Struct1"; + const string element = "Test.Struct1"; + Test::Struct1 sin; sin.l = 10; @@ -77,7 +82,8 @@ TestStruct1(const Ice::CommunicatorPtr& communicator) void TestStruct2(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Struct2"; + const string element = "Test.Struct2"; + Test::Struct2 sin; sin.s1.l = 10; @@ -97,7 +103,8 @@ TestStruct2(const Ice::CommunicatorPtr& communicator) void TestStruct3(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Struct3"; + const string element = "Test.Struct3"; + Test::Struct3 sin; sin.l = 20; sin.s2.s1.l = 10; @@ -118,7 +125,8 @@ TestStruct3(const Ice::CommunicatorPtr& communicator) void TestStruct4(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Struct4"; + const string element = "Test.Struct4"; + Test::Struct4 sin; sin.l = 30; sin.s3.l = 20; @@ -140,7 +148,8 @@ TestStruct4(const Ice::CommunicatorPtr& communicator) void TestStruct4Seq(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Struct4Seq"; + const string element = "Test.Struct4Seq"; + Test::Struct4Seq seqin; Test::Struct4 sin; @@ -178,7 +187,8 @@ TestStruct4Seq(const Ice::CommunicatorPtr& communicator) void TestStringStruct4Dict(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.StringStruct4Dict"; + const string element = "Test.StringStruct4Dict"; + Test::StringStruct4Dict dictin; Test::Struct4 sin; @@ -214,7 +224,8 @@ TestStringStruct4Dict(const Ice::CommunicatorPtr& communicator) void TestColor(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Color"; + const string element = "Test.Color"; + Test::Color ein = Test::Red; ostringstream os; @@ -233,7 +244,8 @@ TestColor(const Ice::CommunicatorPtr& communicator) void TestColorSeq(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.ColorSeq"; + const string element = "Test.ColorSeq"; + Test::ColorSeq seqin; seqin.push_back(Test::Red); @@ -264,7 +276,8 @@ TestColorSeq(const Ice::CommunicatorPtr& communicator) void TestClass1(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Class1"; + const string element = "Test.Class1"; + Test::Class1Ptr in = new Test::Class1(); in->c = Test::Red; in->name = "Red"; @@ -285,7 +298,8 @@ TestClass1(const Ice::CommunicatorPtr& communicator) void TestClass2(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Class2"; + const string element = "Test.Class2"; + Test::Class2Ptr in = new Test::Class2(); in->c = Test::Blue; in->name = "Blue"; @@ -306,7 +320,8 @@ TestClass2(const Ice::CommunicatorPtr& communicator) void TestClass2Rec(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Class2"; + const string element = "Test.Class2"; + Test::Class2Ptr in = new Test::Class2(); in->c = Test::Blue; in->name = "Blue"; @@ -369,7 +384,8 @@ public: void TestClass3(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Class3"; + const string element = "Test.Class3"; + Test::Class3Ptr in = new Class3I(); in->c = Test::Blue; in->name = "Blue"; @@ -392,7 +408,8 @@ TestClass3(const Ice::CommunicatorPtr& communicator) void TestClass3Rec(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Class3"; + const string element = "Test.Class3"; + Test::Class3Ptr in = new Class3I(); in->c = Test::Blue; in->name = "Blue"; @@ -432,7 +449,8 @@ TestFacets(const Ice::CommunicatorPtr& communicator) communicator->addObjectFactory(Test::Class1::ice_factory(), Test::Class1::ice_staticId()); communicator->addObjectFactory(Test::Class2::ice_factory(), Test::Class2::ice_staticId()); - static const string element = "Test.Class2"; + const string element = "Test.Class2"; + Test::Class2Ptr in = new Test::Class2(); in->c = Test::Blue; in->name = "Blue"; @@ -481,7 +499,8 @@ TestFacets(const Ice::CommunicatorPtr& communicator) void TestException1(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Exception1"; + const string element = "Test.Exception1"; + Test::Exception1 in; ostringstream os; @@ -499,7 +518,8 @@ TestException1(const Ice::CommunicatorPtr& communicator) void TestException2(const Ice::CommunicatorPtr& communicator) { - static const string element = "Test.Exception2"; + const string element = "Test.Exception2"; + Test::Exception2 in; in.msg = "hello world"; |