bux API Reference 1.9.0
Static library of whatever are seen required in general purpose but not directly supported from Modern C++. Or whatever reusable originated from my side projects.
Loading...
Searching...
No Matches
MemOut.h
Go to the documentation of this file.
1#pragma once
2
3#include <ostream> // std::basic_ostream<>
4#include <span> // std::span<>
5
6namespace bux {
7
8//
9// Types
10//
11template <class _CharT, class _Traits>
13{
14 // Data
15 struct C_OMemBuf: std::basic_streambuf<_CharT,_Traits>
16 {
17 C_OMemBuf(_CharT *buffer, size_t size)
18 { this->setp(buffer, buffer+size); }
19 C_OMemBuf(std::span<_CharT> buffer)
20 { this->setp(buffer.begin(), buffer.end()); }
22
23 // Ctor
24 C_OMemBufAsMemberT(_CharT *buffer, size_t size): m_Buffer(buffer, size) {}
25 C_OMemBufAsMemberT(std::span<_CharT> buffer): m_Buffer(buffer) {}
26};
27
28template <class _CharT, class _Traits =std::char_traits<_CharT>>
30 private C_OMemBufAsMemberT<_CharT,_Traits>,
31 public std::basic_ostream<_CharT,_Traits> // Inheritance order matters
32{
33public:
34
35 // Ctor
36 C_OMemStreamT(_CharT *buffer, size_t size):
37 C_OMemBufAsMemberT<_CharT,_Traits>(buffer, size),
38 std::basic_ostream<_CharT,_Traits>(&this->m_Buffer)
39 {}
40 C_OMemStreamT(std::span<_CharT> buffer):
41 C_OMemBufAsMemberT<_CharT,_Traits>(buffer),
42 std::basic_ostream<_CharT,_Traits>(&this->m_Buffer)
43 {}
44};
46
47} // namespace bux
C_OMemStreamT(_CharT *buffer, size_t size)
Definition MemOut.h:36
C_OMemStreamT(std::span< _CharT > buffer)
Definition MemOut.h:40
THE common namespace of bux library.
Definition AtomiX.cpp:3
C_OMemBuf(std::span< _CharT > buffer)
Definition MemOut.h:19
C_OMemBuf(_CharT *buffer, size_t size)
Definition MemOut.h:17
C_OMemBufAsMemberT(std::span< _CharT > buffer)
Definition MemOut.h:25
C_OMemBufAsMemberT(_CharT *buffer, size_t size)
Definition MemOut.h:24
bux::C_OMemBufAsMemberT::C_OMemBuf m_Buffer