跳到主要内容

eosio::symbol_code

Module: Core API / Symbol

More...

#include <symbol.hpp>

Public Functions

Name
constexprsymbol_code()
Construct a new symbol_code object defaulting to a value of 0.
constexprsymbol_code(uint64_t raw)
Construct a new symbol_code object initialising value with raw.
constexprsymbol_code(std::string_view str)
Construct a new symbol_code object initialising value with str.
constexpr boolis_valid() const
constexpr uint32_tlength() const
constexpr uint64_traw() const
constexproperator bool() const
char *write_as_string(char begin, char end, bool dry_run =false) const
Writes the symbol_code as a string to the provided char buffer.
std::stringto_string() const
voidprint() const

Friends

Name
constexpr friend booloperator==(const symbol_code & a, const symbol_code & b)
constexpr friend booloperator!=(const symbol_code & a, const symbol_code & b)
constexpr friend booloperator<(const symbol_code & a, const symbol_code & b)
Less than operator.

Detailed Description

class eosio::symbol_code;

Stores the symbol code as a uint64_t value

Public Functions Documentation

function symbol_code

inline constexpr symbol_code()

Construct a new symbol_code object defaulting to a value of 0.

Default constructor, construct a new symbol_code

function symbol_code

inline explicit constexpr symbol_code(
uint64_t raw
)

Construct a new symbol_code object initialising value with raw.

Parameters:

  • raw - The raw value which is a scoped enumerated type of unit64_t

Construct a new symbol_code given a scoped enumerated type of raw (uint64_t).

function symbol_code

inline explicit constexpr symbol_code(
std::string_view str
)

Construct a new symbol_code object initialising value with str.

Parameters:

  • str - The string value which validated then converted to unit64_t

Construct a new symbol_code given an string.

function is_valid

inline constexpr bool is_valid() const

Return: true - if symbol is valid

Checks if the symbol code is valid

function length

inline constexpr uint32_t length() const

Return: length - character length of the provided symbol

Returns the character length of the provided symbol

function raw

inline constexpr uint64_t raw() const

Return: Returns an instance of raw based on the value of a symbol_code

Casts a symbol code to raw

function operator bool

inline explicit constexpr operator bool() const

Return: Returns true if the symbol_code is set to the default value of 0 else true.

Explicit cast to bool of the symbol_code

function write_as_string

inline char * write_as_string(
char * begin,
char * end,
bool dry_run =false
) const

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

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.

Return: 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.)

Precondition:

  • is_valid() == true
  • The range [begin, end) must be a valid range of memory to write to.

Postcondition: 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 symbol_code. Nothing is written if dry_run == true or returned pointer > end (insufficient space) or if returned pointer < begin (overflow in calculating desired end).

Writes the symbol_code as a string to the provided char buffer

function to_string

inline std::string to_string() const

Returns the name value as a string by calling write_as_string() and returning the buffer produced by write_as_string()

function print

inline void print() const

Parameters:

  • sym_code symbol code to be printed

Prints a symbol_code

Friends

friend operator==

friend constexpr friend bool operator==(
const symbol_code & a,

const symbol_code & b
);

Return: boolean - true if both provided symbol_codes are the same

Equivalency operator. Returns true if a == b (are the same)

friend operator!=

friend constexpr friend bool operator!=(
const symbol_code & a,

const symbol_code & b
);

Return: boolean - true if both provided symbol_codes are not the same

Inverted equivalency operator. Returns true if a != b (are different)

friend operator<

friend constexpr friend bool operator<(
const symbol_code & a,

const symbol_code & b
);

Less than operator.

Return: boolean - true if symbol_codea is less than b

Less than operator. Returns true if a < b.


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