libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
util.hpp File Reference

General SDL utility helpers, file I/O, and compression utilities. More...

#include <vector>
#include <string>
#include <iostream>
#include "SDL.h"
#include "SDL_ttf.h"
#include "tee_stream.hpp"
#include <optional>
#include <memory>
#include <zlib.h>
Include dependency graph for util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  mx::mxUtil
 Utility bag for SDL-based applications. More...

Namespaces

namespace  mx

Functions

std::vector< char > mx::readFile (const std::string &filename)
 Read an entire file into a byte vector.
std::string mx::readFileToString (const std::string &filename)
 Read an entire text file into a string.
std::string mx::decompressString (void *data, uLong size_)
 Decompress a zlib-compressed data block.
std::unique_ptr< char[]> mx::compressString (const std::string &text, uLong &len)
 Compress a string using zlib.
float mx::generateRandomFloat (float min, float max)
 Generate a random float in the given range.
int mx::generateRandomInt (int min, int max)
 Generate a random integer in the given range.

Detailed Description

General SDL utility helpers, file I/O, and compression utilities.

Provides mxUtil for window-attached helpers (texture loading, font loading, joystick management) plus free functions for file reading, string compression/decompression (zlib), and random number generation.

Definition in file util.hpp.