본문으로 건너뛰기

libraries/eosiolib/core/eosio/check.hpp

More...

Namespaces

Name
eosio
eosio::internal_use_do_not_use

Detailed Description

Copyright: defined in eos/LICENSE

Source code


#pragma once

#include <string>
#include <string_view>

namespace eosio {

namespace internal_use_do_not_use {
extern "C" {
__attribute__((eosio_wasm_import))
void eosio_assert( uint32_t test, const char* msg );

__attribute__((eosio_wasm_import))
void eosio_assert_message( uint32_t test, const char* msg, uint32_t msg_len );

__attribute__((eosio_wasm_import))
void eosio_assert_code( uint32_t test, uint64_t code );
}
}

inline void check(bool pred, std::string_view msg) {
if (!pred)
internal_use_do_not_use::eosio_assert_message(false, msg.data(), msg.size());
}

inline void check(bool pred, const char* msg) {
if (!pred) {
internal_use_do_not_use::eosio_assert(false, msg);
}
}

inline void check(bool pred, const std::string& msg) {
if (!pred) {
internal_use_do_not_use::eosio_assert_message(false, msg.data(), msg.size());
}
}

inline void check(bool pred, std::string&& msg) {
if (!pred) {
internal_use_do_not_use::eosio_assert_message(false, msg.data(), msg.size());
}
}


inline void check(bool pred, const char* msg, size_t n) {
if (!pred) {
internal_use_do_not_use::eosio_assert_message(false, msg, n);
}
}

inline void check(bool pred, const std::string& msg, size_t n) {
if (!pred) {
internal_use_do_not_use::eosio_assert_message(false, msg.data(), n);
}
}

inline void check(bool pred, uint64_t code) {
if (!pred) {
internal_use_do_not_use::eosio_assert_code(false, code);
}
}
} // namespace eosio

Updated on 2022-12-05 at 15:38:08 +0000