CLibs
Loading...
Searching...
No Matches
item_print_functions.h File Reference
#include "headers/attributes.h"
#include "headers/errors.h"
#include <stdbool.h>

Go to the source code of this file.

Macros

#define TYPE_SEPARATOR   ": "
 String which separates the type name (see PrintFunctions_DoPrintType) from the value.
#define ITEM_PRINT_FUNCTION_NAME(type)
 Creates a function name token from the type (must be a single token)
#define DECLARE_PRINT_FUNC(name)
 Declares a PrintFunction
#define DEFINE_PRINT_FUNC(type, format_str)

Typedefs

typedef void(* PrintFunction) (const void *, size_t)
 Interface for functions that print data.

Functions

 DECLARE_PRINT_FUNC (byte)
 DECLARE_PRINT_FUNC (bool)
 DECLARE_PRINT_FUNC (int)
 DECLARE_PRINT_FUNC (size_t)
 DECLARE_PRINT_FUNC (ssize_t)
 DECLARE_PRINT_FUNC (char)
 DECLARE_PRINT_FUNC (float)
 DECLARE_PRINT_FUNC (double)
 DECLARE_PRINT_FUNC (pointer)
 DECLARE_PRINT_FUNC (string)
 DECLARE_PRINT_FUNC (string_direct)

Variables

LibraryDefined bool PrintFunctions_DoPrintType = false
 If true, the functions defined by DEFINE_PRINT_FUNC also print the type name.

Macro Definition Documentation

◆ DECLARE_PRINT_FUNC

#define DECLARE_PRINT_FUNC ( name)
Value:
void ITEM_PRINT_FUNCTION_NAME( name )( const void *, size_t )
#define ITEM_PRINT_FUNCTION_NAME(type)
Creates a function name token from the type (must be a single token)
Definition item_print_functions.h:29

Declares a PrintFunction

◆ DEFINE_PRINT_FUNC

#define DEFINE_PRINT_FUNC ( type,
format_str )
Value:
void ITEM_PRINT_FUNCTION_NAME( type )( const void *data, const size_t nbytes ) \
{ \
if ( nbytes != sizeof( type ) ) \
{ \
fwarnx( "invalid data" ); \
return; \
} \
\
{ \
printf( "‹" ); \
printf( #type TYPE_SEPARATOR ); \
} \
printf( format_str, *( ( type * ) data ) ); \
printf( "›" ); \
}
#define TYPE_SEPARATOR
String which separates the type name (see PrintFunctions_DoPrintType) from the value.
Definition item_print_functions.h:24
LibraryDefined bool PrintFunctions_DoPrintType
If true, the functions defined by DEFINE_PRINT_FUNC also print the type name.
Definition item_print_functions.h:20

Defines a PrintFunction.

This function checks whether data size equals sizeof( type ) and prints the data as type, according to the format_string.

◆ ITEM_PRINT_FUNCTION_NAME

#define ITEM_PRINT_FUNCTION_NAME ( type)
Value:
Print_##type

Creates a function name token from the type (must be a single token)

◆ TYPE_SEPARATOR

#define TYPE_SEPARATOR   ": "

String which separates the type name (see PrintFunctions_DoPrintType) from the value.

Typedef Documentation

◆ PrintFunction

typedef void(* PrintFunction) (const void *, size_t)

Interface for functions that print data.

Function Documentation

◆ DECLARE_PRINT_FUNC() [1/11]

DECLARE_PRINT_FUNC ( bool )

◆ DECLARE_PRINT_FUNC() [2/11]

DECLARE_PRINT_FUNC ( byte )

◆ DECLARE_PRINT_FUNC() [3/11]

DECLARE_PRINT_FUNC ( char )

◆ DECLARE_PRINT_FUNC() [4/11]

DECLARE_PRINT_FUNC ( double )

◆ DECLARE_PRINT_FUNC() [5/11]

DECLARE_PRINT_FUNC ( float )

◆ DECLARE_PRINT_FUNC() [6/11]

DECLARE_PRINT_FUNC ( int )

◆ DECLARE_PRINT_FUNC() [7/11]

DECLARE_PRINT_FUNC ( pointer )

◆ DECLARE_PRINT_FUNC() [8/11]

DECLARE_PRINT_FUNC ( size_t )

◆ DECLARE_PRINT_FUNC() [9/11]

DECLARE_PRINT_FUNC ( ssize_t )

◆ DECLARE_PRINT_FUNC() [10/11]

DECLARE_PRINT_FUNC ( string )

◆ DECLARE_PRINT_FUNC() [11/11]

DECLARE_PRINT_FUNC ( string_direct )

Variable Documentation

◆ PrintFunctions_DoPrintType

LibraryDefined bool PrintFunctions_DoPrintType = false

If true, the functions defined by DEFINE_PRINT_FUNC also print the type name.