Handles file writing for text, stdout, and object files.
More...
#include <io_utils.h>
|
| 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_file (std::string_view filename, std::string_view data) noexcept |
| | Write to a file.
|
| static bool | is_an_absolute_path (std::string_view path) noexcept |
| | Check if a path is an absolute path.
|
| 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.
|
| 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_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_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_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.
|
Handles file writing for text, stdout, and object files.
◆ is_an_absolute_path()
| bool mazes::io_utils::is_an_absolute_path |
( |
std::string_view | path | ) |
|
|
staticnoexcept |
Check if a path is an absolute path.
- Parameters
-
◆ is_valid_path()
| bool mazes::io_utils::is_valid_path |
( |
std::string_view | path | ) |
|
|
staticnoexcept |
Check if a path is valid.
- Parameters
-
- Returns
◆ parent_path()
| std::string mazes::io_utils::parent_path |
( |
std::string_view | filepath | ) |
|
|
staticnoexcept |
Get the directory path from a full file path.
- Parameters
-
- Returns
- Directory path
◆ read_file_to_bytes()
| std::vector< std::uint8_t > mazes::io_utils::read_file_to_bytes |
( |
const std::filesystem::path & | file_path | ) |
|
|
staticnoexcept |
Read an entire file into memory.
- Parameters
-
- Returns
- The file contents as bytes, or an empty vector on failure
◆ write()
| bool mazes::io_utils::write |
( |
std::ostream & | oss, |
|
|
std::string_view | data, |
|
|
std::string_view | delimiter = "\n" ) |
|
staticnoexcept |
Handles writing to an output stream.
- Parameters
-
| oss | |
| data | |
| delimiter | Delimiter to use between data entries |
- Returns
- True if the write was successful, false otherwise
◆ write_bmp()
| bool mazes::io_utils::write_bmp |
( |
const std::filesystem::path & | file_path, |
|
|
const std::vector< std::uint8_t > & | pixels, |
|
|
int | width, |
|
|
int | height ) |
|
staticnoexcept |
Writes a BMP image file from pixel data.
- Parameters
-
| file_path | The path where the BMP file will be written. |
| pixels | A vector containing the pixel data to write. |
| width | The width of the image in pixels. |
| height | The height of the image in pixels. |
- Returns
- Returns true if the BMP file was successfully written, false otherwise.
◆ write_file()
| bool mazes::io_utils::write_file |
( |
std::string_view | filename, |
|
|
std::string_view | data ) |
|
staticnoexcept |
Write to a file.
- Parameters
-
| filename | Full file path |
| data | Data to write |
- Returns
- True if the write was successful, false otherwise
◆ write_jpg()
| bool mazes::io_utils::write_jpg |
( |
const std::filesystem::path & | file_path, |
|
|
const std::vector< std::uint8_t > & | pixels, |
|
|
int | width, |
|
|
int | height, |
|
|
int | quality = 95 ) |
|
staticnoexcept |
Writes image data to a JPEG file.
- Parameters
-
| file_path | The file system path where the JPEG file will be written. |
| pixels | A vector containing the pixel data in RGB or RGBA format. |
| width | The width of the image in pixels. |
| height | The height of the image in pixels. |
| quality | The JPEG compression quality (0-100, default is 95). Higher values produce better quality but larger files. |
- Returns
- True if the JPEG file was successfully written, false otherwise.
◆ write_png()
| bool mazes::io_utils::write_png |
( |
const std::filesystem::path & | file_path, |
|
|
const std::vector< std::uint8_t > & | pixels, |
|
|
int | width, |
|
|
int | height ) |
|
staticnoexcept |
Writes pixel data to a PNG image file.
- Parameters
-
| file_path | The filesystem path where the PNG file will be written. |
| pixels | A vector containing the pixel data as 8-bit unsigned integers. |
| width | The width of the image in pixels. |
| height | The height of the image in pixels. |
- Returns
- True if the PNG file was successfully written, false otherwise.
The documentation for this class was generated from the following file: