Maze Builder Docs 8.10.23
Loading...
Searching...
No Matches
io_utils.h
Go to the documentation of this file.
1#ifndef IO_UTILS_H
2#define IO_UTILS_H
3
4#include <cstdint>
5#include <filesystem>
6#include <ostream>
7#include <string_view>
8#include <vector>
9
12namespace mazes
13{
17 {
18 public:
24 static bool write(std::ostream& oss, std::string_view data, std::string_view delimiter = "\n") noexcept;
25
30 static bool write_file(std::string_view filename, std::string_view data) noexcept;
31
34 static bool is_an_absolute_path(std::string_view path) noexcept;
35
39 static bool is_valid_path(std::string_view path) noexcept;
40
44 static std::string parent_path(std::string_view filepath) noexcept;
45
49 static std::vector<std::uint8_t> read_file_to_bytes(const std::filesystem::path& file_path) noexcept;
50
57 static bool write_png(const std::filesystem::path& file_path, const std::vector<std::uint8_t>& pixels, int width, int height) noexcept;
58
66 static bool write_jpg(const std::filesystem::path& file_path, const std::vector<std::uint8_t>& pixels, int width, int height, int quality = 95) noexcept;
67
74 static bool write_bmp(const std::filesystem::path& file_path, const std::vector<std::uint8_t>& pixels, int width, int height) noexcept;
75 }; // io_utils
76}
77
78#endif // IO_UTILS_H
Handles file writing for text, stdout, and object files.
Definition io_utils.h:17
static bool is_an_absolute_path(std::string_view path) noexcept
Check if a path is an absolute path.
static std::vector< std::uint8_t > read_file_to_bytes(const std::filesystem::path &file_path) noexcept
Read an entire file into memory.
static bool write(std::ostream &oss, std::string_view data, std::string_view delimiter="\n") noexcept
Handles writing to an output stream.
static bool write_jpg(const std::filesystem::path &file_path, const std::vector< std::uint8_t > &pixels, int width, int height, int quality=95) noexcept
Writes image data to a JPEG file.
static bool write_file(std::string_view filename, std::string_view data) noexcept
Write to a file.
static bool write_png(const std::filesystem::path &file_path, const std::vector< std::uint8_t > &pixels, int width, int height) noexcept
Writes pixel data to a PNG image file.
static bool write_bmp(const std::filesystem::path &file_path, const std::vector< std::uint8_t > &pixels, int width, int height) noexcept
Writes a BMP image file from pixel data.
static bool is_valid_path(std::string_view path) noexcept
Check if a path is valid.
static std::string parent_path(std::string_view filepath) noexcept
Get the directory path from a full file path.