Deskflow 1.24.0.365
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
ProtocolUtil Class Reference

Deskflow protocol utilities. More...

#include <ProtocolUtil.h>

Static Public Member Functions

static uint8_t read1ByteInt (deskflow::IStream *stream)
 Write formatted data.
static uint16_t read2BytesInt (deskflow::IStream *stream)
static uint32_t read4BytesInt (deskflow::IStream *stream)
static void readVector1ByteInt (deskflow::IStream *, std::vector< uint8_t > &)
 Handles a Vector of integers.
static void readVector2BytesInt (deskflow::IStream *, std::vector< uint16_t > &)
static void readVector4BytesInt (deskflow::IStream *, std::vector< uint32_t > &)
static uint32_t readVectorSize (deskflow::IStream *stream)
static void readBytes (deskflow::IStream *, uint32_t, std::string *)
 Handles an array of bytes.

Detailed Description

Deskflow protocol utilities.

This class provides various functions for implementing the deskflow protocol.

Member Function Documentation

◆ read1ByteInt()

uint8_t ProtocolUtil::read1ByteInt ( deskflow::IStream * stream)
static

Write formatted data.

Write formatted binary data to a stream. fmt consists of regular characters and format specifiers. Format specifiers begin with %. All characters not part of a format specifier are regular and are transmitted unchanged.

Format specifiers are:

  • %% – literal `%'
  • %1i – converts integer argument to 1 byte integer
  • %2i – converts integer argument to 2 byte integer in NBO
  • %4i – converts integer argument to 4 byte integer in NBO
  • %1I – converts std::vector<uint8_t>* to 1 byte integers
  • %2I – converts std::vector<uint16_t>* to 2 byte integers in NBO
  • %4I – converts std::vector<uint32_t>* to 4 byte integers in NBO
  • %s – converts std::string* to stream of bytes
  • %S – converts integer N and const uint8_t* to stream of N bytes */ static void writef(deskflow::IStream *, const char *fmt, ...);

    Read formatted data /*! Read formatted binary data from a buffer. This performs the reverse operation of writef(). Returns true if the entire format was successfully parsed, false otherwise.

Format specifiers are:

  • %% – read (and discard) a literal `%'
  • %1i – reads a 1 byte integer; argument is a int32_t* or uint32_t*
  • %2i – reads an NBO 2 byte integer; arg is int32_t* or uint32_t*
  • %4i – reads an NBO 4 byte integer; arg is int32_t* or uint32_t*
  • %1I – reads 1 byte integers; arg is std::vector<uint8_t>*
  • %2I – reads NBO 2 byte integers; arg is std::vector<uint16_t>*
  • %4I – reads NBO 4 byte integers; arg is std::vector<uint32_t>*
  • %s – reads bytes; argument must be a std::string*, not a char* */ static bool readf(deskflow::IStream *, const char *fmt, ...);

private: static void vwritef(deskflow::IStream *, const char *fmt, uint32_t size, va_list); static void vreadf(deskflow::IStream *, const char *fmt, va_list);

static uint32_t getLength(const char *fmt, va_list); static void writef(std::vector<uint8_t> &, const char *fmt, va_list); static uint32_t eatLength(const char **fmt); static void read(deskflow::IStream *, void *, uint32_t);

/**

Handles 1,2, or 4 byte Integers

◆ read2BytesInt()

uint16_t ProtocolUtil::read2BytesInt ( deskflow::IStream * stream)
static

◆ read4BytesInt()

uint32_t ProtocolUtil::read4BytesInt ( deskflow::IStream * stream)
static

◆ readBytes()

void ProtocolUtil::readBytes ( deskflow::IStream * stream,
uint32_t len,
std::string * destination )
static

Handles an array of bytes.

◆ readVector1ByteInt()

void ProtocolUtil::readVector1ByteInt ( deskflow::IStream * stream,
std::vector< uint8_t > & destination )
static

Handles a Vector of integers.

◆ readVector2BytesInt()

void ProtocolUtil::readVector2BytesInt ( deskflow::IStream * stream,
std::vector< uint16_t > & destination )
static

◆ readVector4BytesInt()

void ProtocolUtil::readVector4BytesInt ( deskflow::IStream * stream,
std::vector< uint32_t > & destination )
static

◆ readVectorSize()

uint32_t ProtocolUtil::readVectorSize ( deskflow::IStream * stream)
static

The documentation for this class was generated from the following files: