MeshNet  1.0.0
Data Structures | Macros | Enumerations | Functions
meshHelper.h File Reference

This file contains classes and structures that supports meshNet. More...

#include "meshConfig.h"
Include dependency graph for meshHelper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  InlinePrintable
 Interface for printing derived class collection as table with header and rows. More...
 
class  RawPrintable
 Interface for converting class or structure instance to raw bytes, which can be sent. More...
 
struct  MeshMAC
 Structure that represents physical MAC address used in MeshNEt protocol. MeshMAC address unlike MAC address used in TCP/IP protocol has just 4 octets. More...
 
struct  MeshVersion
 Structure that represents MeshNet version. Real size of this class is always 2 bytes. More...
 

Macros

#define HAS_MEM_FUNC(func, name)
 This macro creates checker structure, which can check, if class contains member function. More...
 

Enumerations

enum  TextAlignment { T_LEFT, T_CENTER, T_RIGHT }
 Enumeration for text alignment in alignText() function. More...
 
enum  MeshPacketStatus { MPS_Unknown = 0, MPS_Sent, MPS_Waiting, MPS_WaitingForPath }
 

Functions

char * _itoa_s (int32_t value, char *buffer, size_t size, int radix)
 
void alignText (char *text, int size, char fill, TextAlignment alignment)
 Aligns text in char array. More...
 

Detailed Description

This file contains classes and structures that supports meshNet.

Credits

Author
Matej Fitoš
Date
Aug 24, 2021

Macro Definition Documentation

◆ HAS_MEM_FUNC

#define HAS_MEM_FUNC (   func,
  name 
)
Value:
template<typename T, typename Sign> \
struct name { \
typedef char yes[1]; \
typedef char no [2]; \
template <typename U, U> struct type_check; \
template <typename _1> static yes &chk(type_check<Sign, &_1::func> *); \
template <typename > static no &chk(...); \
static bool const value = sizeof(chk<T>(0)) == sizeof(yes); \
}

This macro creates checker structure, which can check, if class contains member function.

@macro HAS_MEM_FUNC

Example

class testClass{
int foo(bool a){
return a;
}
int foo2(bool a) const{
return a;
}
static int foo3(bool a){
return a;
}
};
HAS_MEM_FUNC(foo, has_foo); //Generating checker for member function foo()
HAS_MEM_FUNC(foo2, has_foo2); //Generating checker for member function foo2()
HAS_MEM_FUNC(foo3, has_foo3); //Generating checker for member function foo3()
//Basic member function
bool t1 = has_foo<testClass, int(testClass::*)(bool)>::value; //True
bool t2 = has_foo<testClass, int(testClass::*)(int)>::value; //False
//Constant member function
bool t3 = has_foo2<testClass, int(testClass::*)(bool) const>::value; //True
bool t4 = has_foo2<testClass, int(testClass::*)(bool)>::value; //False
//Static member function
bool t3 = has_foo3<testClass, int(*)(bool)>::value; //True
bool t4 = has_foo3<testClass, int(testClass::*)(bool)>::value; //False

Author

https://stackoverflow.com/a/264088

Parameters
funcName of function that needs to be checked.
nameName of generated checker structure.

Enumeration Type Documentation

◆ MeshPacketStatus

@begin Status of sent mesh packet.

Enumerator
MPS_Unknown 

No info about sent packet exists. This can be set if packet was sent, but no timeout was set.

MPS_Sent 

Packet was sent. This can be set only if packet was sent with timeout.

MPS_Waiting 

Packet is waiting for send.

MPS_WaitingForPath 

Packet is waiting for path creation.

◆ TextAlignment

Enumeration for text alignment in alignText() function.

Enumerator
T_LEFT 
T_CENTER 
T_RIGHT 

Function Documentation

◆ _itoa_s()

char* _itoa_s ( int32_t  value,
char *  buffer,
size_t  size,
int  radix 
)

◆ alignText()

void alignText ( char *  text,
int  size,
char  fill,
TextAlignment  alignment 
)

Aligns text in char array.

Parameters
textText array, that has to be aligned. Text has to end with \0 character.
sizeSize of text array.
fillCharacter, that will be inserted to blank space.
alignmentText alignment.
HAS_MEM_FUNC
#define HAS_MEM_FUNC(func, name)
This macro creates checker structure, which can check, if class contains member function.
Definition: meshHelper.h:57