1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| #pragma once
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
template <class TChar>
struct header_trait
{
using Type = TChar;
using String = std::basic_string<TChar>;
using StringStream = std::basic_stringstream<TChar>;
using oStream = std::basic_ostream<TChar>;
};
template <class headerTraits>
class basic_header_t
{
public:
using TString = typename headerTraits::String;
using TStream = typename headerTraits::oStream;
private:
TString message_;
public:
void set_string(const TString& s) { message_ = s; }
TStream& operator<<(TStream& os, const header_t& h)
{
os << "Message: " << h.message_.c_str() << std::endl;
return os;
}
};
#if UNICODE
using header_t = basic_header_t<header_trait<wchar_t>>;
#else
using header_t = basic_header_t<header_trait<char>>;
#endif |
Partager