EVMC
evmc.hpp File Reference
#include <evmc/evmc.h>
#include <evmc/helpers.h>
#include <evmc/hex.hpp>
#include <functional>
#include <initializer_list>
#include <ostream>
#include <string_view>
#include <utility>

Go to the source code of this file.

Classes

struct  evmc::address
 The big-endian 160-bit hash suitable for keeping an Ethereum address. More...
 
struct  evmc::bytes32
 The fixed size array of 32 bytes for storing 256-bit EVM values. More...
 
class  evmc::Result
 The EVM code execution result. More...
 
class  evmc::HostInterface
 The EVMC Host interface. More...
 
class  evmc::HostContext
 Wrapper around EVMC host context / host interface. More...
 
class  evmc::Host
 Abstract class to be used by Host implementations. More...
 
class  evmc::VM
 The VM instance. More...
 

Namespaces

namespace  evmc
 EVMC C++ API - wrappers and bindings for C++.
 

Typedefs

using evmc::bytes_view = std::basic_string_view< uint8_t >
 String view of uint8_t chars.
 
using evmc::uint256be = bytes32
 The alias for evmc::bytes32 to represent a big-endian 256-bit integer.
 

Functions

constexpr uint64_t evmc::load64be (const uint8_t *data) noexcept
 Loads 64 bits / 8 bytes of data from the given data array in big-endian order.
 
constexpr uint64_t evmc::load64le (const uint8_t *data) noexcept
 Loads 64 bits / 8 bytes of data from the given data array in little-endian order.
 
constexpr uint32_t evmc::load32be (const uint8_t *data) noexcept
 Loads 32 bits / 4 bytes of data from the given data array in big-endian order.
 
constexpr uint32_t evmc::load32le (const uint8_t *data) noexcept
 Loads 32 bits / 4 bytes of data from the given data array in little-endian order.
 
constexpr uint64_t evmc::fnv::fnv1a_by64 (uint64_t h, uint64_t x) noexcept
 The hashing transformation for 64-bit inputs based on the FNV-1a formula.
 
constexpr bool evmc::operator== (const address &a, const address &b) noexcept
 The "equal to" comparison operator for the evmc::address type.
 
constexpr bool evmc::operator!= (const address &a, const address &b) noexcept
 The "not equal to" comparison operator for the evmc::address type.
 
constexpr bool evmc::operator< (const address &a, const address &b) noexcept
 The "less than" comparison operator for the evmc::address type.
 
constexpr bool evmc::operator> (const address &a, const address &b) noexcept
 The "greater than" comparison operator for the evmc::address type.
 
constexpr bool evmc::operator<= (const address &a, const address &b) noexcept
 The "less than or equal to" comparison operator for the evmc::address type.
 
constexpr bool evmc::operator>= (const address &a, const address &b) noexcept
 The "greater than or equal to" comparison operator for the evmc::address type.
 
constexpr bool evmc::operator== (const bytes32 &a, const bytes32 &b) noexcept
 The "equal to" comparison operator for the evmc::bytes32 type.
 
constexpr bool evmc::operator!= (const bytes32 &a, const bytes32 &b) noexcept
 The "not equal to" comparison operator for the evmc::bytes32 type.
 
constexpr bool evmc::operator< (const bytes32 &a, const bytes32 &b) noexcept
 The "less than" comparison operator for the evmc::bytes32 type.
 
constexpr bool evmc::operator> (const bytes32 &a, const bytes32 &b) noexcept
 The "greater than" comparison operator for the evmc::bytes32 type.
 
constexpr bool evmc::operator<= (const bytes32 &a, const bytes32 &b) noexcept
 The "less than or equal to" comparison operator for the evmc::bytes32 type.
 
constexpr bool evmc::operator>= (const bytes32 &a, const bytes32 &b) noexcept
 The "greater than or equal to" comparison operator for the evmc::bytes32 type.
 
constexpr bool evmc::is_zero (const address &a) noexcept
 Checks if the given address is the zero address.
 
