MayaFlux
1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
TextFileWriter.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
FileWriter.hpp
"
4
#include <fstream>
5
6
namespace
MayaFlux::IO
{
7
8
/**
9
* @class TextFileWriter
10
* @brief Simple text file writer for logs and text data
11
*
12
* Thread-safe text file writing with optional buffering.
13
* Designed for log files, configuration files, etc.
14
*/
15
class
MAYAFLUX_API
TextFileWriter
:
public
FileWriter
{
16
public
:
17
TextFileWriter
();
18
~TextFileWriter
()
override
;
19
20
bool
can_write(
const
std::string& filepath)
const override
;
21
bool
open(
const
std::string& filepath,
FileWriteOptions
options)
override
;
22
void
close()
override
;
23
bool
is_open()
const override
;
24
25
bool
write_bytes(
const
void
* data,
size_t
size
)
override
;
26
bool
write_string(std::string_view str)
override
;
27
bool
write_line(std::string_view line)
override
;
28
bool
flush()
override
;
29
30
size_t
get_write_position()
const override
;
31
std::string get_last_error()
const override
;
32
33
/**
34
* @brief Set maximum file size before rotation
35
* @param max_bytes Maximum size in bytes (0 = no limit)
36
*/
37
void
set_max_file_size(
size_t
max_bytes);
38
39
/**
40
* @brief Get current file size
41
*/
42
size_t
get_file_size()
const
;
43
44
private
:
45
bool
should_rotate()
const
;
46
bool
rotate_file();
47
48
mutable
std::mutex
m_mutex
;
49
std::ofstream
m_file
;
50
std::string
m_filepath
;
51
FileWriteOptions
m_options {};
52
size_t
m_bytes_written { 0 };
53
size_t
m_max_file_size { 0 };
54
mutable
std::string
m_last_error
;
55
bool
m_is_open {};
56
};
57
58
}
// namespace MayaFlux::IO
size
bool size
Definition
FFmpegCameraReader.cpp:74
FileWriter.hpp
MayaFlux::IO::FileWriter
Abstract base class for file writing operations.
Definition
FileWriter.hpp:84
MayaFlux::IO::TextFileWriter::TextFileWriter
TextFileWriter()
MayaFlux::IO::TextFileWriter::m_last_error
std::string m_last_error
Definition
TextFileWriter.hpp:54
MayaFlux::IO::TextFileWriter::m_mutex
std::mutex m_mutex
Definition
TextFileWriter.hpp:48
MayaFlux::IO::TextFileWriter::m_filepath
std::string m_filepath
Definition
TextFileWriter.hpp:50
MayaFlux::IO::TextFileWriter::m_file
std::ofstream m_file
Definition
TextFileWriter.hpp:49
MayaFlux::IO::TextFileWriter
Simple text file writer for logs and text data.
Definition
TextFileWriter.hpp:15
MayaFlux::IO::FileWriteOptions
FileWriteOptions
Definition
FileWriter.hpp:5
MayaFlux::IO
Definition
Chronie.hpp:27
src
MayaFlux
IO
TextFileWriter.hpp
Generated by
1.9.8