Motion Master
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions
util.h File Reference
#include <algorithm>
#include <bit>
#include <charconv>
#include <chrono>
#include <condition_variable>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <mutex>
#include <nlohmann/json.hpp>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string_view>
#include <thread>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <utility>
#include <variant>
#include <vector>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mm::core::util::ThreadSafeQueue< T >
 A simple thread-safe FIFO queue. More...
 
struct  std::hash< std::pair< uint16_t, uint8_t > >
 

Namespaces

namespace  mm
 
namespace  mm::core
 
namespace  mm::core::util
 
namespace  std
 Specialization of std::hash for std::pair<uint16_t, uint8_t>.
 

Enumerations

enum class  mm::core::util::Endianness { mm::core::util::LITTLE , mm::core::util::BIG }
 Specifies the byte order used when converting a byte sequence to an integer. More...
 

Functions

template<typename T >
mm::core::util::parseHex (const std::string &s)
 Parses a hexadecimal string into an unsigned integer of type T. More...
 
template<typename T >
mm::core::util::toInteger (const std::vector< std::uint8_t > &data, std::size_t offset=0, Endianness endian=Endianness::LITTLE)
 Converts a byte sequence to an integer of type T with optional offset and endianness. More...
 
std::vector< std::vector< uint8_t > > mm::core::util::splitIntoParts (const std::vector< uint8_t > &input, size_t partSize)
 Splits a byte vector into parts of a specified maximum size. More...
 
std::vector< uint8_t > mm::core::util::zipData (const std::string &filename, const std::vector< uint8_t > &data)
 Compresses a block of data into a ZIP archive containing a single file. More...
 
std::unordered_map< std::string, std::vector< uint8_t > > mm::core::util::unzipData (const std::vector< uint8_t > &data)
 Unzips a ZIP archive from an in-memory byte buffer. More...
 
template<typename T >
bool mm::core::util::stringViewToNumber (std::string_view sv, T &result)
 Converts a string_view to a numeric type. More...
 
template<typename T >
std::vector< uint8_t > mm::core::util::toBytes (T value, bool bigEndian=false)
 Converts a trivially copyable value to a byte vector. More...
 
template<typename T >
mm::core::util::fromBytes (const std::vector< uint8_t > &bytes, bool bigEndian=false)
 Reconstructs a value of type T from a byte vector. More...
 
std::string mm::core::util::makeParameterId (int index, int subindex)
 Formats the given index and subindex into a parameter identifier string. More...
 
std::string mm::core::util::toHex (const std::vector< uint8_t > &data)
 Converts a vector of bytes to a space-separated hexadecimal string. More...
 
template<typename T >
std::string mm::core::util::toHex (T value)
 Converts an integer value to its hexadecimal string representation. More...
 
std::vector< uint8_t > mm::core::util::readBinaryFile (const std::string &filename)
 Reads the entire contents of a binary file into a byte vector. More...
 
std::string mm::core::util::readTextFile (const std::string &filename)
 Reads the entire content of a text file into a std::string. More...
 
std::string mm::core::util::joinStrings (const std::vector< std::string > &list, const std::string &delimiter)
 Joins a list of strings into a single string with a delimiter. More...
 
std::string mm::core::util::formatMacAddress (const std::string &originalMacAddress)
 Formats a MAC address string to ensure each component is two digits and uppercase. More...
 
std::string mm::core::util::extractIpAddress (const std::string &socketAddress)
 Extracts the IP address from a socket address string. More...
 
unsigned short mm::core::util::extractPort (const std::string &socketAddress)
 Extracts the port number from a socket address string. More...
 
bool mm::core::util::endsWith (const std::string &str, const std::string &suffix)
 Checks whether a string ends with the given suffix. More...
 
size_t mm::core::util::countStringsStartingWith (const std::vector< std::string > &strings, const std::string &prefix)
 Count how many strings in the list start with the given prefix. More...
 
std::vector< std::string > mm::core::util::split (const std::string &input, char delimiter)
 Splits a string into substrings based on a delimiter character. More...
 
int64_t mm::core::util::currentTimeMillis ()
 Gets the current system time in milliseconds since the Unix epoch. More...
 
template<typename T >
constexpr T mm::core::util::linearScale (T value, T inMin, T inMax, T outMin, T outMax)