MiKTeX 26.5-next
A scalable TeX distribution
Loading...
Searching...
No Matches
StreamWriter.h
1/* miktex/Core/StreamWriter.h: -*- C++ -*-
2
3 Copyright (C) 1996-2018 Christian Schenk
4
5 This file is part of the MiKTeX Core Library.
6
7 The MiKTeX Core Library is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2, or
10 (at your option) any later version.
11
12 The MiKTeX Core Library is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with the MiKTeX Core Library; if not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#pragma once
23
24#if !defined(ACBE4B57EA604A0289F0EED42F80F8B1)
25#define ACBE4B57EA604A0289F0EED42F80F8B1
26
27#include <miktex/Core/config.h>
28#include <miktex/Util/PathName>
29
30#include <string>
31
32#include "FileStream.h"
33
34MIKTEX_CORE_BEGIN_NAMESPACE;
35
36class StreamWriter
37{
38public:
39 StreamWriter() = default;
40
41public:
42 StreamWriter(const StreamWriter& other) = delete;
43
44public:
45 StreamWriter operator=(const StreamWriter& other) = delete;
46
47public:
48 StreamWriter(StreamWriter&& other) = delete;
49
50public:
51 StreamWriter operator=(StreamWriter&& other) = delete;
52
53public:
54 virtual MIKTEXCOREEXPORT MIKTEXTHISCALL ~StreamWriter() noexcept;
55
56public:
57 MIKTEXCOREEXPORT MIKTEXTHISCALL StreamWriter(const MiKTeX::Util::PathName& path);
58
59public:
60 bool IsOpen() const
61 {
62 return stream.GetFile() != nullptr;
63 }
64
65public:
66 void Flush()
67 {
68 fflush(stream.GetFile());
69 }
70
71public:
72 MIKTEXCORETHISAPI(void) Write(char ch);
73
74public:
75 MIKTEXCORETHISAPI(void) Write(const std::string& line);
76
77public:
78 MIKTEXCORETHISAPI(void) WriteLine(const std::string& line);
79
80public:
81 MIKTEXCORETHISAPI(void) WriteLine();
82
83public:
84 MIKTEXCORETHISAPI(void) Close();
85
86private:
87 FileStream stream;
88};
89
90MIKTEX_CORE_END_NAMESPACE;
91
92#endif
Instances of this class can be used to store path names.
Definition PathName.h:64