constexpr bool evmc::is_zero (const bytes32 &a) noexcept
 Checks if the given bytes32 object has all zero bytes.
 
template<typename T >
constexpr T evmc::literals::parse (std::string_view s) noexcept
 Converts a raw literal into value of type T.
 
constexpr address evmc::literals::operator""_address (const char *s) noexcept
 Literal for evmc::address.
 
constexpr bytes32 evmc::literals::operator""_bytes32 (const char *s) noexcept
 Literal for evmc::bytes32.
 
const char * evmc::to_string (evmc_status_code status_code) noexcept
 Returns text representation of the evmc_status_code.
 
const char * evmc::to_string (evmc_revision rev) noexcept
 Returns the name of the evmc_revision.
 
std::ostream & operator<< (std::ostream &os, evmc_status_code status_code)
 "Stream out" operator implementation for evmc_status_code.
 
std::ostream & operator<< (std::ostream &os, evmc_revision rev)
 "Stream out" operator implementation for evmc_revision.
 

Variables

constexpr auto evmc::fnv::prime = 0x100000001b3
 The 64-bit FNV prime number.
 
constexpr auto evmc::fnv::offset_basis = 0xcbf29ce484222325
 The 64-bit FNV offset basis.
 
constexpr auto evmc::make_result = evmc_make_result
 Alias for evmc_make_result().
 

Detailed Description

EVMC C++ API - wrappers and bindings for C++.

Definition in file evmc.hpp.

Function Documentation

◆ fnv1a_by64()

constexpr uint64_t evmc::fnv::fnv1a_by64 ( uint64_t  h,
uint64_t  x 
)
inlineconstexprnoexcept

The hashing transformation for 64-bit inputs based on the FNV-1a formula.

Definition at line 166 of file evmc.hpp.

167{
168 return (h ^ x) * prime;
169}
constexpr auto prime
The 64-bit FNV prime number.
Definition: evmc.hpp:162

◆ operator""_address()

constexpr address evmc::literals::operator""_address ( const char *  s)
constexprnoexcept

Literal for evmc::address.

Definition at line 296 of file evmc.hpp.

297{
298 return parse<address>(s);
299}

◆ operator""_bytes32()

constexpr bytes32 evmc::literals::operator""_bytes32 ( const char *  s)
constexprnoexcept

Literal for evmc::bytes32.

Definition at line 302 of file evmc.hpp.

303{
304 return parse<bytes32>(s);
305}

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  os,
evmc_revision  rev 
)
inline

"Stream out" operator implementation for evmc_revision.

Note
This is defined in global namespace to match evmc_revision definition and allow convenient operator overloading usage.

Definition at line 923 of file evmc.hpp.

924{
925 return os << evmc::to_string(rev);
926}
const char * to_string(evmc_status_code status_code) noexcept
Returns text representation of the evmc_status_code.
Definition: evmc.hpp:312

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  os,
evmc_status_code  status_code 
)
inline

"Stream out" operator implementation for evmc_status_code.

Note
This is defined in global namespace to match evmc_status_code definition and allow convenient operator overloading usage.

Definition at line 914 of file evmc.hpp.

915{
916 return os << evmc::to_string(status_code);
917}

◆ parse()

template<typename T >
constexpr T evmc::literals::parse ( std::string_view  s)
constexprnoexcept

Converts a raw literal into value of type T.

This function is expected to be used on literals in constexpr context only. In case the input is invalid the std::terminate() is called. TODO(c++20): Use consteval.

Definition at line 290 of file evmc.hpp.

291{
292 return from_hex<T>(s).value();
293}

Variable Documentation

◆ offset_basis

constexpr auto evmc::fnv::offset_basis = 0xcbf29ce484222325
constexpr

The 64-bit FNV offset basis.

Definition at line 163 of file evmc.hpp.

◆ prime

constexpr auto evmc::fnv::prime = 0x100000001b3
constexpr

The 64-bit FNV prime number.

Definition at line 162 of file evmc.hpp.