Menu

Defines C++ wrapper to log/print text messages. More...

Classes

Type Name
class eosio::iostream

Variables

Type Name
static iostream cout

Functions

Detailed Description

This API uses C++ variadic templates and type detection to make it easy to print any native type. You can even overload the method for your own custom types. Example:

print( "hello world, this is a number: ", 5 );

Variables Documentation

variable cout

iostream eosio::cout;

Functions Documentation

function print_f

template<typename Arg, typename... Args>
void eosio::print_f(
    const char * s,
    Arg val,
    Args... rest
)

Prints formatted string.

Prints formatted string. It behaves similar to C printf/

Template parameters:

  • Arg - Type of the value used to replace the format specifier
  • Args - Type of the value used to replace the format specifier

Parameters:

  • s - Null terminated string with to be printed (it can contains format specifier)
  • val - The value used to replace the format specifier
  • rest - The values used to replace the format specifier

Example:

print_f("Number of apples: %", 10);

function print

template<typename Arg, typename... Args>
void eosio::print(
    Arg && a,
    Args &&... args
)

Print out value / list of values.

Print out value / list of values

Parameters:

  • a - The value to be printed
  • args - The other values to be printed

Example:

const char *s = "Hello World!";
uint64_t unsigned_64_bit_int = 1e+18;
uint128_t unsigned_128_bit_int (87654323456);
uint64_t string_as_unsigned_64_bit = "abcde"_n;
print(s , unsigned_64_bit_int, unsigned_128_bit_int, string_as_unsigned_64_bit);
// Ouput: Hello World!100000000000000000087654323456abcde

function operator<<

template<typename T>
iostream& eosio::operator<<(
    iostream & out,
    const T & v
)

Overload c++ iostream.

Overload c++ iostream

Parameters:

  • out - Output strem
  • v - The value to be printed

Returns:

iostream& - Reference to the input output stream

Example:

const char *s = "Hello World!";
uint64_t unsigned_64_bit_int = 1e+18;
uint128_t unsigned_128_bit_int (87654323456);
uint64_t string_as_unsigned_64_bit = "abcde"_n;
std::out << s << " " << unsigned_64_bit_int << " "  << unsigned_128_bit_int << " " << string_as_unsigned_64_bit;
// Output: Hello World! 1000000000000000000 87654323456 abcde