NDEVR
API Documentation
AsciiFileOutputStream.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: AsciiFileOutputStream
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/LogStream.h>
35#include <NDEVR/File.h>
36namespace NDEVR
37{
38 class File;
39 class AsciiWriteThread;
44 class AsciiFileOutputStream final : public LogStream
45 {
46 public:
52 NDEVR_BASE_API explicit AsciiFileOutputStream(const File& file, bool append);
56 NDEVR_BASE_API virtual ~AsciiFileOutputStream();
62 void setProgress(uint04, fltp04) final override {};
67 void setOnlyLogSession(bool only_log_session);
73 NDEVR_BASE_API void addMessage(uint04 id, const LogMessage& message) final override;
79 NDEVR_BASE_API void setFile(const File& file, bool append);
84 NDEVR_BASE_API void moveFile(File new_location);
89 NDEVR_BASE_API void copyFile(File new_location);
94 NDEVR_BASE_API const File& file() const;
100 NDEVR_BASE_API static void WriteLogFile(LogPtr stream, const File& file);
106 NDEVR_BASE_API static void ReadLogFile(LogPtr stream, const File& file);
107#if NDEVR_SUPPORTS_THREADING
113 NDEVR_BASE_API void addMessages(uint04 id, const Buffer<LogMessage>& messages) final override;
114#endif
115 private:
116#if NDEVR_SUPPORTS_THREADING
117 AsciiWriteThread* m_write_thread;
118#else
119 File m_file;
120 String m_separator;
121 String m_new_line;
122#endif
123 bool m_only_log_session = true;
124 };
125}
126
AsciiFileOutputStream(const File &file, bool append)
Constructs an AsciiFileOutputStream targeting the given file.
static void ReadLogFile(LogPtr stream, const File &file)
Reads log messages from an ascii file into a log stream.
void setFile(const File &file, bool append)
Changes the target output file.
void setProgress(uint04, fltp04) final override
Sets progress information.
void copyFile(File new_location)
Copies the current log file to a new location on disk.
virtual ~AsciiFileOutputStream()
Destructor.
void moveFile(File new_location)
Moves the current log file to a new location on disk.
const File & file() const
Returns a reference to the current output file.
void setOnlyLogSession(bool only_log_session)
Sets whether only messages from the current session should be logged.
void addMessages(uint04 id, const Buffer< LogMessage > &messages) final override
Adds multiple log messages to the output file in a batch.
void addMessage(uint04 id, const LogMessage &message) final override
Adds a single log message to the output file.
static void WriteLogFile(LogPtr stream, const File &file)
Writes all messages from a log stream to an ascii file.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
Definition LogMessage.h:48
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A listener that receives and processes log messages and progress updates from an InfoPipe.
Definition LogStream.h:49
The core String class for the NDEVR API.
Definition String.h:95
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...