mirror of https://github.com/status-im/evmc.git
Move C++ helpers into evmc/helpers.hpp
This commit is contained in:
parent
7cfc2bf39e
commit
3dfa18a393
2
Doxyfile
2
Doxyfile
|
@ -100,7 +100,7 @@ WARN_LOGFILE =
|
|||
# Configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = \
|
||||
include/evmc/evmc.h include/evmc/loader.h include/evmc/helpers.h include/evmc/utils.h include/evmc/instructions.h \
|
||||
include/evmc/evmc.h include/evmc/helpers.h include/evmc/helpers.hpp include/evmc/loader.h include/evmc/utils.h include/evmc/instructions.h \
|
||||
docs/
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS =
|
||||
|
|
|
@ -7,28 +7,11 @@
|
|||
|
||||
#include "example_host.h"
|
||||
|
||||
#include <evmc/helpers.hpp>
|
||||
#include <evmc/helpers.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
|
||||
/// The comparator for std::map<evmc_address, ...>.
|
||||
bool operator<(const evmc_address& a, const evmc_address& b)
|
||||
{
|
||||
return std::memcmp(a.bytes, b.bytes, sizeof(a)) < 0;
|
||||
}
|
||||
|
||||
/// The comparator for std::map<evmc_bytes32, ...>.
|
||||
bool operator<(const evmc_bytes32& a, const evmc_bytes32& b)
|
||||
{
|
||||
return std::memcmp(a.bytes, b.bytes, sizeof(a)) < 0;
|
||||
}
|
||||
|
||||
bool operator==(const evmc_bytes32& a, const evmc_bytes32& b)
|
||||
{
|
||||
return std::memcmp(a.bytes, b.bytes, sizeof(a)) == 0;
|
||||
}
|
||||
|
||||
struct account
|
||||
{
|
||||
evmc_uint256be balance = {};
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/* EVMC: Ethereum Client-VM Connector API.
|
||||
* Copyright 2018 The EVMC Authors.
|
||||
* Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* EVMC C++ helpers
|
||||
*
|
||||
* A collection of helpers (overloaded operators) for using EVMC effectively in C++.
|
||||
*
|
||||
* @defgroup cpphelpers EVMC C++ helpers
|
||||
* @{
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <evmc/evmc.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
/// The comparator for std::map<evmc_address, ...>.
|
||||
bool operator<(const evmc_address& a, const evmc_address& b)
|
||||
{
|
||||
return std::memcmp(a.bytes, b.bytes, sizeof(a)) < 0;
|
||||
}
|
||||
|
||||
/// The comparator for std::map<evmc_bytes32, ...>.
|
||||
bool operator<(const evmc_bytes32& a, const evmc_bytes32& b)
|
||||
{
|
||||
return std::memcmp(a.bytes, b.bytes, sizeof(a)) < 0;
|
||||
}
|
||||
|
||||
/// The comparator for equality.
|
||||
bool operator==(const evmc_address& a, const evmc_address& b)
|
||||
{
|
||||
return std::memcmp(a.bytes, b.bytes, sizeof(a)) == 0;
|
||||
}
|
||||
|
||||
/// The comparator for equality.
|
||||
bool operator==(const evmc_bytes32& a, const evmc_bytes32& b)
|
||||
{
|
||||
return std::memcmp(a.bytes, b.bytes, sizeof(a)) == 0;
|
||||
}
|
||||
|
||||
/** @} */
|
Loading…
Reference in New Issue