From 149b204fd54e2ad6041d53fb0e1ef1eeb009eb4e Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Fri, 27 Oct 2023 15:23:42 +0300 Subject: [PATCH] Workaround c++20 has stringstream move override IB-7851 Signed-off-by: Raul Metsma --- src/SiVaContainer.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/SiVaContainer.cpp b/src/SiVaContainer.cpp index 49420c3ff..1a3da1cfb 100644 --- a/src/SiVaContainer.cpp +++ b/src/SiVaContainer.cpp @@ -53,7 +53,7 @@ using namespace std; using namespace xercesc; using json = nlohmann::json; -static string base64_decode(const XMLCh *in) { +static auto base64_decode(const XMLCh *in) { static constexpr array T{ 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, @@ -65,7 +65,7 @@ static string base64_decode(const XMLCh *in) { 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x64, 0x64, 0x64, 0x64, 0x64 }; - string out; + auto out = make_unique(); int value = 0; int bits = -8; for(; in; ++in) @@ -77,9 +77,9 @@ static string base64_decode(const XMLCh *in) { if(check == 0x64) break; value = (value << 6) + check; - if((bits += 6) < 0) + if(bits += 6; bits < 0) continue; - out.push_back(char((value >> bits) & 0xFF)); + out->put(char((value >> bits) & 0xFF)); bits -= 8; } return out; @@ -162,7 +162,7 @@ SiVaContainer::SiVaContainer(const string &path, const string &ext, bool useHash d->dataFiles.push_back(new DataFilePrivate(std::move(ifs), fileName, "application/pdf")); } - array buf{}; + array buf{}; string b64; is->clear(); is->seekg(0); @@ -337,7 +337,7 @@ unique_ptr SiVaContainer::parseDDoc(bool useHashCode) DOMNodeList *nodeList = dom->getElementsByTagName(cpXMLCh(u"DataFile")); for(XMLSize_t i = 0; i < nodeList->getLength(); ++i) { - DOMElement *item = static_cast(nodeList->item(i)); + auto *item = static_cast(nodeList->item(i)); if(!item) continue; @@ -348,7 +348,7 @@ unique_ptr SiVaContainer::parseDDoc(bool useHashCode) if(const XMLCh *b64 = item->getTextContent()) { - d->dataFiles.push_back(new DataFilePrivate(make_unique(base64_decode(b64)), + d->dataFiles.push_back(new DataFilePrivate(base64_decode(b64), xml::transcode(item->getAttribute(cpXMLCh(u"Filename"))), xml::transcode(item->getAttribute(cpXMLCh(u"MimeType"))), xml::transcode(item->getAttribute(cpXMLCh(u"Id"))))); @@ -359,8 +359,7 @@ unique_ptr SiVaContainer::parseDDoc(bool useHashCode) Digest calc(URI_SHA1); SecureDOMParser::calcDigestOnNode(&calc, "http://www.w3.org/TR/2001/REC-xml-c14n-20010315", item); vector digest = calc.result(); - XMLSize_t size = 0; - if(XMLByte *out = Base64::encode(digest.data(), XMLSize_t(digest.size()), &size)) + if(XMLSize_t size = 0; XMLByte *out = Base64::encode(digest.data(), XMLSize_t(digest.size()), &size)) { item->setAttribute(cpXMLCh(u"ContentType"), cpXMLCh(u"HASHCODE")); item->setAttribute(cpXMLCh(u"DigestType"), cpXMLCh(u"sha1"));