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).
| Name | Kind | Items |
|---|---|---|
Base64 | class | 3 |
Camera2DHelper | class | 17 |
PaletteType | enum | 4 |
ColorPalette | struct | 2 |
CommandLineParser | class | 12 |
Compression | class | 10 |
CompressedAssetBundle | class | 3 |
Easing | struct | 7 |
Lerp | struct | 5 |
Grid2D | class | 10 |
Hash | class | 7 |
HighScoreStore | class | 7 |
ObjectPool | class | 12 |
Pathfinder | struct | 3 |
Rng | class | 6 |
IntervalTimer | class | 5 |
CountdownTimer | class | 8 |
StringUtils | class | 20 |
TileRenderer | struct | 5 |
TweenEntry | struct | 8 |
Tweener | class | 6 |
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 noexceptvoid setCenter(const sgc::Vec2f& center) noexcept[[nodiscard]] sgc::Vec2f center() const noexceptvoid setZoom(float zoom) noexcept[[nodiscard]] float zoom() const noexceptvoid 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) noexceptenum PaletteType 4
Pico8NesPastelGameBoystruct 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) noexceptclass 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) consttemplate <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 noexceptvoid printHelp() conststatic 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) noexceptclass 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) noexceptstatic constexpr float easeInQuad(float t) noexceptstatic constexpr float easeOutQuad(float t) noexceptstatic constexpr float easeInOutQuad(float t) noexceptstatic inline float easeOutBounce(float t) noexceptstatic inline float easeOutElastic(float t) noexceptstatic constexpr float easeInOutCubic(float t) noexceptstruct Lerp 5
float from = 0.0ffloat to = 1.0ffloat duration = 1.0f[[nodiscard]] float value(float elapsed) const noexcepttemplate <typename EaseFunc> [[nodiscard]] float value(float elapsed, EaseFunc ease) const noexceptclass Grid2D 10
Grid2D(int width, int height, const T& defaultValue = T{})T& at(int x, int y)const T& at(int x, int y) constbool inBounds(int x, int y) const noexceptvoid fill(const T& value)int width() const noexceptint height() const noexcepttemplate <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) noexceptclass 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) noexceptclass 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() noexceptinline 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 noexceptT& at(int index)const T& at(int index) constinline 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) noexceptstd::uint32_t next() noexceptint 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) noexceptclass IntervalTimer 5
explicit IntervalTimer(float interval)int update(float dt) noexceptvoid reset() noexceptfloat interval() const noexceptvoid setInterval(float interval)class CountdownTimer 8
explicit CountdownTimer(float duration)void update(float dt) noexceptbool isFinished() const noexceptfloat remaining() const noexceptfloat progress() const noexceptvoid 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::utilclass 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) noexcepttemplate <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) noexceptusing TweenId = std::uint32_t;using TweenCallback = std::function<void(float)>;using EaseFunc = std::function<float(float)>;struct TweenEntry 8
TweenId id = 0float from = 0.0ffloat to = 1.0ffloat duration = 1.0ffloat elapsed = 0.0fTweenCallback callbackEaseFunc easebool finished = falseclass 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 noexceptSourced from docs/API_CATALOG.md, auto-generated by tools/generate_api_catalog.py.