跳到主要内容

Console

Module: Core API

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

Classes

Name
classeosio::iostream

Functions

Name
voidprinthex(const void * ptr, uint32_t size)
voidprintl(const char * ptr, size_t len)
voidprint(const char * ptr)
voidprint(float num)
voidprint(double num)
voidprint(long double num)
template <typename T ,std::enable_if_t<!std::is_integral< std::decay_t< T >>::value, int > =0>
void
print(T && t)
voidprint_f(const char * s)

Detailed Description

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

This API uses C++ variadic templates and type detection to make it easy to print any native type. You can even overload the [print()](/cdt/latest/reference/Modules/group__console#function-print) method for your own custom types.

Example:

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

Overriding Print for your Types

There are two ways to overload print:

  1. implement void print( const T& )
  2. implement T::print()const

Functions Documentation

function printhex

inline void printhex(
const void * ptr,
uint32_t size
)

Parameters:

  • ptr - pointer to bytes of interest
  • size - number of bytes to print

Prints a block of bytes in hexadecimal

function printl

inline void printl(
const char * ptr,
size_t len
)

Parameters:

  • ptr - a string
  • len - number of chars to print

Prints string to a given length

function print

inline void print(
const char * ptr
)

Parameters:

  • ptr - a null terminated string

Prints string

function print

inline void print(
float num
)

Parameters:

  • num to be printed

Prints single-precision floating point number (i.e. float)

function print

inline void print(
double num
)

Parameters:

  • num to be printed

Prints double-precision floating point number (i.e. double)

function print

inline void print(
long double num
)

Parameters:

  • num to be printed

Prints quadruple-precision floating point number (i.e. long double)

function print

template <typename T ,
std::enable_if_t<!std::is_integral< std::decay_t< T >>::value, int > =0>
inline void print(
T && t
)

Parameters:

  • t to be printed

Precondition: T must implements print() function

Prints class object

function print_f

inline void print_f(
const char * s
)

Parameters:

  • s null terminated string to be printed

Prints null terminated string


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