mitiru::util

Namespace catalog extracted from docs/API_CATALOG.md (21 types, 160 items).

Namespace catalog extracted from docs/API_CATALOG.md (21 types, 160 items).

NameKindItems
Base64class3
Camera2DHelperclass17
PaletteTypeenum4
ColorPalettestruct2
CommandLineParserclass12
Compressionclass10
CompressedAssetBundleclass3
Easingstruct7
Lerpstruct5
Grid2Dclass10
Hashclass7
HighScoreStoreclass7
ObjectPoolclass12
Pathfinderstruct3
Rngclass6
IntervalTimerclass5
CountdownTimerclass8
StringUtilsclass20
TileRendererstruct5
TweenEntrystruct8
Tweenerclass6
class Base64 3
[[nodiscard]] static std::string encode(const uint8_t* data, std::size_t size)
[[nodiscard]] static std::string encode(const std::vector<uint8_t>& data)
[[nodiscard]] static std::vector<uint8_t> decode(const std::string& base64str)
class Camera2DHelper 17
Camera2DHelper(float viewportWidth, float viewportHeight) noexcept
[[nodiscard]] sgc::Vec2f worldToScreen(const sgc::Vec2f& worldPos) const noexcept
[[nodiscard]] sgc::Vec2f screenToWorld(const sgc::Vec2f& screenPos) const noexcept
[[nodiscard]] sgc::Rectf visibleBounds() const noexcept
void setCenter(const sgc::Vec2f& center) noexcept
[[nodiscard]] sgc::Vec2f center() const noexcept
void setZoom(float zoom) noexcept
[[nodiscard]] float zoom() const noexcept
void setViewport(float w, float h) noexcept
[[nodiscard]] float viewportWidth() const noexcept
[[nodiscard]] float viewportHeight() const noexcept
[[nodiscard]] inline bool overlapsRectRect(const sgc::Rectf& a, const sgc::Rectf& b) noexcept
[[nodiscard]] inline bool overlapsCircleCircle( sgc::Vec2f c1, float r1, sgc::Vec2f c2, float r2) noexcept
[[nodiscard]] inline bool overlapsCircleRect( sgc::Vec2f center, float radius, const sgc::Rectf& rect) noexcept
[[nodiscard]] inline bool pointInRect(sgc::Vec2f p, const sgc::Rectf& rect) noexcept
[[nodiscard]] inline bool pointInCircle( sgc::Vec2f p, sgc::Vec2f center, float radius) noexcept
[[nodiscard]] inline std::optional<sgc::Vec2f> resolveAABB( const sgc::Rectf& mover, const sgc::Rectf& obstacle) noexcept
enum PaletteType 4
Pico8
Nes
Pastel
GameBoy
struct ColorPalette 2
[[nodiscard]] static constexpr sgc::Colorf get(PaletteType palette, int index) noexcept
[[nodiscard]] static constexpr sgc::Colorf get( const std::array<sgc::Colorf, PALETTE_SIZE>& palette, int index) noexcept
class CommandLineParser 12
CommandLineParser& addFlag(const std::string& name, const std::string& shortName, const std::string& description)
template <typename T> CommandLineParser& addOption(const std::string& name, const std::string& shortName, const std::string& description, const T& defaultValue)
CommandLineParser& addPositional(const std::string& name, const std::string& description)
bool parse(int argc, char* argv[])
[[nodiscard]] bool hasFlag(const std::string& name) const
template <typename T> [[nodiscard]] T getOption(const std::string& name) const
[[nodiscard]] std::string getPositional(std::size_t index) const
[[nodiscard]] std::size_t positionalCount() const noexcept
[[nodiscard]] bool helpRequested() const noexcept
[[nodiscard]] const std::vector<std::string>& errors() const noexcept
void printHelp() const
static void printVersion(std::string_view name, std::string_view version)
class Compression 10
[[nodiscard]] static constexpr int fast() noexcept
[[nodiscard]] static constexpr int balanced() noexcept
[[nodiscard]] static constexpr int best() noexcept
[[nodiscard]] static std::vector<uint8_t> compress( const uint8_t* data, std::size_t size, int level = balanced())
[[nodiscard]] static std::vector<uint8_t> compress( const std::vector<uint8_t>& data, int level = balanced())
[[nodiscard]] static std::vector<uint8_t> decompress( const uint8_t* compressedData, std::size_t size, std::size_t originalSize)
[[nodiscard]] static std::vector<uint8_t> compressString( const std::string& str, int level = balanced())
[[nodiscard]] static std::string decompressString( const uint8_t* data, std::size_t size)
[[nodiscard]] static std::size_t estimateCompressedSize(std::size_t originalSize) noexcept
[[nodiscard]] static bool isCompressed(const uint8_t* data, std::size_t size) noexcept
class CompressedAssetBundle 3
[[nodiscard]] static std::vector<uint8_t> pack( const std::map<std::string, std::vector<uint8_t>>& files, int level = Compression::balanced())
[[nodiscard]] static std::map<std::string, std::vector<uint8_t>> unpack( const std::vector<uint8_t>& bundle)
[[nodiscard]] static std::vector<uint8_t> extractFile( const std::vector<uint8_t>& bundle, const std::string& filename)
struct Easing 7
static constexpr float linear(float t) noexcept
static constexpr float easeInQuad(float t) noexcept
static constexpr float easeOutQuad(float t) noexcept
static constexpr float easeInOutQuad(float t) noexcept
static inline float easeOutBounce(float t) noexcept
static inline float easeOutElastic(float t) noexcept
static constexpr float easeInOutCubic(float t) noexcept
struct Lerp 5
float from = 0.0f
float to = 1.0f
float duration = 1.0f
[[nodiscard]] float value(float elapsed) const noexcept
template <typename EaseFunc> [[nodiscard]] float value(float elapsed, EaseFunc ease) const noexcept
class Grid2D 10
Grid2D(int width, int height, const T& defaultValue = T{})
T& at(int x, int y)
const T& at(int x, int y) const
bool inBounds(int x, int y) const noexcept
void fill(const T& value)
int width() const noexcept
int height() const noexcept
template <typename Func> void forEach(Func&& func)
template <typename Pred> std::vector<std::pair<int, int>> findAll(Pred&& pred) const
[[nodiscard]] consteval std::uint64_t operator""_hash(const char* str, std::size_t len) noexcept
class Hash 7
Hash() = delete
[[nodiscard]] static constexpr std::uint64_t fnv1a(const void* data, std::size_t size) noexcept
[[nodiscard]] static constexpr std::uint64_t fnv1a(std::string_view str) noexcept
[[nodiscard]] static constexpr std::uint32_t crc32(const void* data, std::size_t size) noexcept
[[nodiscard]] static constexpr std::uint32_t crc32(std::string_view str) noexcept
[[nodiscard]] static constexpr std::uint64_t xxhash(const void* data, std::size_t size) noexcept
[[nodiscard]] static constexpr std::size_t hashCombine(std::size_t seed, std::size_t value) noexcept
class HighScoreStore 7
void save(std::string_view game, int score)
[[nodiscard]] int load(std::string_view game) const
[[nodiscard]] bool isHighScore(std::string_view game, int score) const
[[nodiscard]] static HighScoreStore& instance()
void clear() noexcept
inline void saveBmp(const std::string& path, const std::vector<std::uint8_t>& pixels, int w, int h)
inline void savePng(const std::string& path, const std::vector<std::uint8_t>& pixels, int w, int h)
class ObjectPool 12
explicit ObjectPool(int capacity = 64)
std::pair<T&, int> acquire()
void release(int index)
template <typename Func> void forEachActive(Func&& func)
template <typename Func> void forEachActive(Func&& func) const
[[nodiscard]] int activeCount() const noexcept
[[nodiscard]] int capacity() const noexcept
[[nodiscard]] bool isActive(int index) const noexcept
T& at(int index)
const T& at(int index) const
inline void drawParticles(Screen& screen, const sgc::ParticleSystem& system)
inline void drawParticlesAsRects(Screen& screen, const sgc::ParticleSystem& system)
struct Pathfinder 3
using Pos = std::pair<int, int>;
using WalkableFunc = std::function<bool(int cellValue)>;
[[nodiscard]] static std::vector<Pos> findPath( const Grid2D<int>& grid, Pos start, Pos goal, const WalkableFunc& isWalkable)
class Rng 6
explicit Rng(std::uint32_t seed = 42) noexcept
std::uint32_t next() noexcept
int nextInt(int min, int max)
float nextFloat(float min = 0.0f, float max = 1.0f)
bool nextBool(float probability = 0.5f)
void reset(std::uint32_t seed) noexcept
class IntervalTimer 5
explicit IntervalTimer(float interval)
int update(float dt) noexcept
void reset() noexcept
float interval() const noexcept
void setInterval(float interval)
class CountdownTimer 8
explicit CountdownTimer(float duration)
void update(float dt) noexcept
bool isFinished() const noexcept
float remaining() const noexcept
float progress() const noexcept
void reset(float duration)
void reset() noexcept
#pragma once #include <algorithm> #include <cmath> #include <cstdint> #include <cstring> #include <string> #include <string_view> #include <unordered_map> #include <vector> #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #include <Windows.h> #include <mmsystem.h> #pragma comment(lib, "winmm.lib") #endif namespace mitiru::util
class StringUtils 20
StringUtils() = delete
[[nodiscard]] static std::vector<std::string> split(std::string_view str, std::string_view delimiter)
[[nodiscard]] static std::string join(const std::vector<std::string>& strings, std::string_view delimiter)
[[nodiscard]] static std::string trimLeft(std::string_view str)
[[nodiscard]] static std::string trimRight(std::string_view str)
[[nodiscard]] static std::string trim(std::string_view str)
[[nodiscard]] static std::string toLower(std::string_view str)
[[nodiscard]] static std::string toUpper(std::string_view str)
[[nodiscard]] static constexpr bool startsWith(std::string_view str, std::string_view prefix) noexcept
[[nodiscard]] static constexpr bool endsWith(std::string_view str, std::string_view suffix) noexcept
[[nodiscard]] static constexpr bool contains(std::string_view str, std::string_view substr) noexcept
[[nodiscard]] static std::string replace(std::string_view str, std::string_view from, std::string_view to)
[[nodiscard]] static std::string replaceAll(std::string_view str, std::string_view from, std::string_view to)
template <typename... Args> [[nodiscard]] [[deprecated("Use with caution: fmt must be a compile-time constant, never user input")]] static std::string format(const char* fmt, Args&&... args)
template <typename T> [[nodiscard]] static std::optional<T> toNumber(std::string_view str) noexcept
template <typename T> [[nodiscard]] static std::string fromNumber(const T& value)
[[nodiscard]] static std::string padLeft(std::string_view str, std::size_t width, char padChar = ' ')
[[nodiscard]] static std::string padRight(std::string_view str, std::size_t width, char padChar = ' ')
[[nodiscard]] static std::string repeat(std::string_view str, std::size_t count)
using TileColorMapper = std::function<sgc::Colorf(int cellValue)>;
struct TileRenderer 5
static void draw( Screen& screen, const Grid2D<int>& grid, const sgc::Vec2f& origin, float tileSize, const TileColorMapper& colorMapper, bool drawGridLines = false, const sgc::Colorf& gridLineColor = sgc::Colorf{0.3f, 0.3f, 0.3f, 1.0f})
[[nodiscard]] static int expectedDrawCalls(const Grid2D<int>& grid, bool drawGridLines) noexcept
using TweenId = std::uint32_t;
using TweenCallback = std::function<void(float)>;
using EaseFunc = std::function<float(float)>;
struct TweenEntry 8
TweenId id = 0
float from = 0.0f
float to = 1.0f
float duration = 1.0f
float elapsed = 0.0f
TweenCallback callback
EaseFunc ease
bool finished = false
class Tweener 6
TweenId add(float from, float to, float duration, TweenCallback callback, EaseFunc ease = Easing::linear)
void update(float dt)
bool cancel(TweenId id)
void clear()
[[nodiscard]] int activeCount() const noexcept
[[nodiscard]] bool hasActive() const noexcept

Sourced from docs/API_CATALOG.md, auto-generated by tools/generate_api_catalog.py.