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::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 163 of file evmc.hpp.

164{
165 return (h ^ x) * prime;
166}
constexpr auto prime
The 64-bit FNV prime number.
Definition: evmc.hpp:159

◆ operator""_address()

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

Literal for evmc::address.

Definition at line 293 of file evmc.hpp.

294{
295 return parse<address>(s);
296}

◆ operator""_bytes32()

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

Literal for evmc::bytes32.

Definition at line 299 of file evmc.hpp.

300{
301 return parse<bytes32>(s);
302}

◆ 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 920 of file evmc.hpp.

921{
922 return os << evmc::to_string(rev);
923}
const char * to_string(evmc_status_code status_code) noexcept
Returns text representation of the evmc_status_code.
Definition: evmc.hpp:309

◆ 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 911 of file evmc.hpp.

912{
913 return os << evmc::to_string(status_code);
914}

◆ 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 287 of file evmc.hpp.

288{
289 return from_hex<T>(s).value();
290}

Variable Documentation

◆ offset_basis

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

The 64-bit FNV offset basis.

Definition at line 160 of file evmc.hpp.

◆ prime

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

The 64-bit FNV prime number.

Definition at line 159 of file evmc.hpp.