CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
MetaSignature.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "TypeName.hpp"
11#include "TypeTraits.hpp"
12
16
17#include <sstream>
18
19namespace CeresEngine {
20
21 template<typename T, typename CharT = char, typename Traits = std::char_traits<CharT>> class PrefixOutputStreamIterator {
22 private:
23 using StreamType = std::basic_ostream<CharT, Traits>;
24 using StringViewType = std::basic_string_view<CharT, Traits>;
25
28 bool first = true;
29
30 public:
32 using traits_type = Traits;
33 using ostreamType = std::basic_ostream<CharT, Traits>;
34
36
39 PrefixOutputStreamIterator& operator++(int) { return *this; }
40
41 StreamType& stream() { return mStream; }
42
44 if(first) {
45 mStream << value;
46 first = false;
47 } else {
48 mStream << mPrefix << value;
49 }
50
51 return *this;
52 }
53 };
54
55 template<typename... Args> struct MetaSignature {
56 static String get(const StringView name) {
59 os << name << '(';
60 (it = ... = getTypeName<Args>());
61 os << ')';
62 return os.str();
63 }
64 };
65
66 template<typename... Args> struct MetaSignature<MPL::TypeList<Args...>> : MetaSignature<Args...> {};
67
68 template<typename F> struct f_signature : MetaSignature<typename function_traits<typename function_traits<F>::uniformSignature>::args> {};
69
70} //namespace CeresEngine
Definition MetaSignature.hpp:21
PrefixOutputStreamIterator & operator*()
Definition MetaSignature.hpp:37
PrefixOutputStreamIterator & operator++()
Definition MetaSignature.hpp:38
StringViewType mPrefix
Definition MetaSignature.hpp:27
CharT char_type
Definition MetaSignature.hpp:31
Traits traits_type
Definition MetaSignature.hpp:32
StreamType & stream()
Definition MetaSignature.hpp:41
PrefixOutputStreamIterator(StreamType &stream, StringViewType prefix="")
Definition MetaSignature.hpp:35
std::basic_string_view< CharT, Traits > StringViewType
Definition MetaSignature.hpp:24
PrefixOutputStreamIterator & operator++(int)
Definition MetaSignature.hpp:39
std::basic_ostream< CharT, Traits > ostreamType
Definition MetaSignature.hpp:33
bool first
Definition MetaSignature.hpp:28
std::basic_ostream< CharT, Traits > StreamType
Definition MetaSignature.hpp:23
StreamType & mStream
Definition MetaSignature.hpp:26
PrefixOutputStreamIterator & operator=(T const &value)
Definition MetaSignature.hpp:43
Definition Application.hpp:19
BasicStringStream< char > StringStream
Wide string stream used for primarily for constructing narrow strings.
Definition StringStream.hpp:32
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition MetaSignature.hpp:55
static String get(const StringView name)
Definition MetaSignature.hpp:56
Definition MetaSignature.hpp:68