liblcf
Loading...
Searching...
No Matches
writer_lcf.h
Go to the documentation of this file.
1/*
2 * This file is part of liblcf. Copyright (c) 2020 liblcf authors.
3 * https://github.com/EasyRPG/liblcf - https://easyrpg.org
4 *
5 * liblcf is Free/Libre Open Source Software, released under the MIT License.
6 * For the full copyright and license information, please view the COPYING
7 * file that was distributed with this source code.
8 */
9
10#ifndef LCF_WRITER_LCF_H
11#define LCF_WRITER_LCF_H
12
13#include <string>
14#include <vector>
15#include <iosfwd>
16#include <cstring>
17#include <memory>
18#include <cassert>
19#include <stdint.h>
20#include "lcf_options.h"
21#include "reader_util.h"
22#include "encoder.h"
23
27class LcfWriter {
28
29public:
36 LcfWriter(std::ostream& filestream, std::string encoding = "");
37
41 ~LcfWriter();
42
50 void Write(const void *ptr, size_t size, size_t nmemb);
51
57 template <class T>
58 void Write(T val);
59
66 void Write(const std::string& str);
67
73 void WriteInt(int val);
74
80 template <class T>
81 void Write(const std::vector<T>& buffer);
82
89 uint32_t Tell();
90
96 bool IsOk() const;
97
105 std::string Decode(const std::string& str_to_encode);
106
107private:
109 std::ostream& stream;
112
118 static void SwapByteOrder(int16_t &us);
119
125 static void SwapByteOrder(uint16_t &us);
126
132 static void SwapByteOrder(int32_t &us);
133
139 static void SwapByteOrder(uint32_t &ui);
140
146 static void SwapByteOrder(double &d);
147
148};
149
150#endif
void WriteInt(int val)
Definition: writer_lcf.cpp:51
Encoder encoder
Definition: writer_lcf.h:111
void Write(const std::vector< T > &buffer)
bool IsOk() const
Definition: writer_lcf.cpp:125
void Write(const void *ptr, size_t size, size_t nmemb)
Definition: writer_lcf.cpp:24
std::string Decode(const std::string &str_to_encode)
Definition: writer_lcf.cpp:129
std::ostream & stream
Definition: writer_lcf.h:109
uint32_t Tell()
Definition: writer_lcf.cpp:121
void Write(T val)
static void SwapByteOrder(int16_t &us)
Definition: writer_lcf.cpp:165