From 9d314f181af7c43ad8cd7223c08486e316bef5e2 Mon Sep 17 00:00:00 2001 From: svost Date: Mon, 3 Jan 2022 11:19:13 +0300 Subject: [PATCH] Wip: remove boost from code --- src/script.cpp | 2 +- src/serialize.h | 107 +++++++++++++++++++++++++++--------------------------- src/walletdb.cpp | 4 +- 3 files changed, 56 insertions(+), 57 deletions(-) diff --git a/src/script.cpp b/src/script.cpp index 02bb502..6125388 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1228,7 +1228,7 @@ class CSignatureCache { private: // sigdata_type is (signature hash, signature, public key): - typedef boost::tuple, CPubKey > sigdata_type; + typedef std::tuple, CPubKey > sigdata_type; std::set< sigdata_type> setValid; boost::shared_mutex cs_sigcache; diff --git a/src/serialize.h b/src/serialize.h index bdcd830..bc8ce01 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -9,17 +9,16 @@ #include #include #include +#include +#include #include #include #include #include -#ifndef Q_MOC_RUN -#include -#include -#include -#include -#endif +//#ifndef Q_MOC_RUN +//#include +//#endif #if defined __USE_MINGW_ANSI_STDIO #undef __USE_MINGW_ANSI_STDIO // This constant forces MinGW to conduct stupid behavior @@ -382,14 +381,14 @@ template void Serialize(Stream& os, const std::basi template void Unserialize(Stream& is, std::basic_string& str, int, int=0); // vector -template unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::true_type&); -template unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::false_type&); +template unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const std::true_type&); +template unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const std::false_type&); template inline unsigned int GetSerializeSize(const std::vector& v, int nType, int nVersion); -template void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::true_type&); -template void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::false_type&); +template void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const std::true_type&); +template void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const std::false_type&); template inline void Serialize(Stream& os, const std::vector& v, int nType, int nVersion); -template void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::true_type&); -template void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::false_type&); +template void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const std::true_type&); +template void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const std::false_type&); template inline void Unserialize(Stream& is, std::vector& v, int nType, int nVersion); // others derived from vector @@ -403,14 +402,14 @@ template void Serialize(Stream& os, con template void Unserialize(Stream& is, std::pair& item, int nType, int nVersion); // 3 tuple -template unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion); -template void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion); -template void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion); +template unsigned int GetSerializeSize(const std::tuple& item, int nType, int nVersion); +template void Serialize(Stream& os, const std::tuple& item, int nType, int nVersion); +template void Unserialize(Stream& is, std::tuple& item, int nType, int nVersion); // 4 tuple -template unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion); -template void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion); -template void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion); +template unsigned int GetSerializeSize(const std::tuple& item, int nType, int nVersion); +template void Serialize(Stream& os, const std::tuple& item, int nType, int nVersion); +template void Unserialize(Stream& is, std::tuple& item, int nType, int nVersion); // map template unsigned int GetSerializeSize(const std::map& m, int nType, int nVersion); @@ -486,13 +485,13 @@ void Unserialize(Stream& is, std::basic_string& str, int, int) // vector // template -unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::true_type&) +unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const std::true_type&) { return (unsigned int)(GetSizeOfCompactSize(v.size()) + v.size() * sizeof(T)); } template -unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const boost::false_type&) +unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nVersion, const std::false_type&) { unsigned int nSize = GetSizeOfCompactSize(v.size()); for (typename std::vector::const_iterator vi = v.begin(); vi != v.end(); ++vi) @@ -503,12 +502,12 @@ unsigned int GetSerializeSize_impl(const std::vector& v, int nType, int nV template inline unsigned int GetSerializeSize(const std::vector& v, int nType, int nVersion) { - return GetSerializeSize_impl(v, nType, nVersion, boost::is_fundamental()); + return GetSerializeSize_impl(v, nType, nVersion, std::is_fundamental()); } template -void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::true_type&) +void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const std::true_type&) { WriteCompactSize(os, v.size()); if (!v.empty()) @@ -516,7 +515,7 @@ void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVers } template -void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const boost::false_type&) +void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const std::false_type&) { WriteCompactSize(os, v.size()); for (typename std::vector::const_iterator vi = v.begin(); vi != v.end(); ++vi) @@ -526,12 +525,12 @@ void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVers template inline void Serialize(Stream& os, const std::vector& v, int nType, int nVersion) { - Serialize_impl(os, v, nType, nVersion, boost::is_fundamental()); + Serialize_impl(os, v, nType, nVersion, std::is_fundamental()); } template -void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::true_type&) +void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const std::true_type&) { // Limit size per read so bogus size value won't cause out of memory v.clear(); @@ -547,7 +546,7 @@ void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, } template -void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const boost::false_type&) +void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, const std::false_type&) { v.clear(); unsigned int nSize = (unsigned int)(ReadCompactSize(is)); @@ -567,7 +566,7 @@ void Unserialize_impl(Stream& is, std::vector& v, int nType, int nVersion, template inline void Unserialize(Stream& is, std::vector& v, int nType, int nVersion) { - Unserialize_impl(is, v, nType, nVersion, boost::is_fundamental()); + Unserialize_impl(is, v, nType, nVersion, std::is_fundamental()); } @@ -623,29 +622,29 @@ void Unserialize(Stream& is, std::pair& item, int nType, int nVersion) // 3 tuple // template -unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion) +unsigned int GetSerializeSize(const std::tuple& item, int nType, int nVersion) { unsigned int nSize = 0; - nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion); - nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion); - nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion); + nSize += GetSerializeSize(std::get<0>(item), nType, nVersion); + nSize += GetSerializeSize(std::get<1>(item), nType, nVersion); + nSize += GetSerializeSize(std::get<2>(item), nType, nVersion); return nSize; } template -void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion) +void Serialize(Stream& os, const std::tuple& item, int nType, int nVersion) { - Serialize(os, boost::get<0>(item), nType, nVersion); - Serialize(os, boost::get<1>(item), nType, nVersion); - Serialize(os, boost::get<2>(item), nType, nVersion); + Serialize(os, std::get<0>(item), nType, nVersion); + Serialize(os, std::get<1>(item), nType, nVersion); + Serialize(os, std::get<2>(item), nType, nVersion); } template -void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion) +void Unserialize(Stream& is, std::tuple& item, int nType, int nVersion) { - Unserialize(is, boost::get<0>(item), nType, nVersion); - Unserialize(is, boost::get<1>(item), nType, nVersion); - Unserialize(is, boost::get<2>(item), nType, nVersion); + Unserialize(is, std::get<0>(item), nType, nVersion); + Unserialize(is, std::get<1>(item), nType, nVersion); + Unserialize(is, std::get<2>(item), nType, nVersion); } @@ -654,32 +653,32 @@ void Unserialize(Stream& is, boost::tuple& item, int nType, int nVer // 4 tuple // template -unsigned int GetSerializeSize(const boost::tuple& item, int nType, int nVersion) +unsigned int GetSerializeSize(const std::tuple& item, int nType, int nVersion) { unsigned int nSize = 0; - nSize += GetSerializeSize(boost::get<0>(item), nType, nVersion); - nSize += GetSerializeSize(boost::get<1>(item), nType, nVersion); - nSize += GetSerializeSize(boost::get<2>(item), nType, nVersion); - nSize += GetSerializeSize(boost::get<3>(item), nType, nVersion); + nSize += GetSerializeSize(std::get<0>(item), nType, nVersion); + nSize += GetSerializeSize(std::get<1>(item), nType, nVersion); + nSize += GetSerializeSize(std::get<2>(item), nType, nVersion); + nSize += GetSerializeSize(std::get<3>(item), nType, nVersion); return nSize; } template -void Serialize(Stream& os, const boost::tuple& item, int nType, int nVersion) +void Serialize(Stream& os, const std::tuple& item, int nType, int nVersion) { - Serialize(os, boost::get<0>(item), nType, nVersion); - Serialize(os, boost::get<1>(item), nType, nVersion); - Serialize(os, boost::get<2>(item), nType, nVersion); - Serialize(os, boost::get<3>(item), nType, nVersion); + Serialize(os, std::get<0>(item), nType, nVersion); + Serialize(os, std::get<1>(item), nType, nVersion); + Serialize(os, std::get<2>(item), nType, nVersion); + Serialize(os, std::get<3>(item), nType, nVersion); } template -void Unserialize(Stream& is, boost::tuple& item, int nType, int nVersion) +void Unserialize(Stream& is, std::tuple& item, int nType, int nVersion) { - Unserialize(is, boost::get<0>(item), nType, nVersion); - Unserialize(is, boost::get<1>(item), nType, nVersion); - Unserialize(is, boost::get<2>(item), nType, nVersion); - Unserialize(is, boost::get<3>(item), nType, nVersion); + Unserialize(is, std::get<0>(item), nType, nVersion); + Unserialize(is, std::get<1>(item), nType, nVersion); + Unserialize(is, std::get<2>(item), nType, nVersion); + Unserialize(is, std::get<3>(item), nType, nVersion); } diff --git a/src/walletdb.cpp b/src/walletdb.cpp index e5204b6..65cb655 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -57,7 +57,7 @@ bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account) bool CWalletDB::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry) { - return Write(boost::make_tuple(string("acentry"), acentry.strAccount, nAccEntryNum), acentry); + return Write(std::make_tuple(string("acentry"), acentry.strAccount, nAccEntryNum), acentry); } bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry) @@ -90,7 +90,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list