diff --git a/include/opentxs/core/crypto/OTASCIIArmor.hpp b/include/opentxs/core/crypto/OTASCIIArmor.hpp index 9274d6605e..2bd40368b1 100644 --- a/include/opentxs/core/crypto/OTASCIIArmor.hpp +++ b/include/opentxs/core/crypto/OTASCIIArmor.hpp @@ -267,18 +267,6 @@ class OTASCIIArmor : public OTString EXPORT bool SetAndPackString(const OTString& theData, bool bLineBreaks = true); - EXPORT bool GetStringMap(std::map& the_map, - bool bLineBreaks = true) const; - EXPORT bool GetAndUnpackStringMap( - std::map& the_map, - bool bLineBreaks = true) const; - - EXPORT bool SetStringMap(const std::map& the_map, - bool bLineBreaks = true); - EXPORT bool SetAndPackStringMap( - const std::map& the_map, - bool bLineBreaks = true); - private: static std::unique_ptr s_pPacker; }; diff --git a/src/core/crypto/OTASCIIArmor.cpp b/src/core/crypto/OTASCIIArmor.cpp index eb35e5704f..221e5513e6 100644 --- a/src/core/crypto/OTASCIIArmor.cpp +++ b/src/core/crypto/OTASCIIArmor.cpp @@ -480,137 +480,6 @@ bool OTASCIIArmor::GetString(OTString& strData, return GetAndUnpackString(strData, bLineBreaks); } -bool OTASCIIArmor::GetStringMap(std::map& the_map, - bool bLineBreaks) const -{ - return GetAndUnpackStringMap(the_map, bLineBreaks); -} - -bool OTASCIIArmor::GetAndUnpackStringMap( - std::map& the_map, bool bLineBreaks) const -{ - size_t outSize = 0; - uint8_t* pData = nullptr; - - the_map.clear(); - - if (GetLength() < 1) return true; - - pData = OTCrypto::It()->Base64Decode(Get(), &outSize, bLineBreaks); - - if (pData) { - - OTDB::OTPacker* pPacker = - OTASCIIArmor::GetPacker(); // No need to check for failure, since - // this already ASSERTS. No need to - // cleanup either. - - std::unique_ptr pBuffer( - pPacker->CreateBuffer()); // Need to clean this up. - OT_ASSERT(nullptr != pBuffer); - - pBuffer->SetData(static_cast(pData), outSize); - delete[] pData; - pData = nullptr; - - std::unique_ptr pStringMap( - dynamic_cast( - OTDB::CreateObject(OTDB::STORED_OBJ_STRING_MAP))); - OT_ASSERT(nullptr != pStringMap); - - bool bUnpacked = pPacker->Unpack(*pBuffer, *pStringMap); - - if (!bUnpacked) { - otErr << "Failed unpacking data in " - "OTASCIIArmor::GetAndUnpackStringMap.\n"; - delete[] pData; - pData = nullptr; - return false; - } - - the_map = pStringMap->the_map; - - delete[] pData; - pData = nullptr; - return true; - } - else { - otErr << "Error while base64_decoding in " - "OTASCIIArmor::GetAndUnpackStringMap.\n"; - return false; - } -} - -bool OTASCIIArmor::SetStringMap( - const std::map& the_map, bool bLineBreaks) -{ - return SetAndPackStringMap(the_map, bLineBreaks); -} - -bool OTASCIIArmor::SetAndPackStringMap( - const std::map& the_map, bool bLineBreaks) -{ - char* pString = nullptr; - - Release(); - - if (the_map.empty()) return true; - - OTDB::OTPacker* pPacker = - OTASCIIArmor::GetPacker(); // No need to check for failure, since this - // already ASSERTS. No need to cleanup - // either. - - // Here I use the default storage context to create the object (the string - // map.) - // I also originally created OTASCIIArmor::GetPacker() using - // OTDB_DEFAULT_PACKER, - // so I know everything is compatible. - // - std::unique_ptr pStringMap(dynamic_cast( - OTDB::CreateObject(OTDB::STORED_OBJ_STRING_MAP))); - - OT_ASSERT(nullptr != - pStringMap); // Beyond this point, responsible to delete - // pStringMap. - - pStringMap->the_map = the_map; - - std::unique_ptr pBuffer(pPacker->Pack( - *pStringMap)); // Now we PACK our data before compressing/encoding it. - - if (nullptr == pBuffer) { - otErr << "Failed packing data in OTASCIIArmor::SetAndPackStringMap. \n"; - return false; - } - - const uint8_t* pUint = static_cast(pBuffer->GetData()); - const size_t theSize = pBuffer->GetSize(); - - if (nullptr != pUint) - pString = OTCrypto::It()->Base64Encode( - pUint, static_cast(theSize), bLineBreaks); - // pString = OT_base64_encode(pUint, static_cast (theSize), - // (bLineBreaks ? 1 : 0)); - else { - otErr << "Error while base64_encoding in " - "OTASCIIArmor::SetAndPackStringMap.\n"; - return false; - } - - if (nullptr != pString) { - Set(pString); - delete[] pString; - pString = nullptr; - return true; - } - else { - otErr << "Error while base64_encoding in " - "OTASCIIArmor::SetAndPackStringMap.\n"; - return false; - } -} - // This function will base64 DECODE the string contents // and return them as binary in theData bool OTASCIIArmor::GetData(OTData& theData,