C/C++ Library, mos@ua 1.0
cpplib-mos
utils.h File Reference

Useful common functions and macros. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "dbc.h"
#include "hdp.h"

Go to the source code of this file.

Macros

#define numDigits(num)
 Number of digits of an integer number (ignores signal!).
 
#define int2str(num)
 Converts an int value to a stack allocated string (signal is considered).
 
#define int2nstr(num, len)
 Converts an int value to a stack allocated string (signal is considered).
 
#define long2str(num)
 Converts an long value to a stack allocated string (signal is considered).
 
#define long2nstr(num, len)
 Converts an long value to a stack allocated string (signal is considered).
 
#define perc2str(percentage)
 Converts an int percentage to a stack allocated string.
 
#define random_boolean(trueProb)
 Generates a random boolean value.
 
#define random_int(min, max)
 Generates a random integer value within a given interval.
 
#define clear_console()
 Clears the terminal.
 
#define move_cursor(line, column)
 Moves the cursor to a position in terminal.
 
#define hide_cursor()
 Hides the terminal cursor.
 
#define show_cursor()
 Shows the terminal cursor.
 
String concatenation in stack memory (useful to compose contract error messages)

#define concat_2str(str1, str2)
 Concatenates two strings in the stack memory (thus it cannot be implemented in a function).
 
#define concat_3str(str1, str2, str3)
 Concatenates three strings in the stack memory (thus it cannot be implemented in a function).
 
#define concat_4str(str1, str2, str3, str4)
 Concatenates four strings in the stack memory (thus it cannot be implemented in a function).
 
#define concat_5str(str1, str2, str3, str4, str5)
 Concatenates five strings in the stack memory (thus it cannot be implemented in a function).
 
#define concat_6str(str1, str2, str3, str4, str5, str6)
 Concatenates six strings in the stack memory (thus it cannot be implemented in a function).
 
#define concat_7str(str1, str2, str3, str4, str5, str6, str7)
 Concatenates seven strings in the stack memory (thus it cannot be implemented in a function).
 
#define concat_12str(str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11, str12)
 Concatenates twelve strings in the stack memory (thus it cannot be implemented in a function).
 

Detailed Description

Useful common functions and macros.