DirectZ
Loading...
Searching...
No Matches
memory_stream.hpp
Go to the documentation of this file.
1#pragma once
2#include <iostream>
3#include "memory_buffer.hpp"
4
9class memory_stream : public std::iostream {
10public:
11 memory_stream(std::ios_base::openmode ios) : std::iostream(&m_buf) {}
12
13 memory_stream(const std::string& s) : std::iostream(&m_buf) {
14 m_buf.str(s);
15 }
16
17 std::string str() {
18 return m_buf.str();
19 }
20
21 void str(const std::string& s) {
22 m_buf.str(s);
23 }
24
25 void mod(std::ios_base::openmode ios)
26 {
27 if (ios & std::ios::trunc)
28 {
29 m_buf.str("");
30 }
31 }
32
33private:
34 memory_buffer m_buf;
35};
A custom stream buffer that uses a dynamically resizable std::vector<char> as its underlying storage.
Definition memory_buffer.hpp:16
void str(const std::string &s)
Definition memory_stream.hpp:21
std::string str()
Definition memory_stream.hpp:17
memory_stream(std::ios_base::openmode ios)
Definition memory_stream.hpp:11
void mod(std::ios_base::openmode ios)
Definition memory_stream.hpp:25
memory_stream(const std::string &s)
Definition memory_stream.hpp:13