struct eosio::asset

Class List > eosio :: asset

Public Attributes

Type Name
int64_t amount
symbol symbol

Public Static Attributes

Type Name
static constexpr int64_t max_amount

Public Functions

Type Name
asset ()
asset (int64_t a, class symbol s)
bool is_amount_within_range () const
bool is_valid () const
void set_amount (int64_t a)
char * write_as_string (char * begin, char * end, bool dry_run = false) const
Writes the asset as a string to the provided char buffer.
std::string to_string () const
asset to std::string
void print () const
Print the asset

Detailed Description

Stores information for owner of asset

Public Attributes Documentation

variable amount

int64_t eosio::asset::amount;

The amount of the asset

variable symbol

symbol eosio::asset::symbol;

The symbol name of the asset

Public Static Attributes Documentation

variable max_amount

constexpr int64_t eosio::asset::max_amount;

Maximum amount possible for this asset. It's capped to 2^62 - 1

Public Functions Documentation

function asset (1/2)

eosio::asset::asset()

function asset (2/2)

eosio::asset::asset(
    int64_t a,
    class symbol s
)

Construct a new asset given the symbol name and the amount

Parameters:

  • a - The amount of the asset
  • s - The name of the symbol

function is_amount_within_range

bool eosio::asset::is_amount_within_range() const

Check if the amount doesn't exceed the max amount

Returns:

true - if the amount doesn't exceed the max amount

Returns:

false - otherwise

function is_valid

bool eosio::asset::is_valid() const

Check if the asset is valid. A valid asset has its amount <= max_amount and its symbol name valid

Returns:

true - if the asset is valid

Returns:

false - otherwise

function set_amount

void eosio::asset::set_amount(
    int64_t a
)

Set the amount of the asset

Parameters:

  • a - New amount for the asset

function write_as_string

char* eosio::asset::write_as_string(
    char * begin,
    char * end,
    bool dry_run = false
) const

Writes the asset as a string to the provided char buffer.

Writes the asset as a string to the provided char buffer

Precondition:

is_valid() == true

Precondition:

The range [begin, end) must be a valid range of memory to write to.

Parameters:

  • begin - The start of the char buffer
  • end - Just past the end of the char buffer
  • dry_run - If true, do not actually write anything into the range.

Returns:

char* - Just past the end of the last character that would be written assuming dry_run == false and end was large enough to provide sufficient space. (Meaning only applies if returned pointer >= begin.)

Post

If the output string fits within the range [begin, end) and dry_run == false, the range [begin, returned pointer) contains the string representation of the asset. Nothing is written if dry_run == true or returned pointer > end (insufficient space) or if returned pointer < begin (overflow in calculating desired end).

function to_string

std::string eosio::asset::to_string() const

asset to std::string

asset to std::string

function print

void eosio::asset::print() const

Print the asset

Print the asset


The documentation for this class was generated from the following file: libraries/eosiolib/core/eosio/asset.hpp