cpp project compiling with boost::optional

This commit is contained in:
woodser
2019-06-06 12:50:44 -04:00
parent 3ac7a7af50
commit 5471072d2e
2 changed files with 11 additions and 4 deletions
+4 -4
View File
@@ -14,7 +14,7 @@ namespace monero {
// ---------------------------- PRIVATE HELPERS -----------------------------
bool boolEquals(bool val, boost::optional<bool> optVal) {
bool boolEquals(bool val, const boost::optional<bool>& optVal) {
return optVal == boost::none ? false : val == *optVal;
}
@@ -494,9 +494,9 @@ namespace monero {
// translate from MoneroTxRequest to in, out, pending, pool, failed terminology
bool canBeConfirmed = !boolEquals(false, txReq.isConfirmed) && !boolEquals(true, txReq.inTxPool) && !boolEquals(true, txReq.isFailed) && !boolEquals(false, txReq.isRelayed);
bool canBeInTxPool = !boolEquals(true, txReq.isConfirmed) && !boolEquals(false, txReq.inTxPool) && !boolEquals(true, txReq.isFailed) && !boolEquals(false, txReq.isRelayed) && txReq.height == boost::none && txReq.minHeight == boost::none;
bool canBeIncoming = !boolEquals(false, request.isIncoming) && !boolEquals(true, request.isOutgoing) && !boolEquals(true, request.hasDestinations);
bool canBeOutgoing = !boolEquals(false, request.isOutgoing) && !boolEquals(true, request.isIncoming);
bool canBeInTxPool = !boolEquals(true, txReq.isConfirmed) && !boolEquals(false, txReq.inTxPool) && !boolEquals(true, txReq.isFailed) && !boolEquals(false, txReq.isRelayed) && txReq.getHeight() == boost::none && txReq.minHeight == boost::none;
bool canBeIncoming = !boolEquals(false, request.isIncoming) && !boolEquals(true, request.getIsOutgoing()) && !boolEquals(true, request.hasDestinations);
bool canBeOutgoing = !boolEquals(false, request.getIsOutgoing()) && !boolEquals(true, request.isIncoming);
bool isIn = canBeIncoming && canBeConfirmed;
bool isOut = canBeOutgoing && canBeConfirmed;
bool isPending = canBeOutgoing && canBeInTxPool;
+7
View File
@@ -146,6 +146,11 @@ namespace monero {
vector<MoneroDestination> destinations;
boost::optional<bool> hasDestinations;
boost::optional<shared_ptr<MoneroTxRequest>> txRequest;
boost::optional<bool> getIsOutgoing() const {
if (isIncoming == boost::none ) return boost::none;
return !(*isIncoming);
}
};
/**
@@ -163,6 +168,8 @@ namespace monero {
boost::optional<uint64_t> maxHeight;
boost::optional<uint64_t> includeOutputs;
boost::optional<MoneroTransferRequest> transferRequest;
boost::optional<uint64_t> getHeight() { return block == boost::none ? boost::none : (*block)->height; }
};
/**