-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Code cleaning] - Fix shadow warnings
- Loading branch information
Showing
26 changed files
with
662 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "currencycodeset.hpp" | ||
|
||
namespace cct::schema { | ||
|
||
struct ExchangeAssetConfig { | ||
using trivially_relocatable = is_trivially_relocatable<CurrencyCodeSet>::type; | ||
|
||
void mergeWith(const ExchangeAssetConfig &other) { | ||
allExclude.insert(other.allExclude.begin(), other.allExclude.end()); | ||
preferredPaymentCurrencies.insert(other.preferredPaymentCurrencies.begin(), other.preferredPaymentCurrencies.end()); | ||
withdrawExclude.insert(other.withdrawExclude.begin(), other.withdrawExclude.end()); | ||
} | ||
|
||
CurrencyCodeSet allExclude; | ||
CurrencyCodeSet preferredPaymentCurrencies; | ||
CurrencyCodeSet withdrawExclude; | ||
}; | ||
|
||
} // namespace cct::schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#pragma once | ||
|
||
#include <array> | ||
#include <map> | ||
|
||
#include "cct_const.hpp" | ||
#include "cct_string.hpp" | ||
#include "exchange-asset-config.hpp" | ||
#include "exchange-query-config.hpp" | ||
#include "exchange-tradefees-config.hpp" | ||
#include "exchange-withdraw-config.hpp" | ||
|
||
namespace cct { | ||
|
||
namespace schema { | ||
|
||
namespace details { | ||
|
||
template <class T> | ||
struct ExchangeConfigPart { | ||
T def; // default is a reserved keyword - we override the json field name below | ||
std::map<string, T, std::less<>> exchange; | ||
}; | ||
|
||
struct AllExchangeConfigsOptional { | ||
ExchangeConfigPart<ExchangeAssetConfig> asset; | ||
ExchangeConfigPart<ExchangeQueryConfigOptional> query; | ||
ExchangeConfigPart<ExchangeTradeFeesConfigOptional> tradeFees; | ||
ExchangeConfigPart<ExchangeWithdrawConfigOptional> withdraw; | ||
}; | ||
|
||
} // namespace details | ||
|
||
struct ExchangeConfig { | ||
ExchangeAssetConfig asset; | ||
ExchangeQueryConfig query; | ||
ExchangeTradeFeesConfig tradeFees; | ||
ExchangeWithdrawConfig withdraw; | ||
}; | ||
|
||
struct AllExchangeConfigs { | ||
void mergeWith(const details::AllExchangeConfigsOptional &other) { | ||
for (int exchangePos = 0; exchangePos < kNbSupportedExchanges; ++exchangePos) { | ||
auto &exchangeConfig = exchangeConfigs[exchangePos]; | ||
std::string_view exchangeName = kSupportedExchanges[exchangePos]; | ||
|
||
auto assetIt = other.asset.exchange.find(exchangeName); | ||
auto queryIt = other.query.exchange.find(exchangeName); | ||
auto tradeFeesIt = other.tradeFees.exchange.find(exchangeName); | ||
auto withdrawIt = other.withdraw.exchange.find(exchangeName); | ||
|
||
exchangeConfig.asset.mergeWith(other.asset.def); | ||
if (assetIt != other.asset.exchange.end()) { | ||
exchangeConfig.asset.mergeWith(assetIt->second); | ||
} | ||
|
||
exchangeConfig.query.mergeWith(other.query.def); | ||
if (queryIt != other.query.exchange.end()) { | ||
exchangeConfig.query.mergeWith(queryIt->second); | ||
} | ||
|
||
exchangeConfig.tradeFees.mergeWith(other.tradeFees.def); | ||
if (tradeFeesIt != other.tradeFees.exchange.end()) { | ||
exchangeConfig.tradeFees.mergeWith(tradeFeesIt->second); | ||
} | ||
|
||
exchangeConfig.withdraw.mergeWith(other.withdraw.def); | ||
if (withdrawIt != other.withdraw.exchange.end()) { | ||
exchangeConfig.withdraw.mergeWith(withdrawIt->second); | ||
} | ||
} | ||
} | ||
|
||
const ExchangeConfig &operator[](ExchangeNameEnum exchangeName) const { | ||
return exchangeConfigs[static_cast<int>(exchangeName)]; | ||
} | ||
|
||
std::array<ExchangeConfig, kNbSupportedExchanges> exchangeConfigs; | ||
}; | ||
|
||
} // namespace schema | ||
|
||
class LoadConfiguration; | ||
|
||
schema::AllExchangeConfigs ReadExchangeConfigs(const LoadConfiguration &loadConfiguration); | ||
|
||
} // namespace cct | ||
|
||
template <class T> | ||
struct glz::meta<::cct::schema::details::ExchangeConfigPart<T>> { | ||
using V = ::cct::schema::details::ExchangeConfigPart<T>; | ||
static constexpr auto value = object("default", &V::def, "exchange", &V::exchange); | ||
}; |
Oops, something went wrong.