LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
utilitytypes.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <utility>
12#include <QDataStream>
13#include <QByteArray>
14
15namespace LC::Util::oral
16{
17 template<typename T>
19 {
20 using BaseType = QByteArray;
21
23
24 operator T () const &
25 {
26 return Val_;
27 }
28
29 operator T&& () &&
30 {
31 return std::move (Val_);
32 }
33
34 AsDataStream () = default;
35 AsDataStream (const AsDataStream&) = default;
37
40
41 template<typename... Args>
42 AsDataStream (Args&&... args)
43 : Val_ { std::forward<Args> (args)... }
44 {
45 }
46
47 template<typename U>
49 {
50 Val_ = std::forward<U> (val);
51 return *this;
52 }
53
55 {
56 QByteArray ba;
57 {
58 QDataStream out { &ba, QIODevice::WriteOnly };
59 out << Val_;
60 }
61 return ba;
62 }
63
64 static AsDataStream FromBaseType (const QByteArray& ba)
65 {
66 QDataStream in { ba };
67
68 AsDataStream res;
69 in >> res.Val_;
70 return res;
71 }
72 };
73
74}
STL namespace.
AsDataStream(const AsDataStream &)=default
static AsDataStream FromBaseType(const QByteArray &ba)
AsDataStream(AsDataStream &&)=default
AsDataStream(Args &&... args)
AsDataStream & operator=(const AsDataStream &)=default
BaseType ToBaseType() const