Skip to content

Dutils

Overview

Helpful utilities, provides custom data buffer and data utility functions.

Dbuffer

Useful class for storing data.
Has an easy conversion method from string and back.
Various methods of initialization are available.

Constructors


Initializer list

Equivalent to std::vector<unsigned char> buffer = {1,2,3...};

dutils::dbuffer(std::initializer_list list)

  • Parameters:
    • std::initializer_list<unsigned int> list - Input data


Char

Initializes buffer and copies the char data into it.

Note

In case you wish to assign the data without copying you can use the _data, but you have to update _size as well.

dutils::dbuffer(const char* src, size_t size)

  • Parameters:
    • const char* src - Data to copy

dutils::dbuffer(const unsigned char* src, size_t size)

  • Parameters:
    • const unsigned char* src - Data to copy



Vector

Copies data from std::vector<unsigned char> to newly created blank dbuffer, this is primarily for compatibility purposes, but direct construction of dutils::dbuffer is more efficient.

dutils::dbuffer(std::vector data)

  • Parameters:
    • std::vector<unsinged char> data - Buffer to copy


String

Initializes buffer and copies the string into it.

dutils::dbuffer(std::string s_data)

  • Parameters:
    • std::string s_data - String to copy



Methods

toStr

Warning

Please note that the dbuffer contents are not checked for string safety, thus when converting you must handle possible nullterminators yourself.

Returns content of the buffer in form of string

dutils::dbuffer::toStr()

  • Parametrs:
  • Returns:
    • std::string buffer_stringified



hexStr

This function provides an easy way to convert data into string interpretation of hex values.
Useful when you want to print out or compare buffers with non-string data.

dutils::hexStr(const dutils::dbuffer &data)

  • Parameters:
    • const dutils::dbuffer &data - The input data buffer.
  • Returns:
    • std::string - A formatted hex string