Maze Builder Docs 7.5.6
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 <filesystem>
5#include <string>
6#include <vector>
7#include <cstdint>
8
9namespace mazes
10{
11
14
18 {
19 public:
27 bool write_png(const std::string &filename, const std::vector<std::uint8_t> &data, unsigned int w = 100, unsigned int h = 100, unsigned int stride = 4) const noexcept;
28
36 bool write_jpeg(const std::string &filename, const std::vector<std::uint8_t> &data, unsigned int w = 100, unsigned int h = 100, unsigned int stride = 4) const noexcept;
37
42 bool write(std::ostream &oss, const std::string &data) const noexcept;
43
48 bool write_file(const std::string &filename, const std::string &data) const noexcept;
49
53 static std::string getDirectoryPath(const std::string& filepath) noexcept {
54 std::filesystem::path p(filepath);
55 return p.parent_path().string();
56 }
57 }; // io_utils
58
59}
60
61#endif // IO_UTILS_H
Handles file writing for text, stdout, images, and object files.
Definition io_utils.h:18
bool write(std::ostream &oss, const std::string &data) const noexcept
Handles writing to an output stream.
bool write_jpeg(const std::string &filename, const std::vector< std::uint8_t > &data, unsigned int w=100, unsigned int h=100, unsigned int stride=4) const noexcept
Write pixels to a JPEG file.
static std::string getDirectoryPath(const std::string &filepath) noexcept
Get the directory path from a full file path.
Definition io_utils.h:53
bool write_file(const std::string &filename, const std::string &data) const noexcept
Write to a file.
bool write_png(const std::string &filename, const std::vector< std::uint8_t > &data, unsigned int w=100, unsigned int h=100, unsigned int stride=4) const noexcept
Write pixels to a PNG file.
Namespace for the maze builder.
Definition algo_interface.h:6