Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this user
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
golwalkars
/
7166CEM
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Projects
0
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Projects
Security
Insights
Files
a1d716f
CMakeFiles
include
can_wrap.h
can_wrap.hpp
captureio.h
catch.hpp
signal.h
lib
src
CMakeLists.txt
Makefile
README.md
candata.dbc
candump.log
Breadcrumbs
7166CEM
/
include
/
captureio.h
Blame
Blame
Latest commit
History
History
88 lines (75 loc) · 1.77 KB
Breadcrumbs
7166CEM
/
include
/
captureio.h
Top
File metadata and controls
Code
Blame
88 lines (75 loc) · 1.77 KB
Raw
#ifndef CAPTUREIO_H #define CAPTUREIO_H #include <iostream> #include <sstream> #include <string> #include <memory> #include <cxxabi.h> class CaptureStream: public std::ostringstream { private: std::ostream& stream; std::streambuf* rdbuf; public: CaptureStream( std::ostream &_stream ) : stream(_stream), rdbuf(_stream.rdbuf()) {} void capture() { stream.rdbuf( std::ostringstream::rdbuf() ); } void release() { stream.rdbuf( rdbuf ); } virtual ~CaptureStream() {} }; class InjectStream/*: public std::ostream*/ { private: std::stringstream ss; std::istream& stream; std::streambuf* rdbuf; public: InjectStream( std::istream& _stream ) : stream(_stream), rdbuf(_stream.rdbuf()) {} void capture() { stream.rdbuf( ss.rdbuf() ); } void release() { stream.rdbuf( rdbuf ); } template<typename T> InjectStream& operator<<( T const& rhs ) { ss << rhs; return *this; } }; template <class T> std::string type_name() { // credit to https://urldefense.com/v3/__https://stackoverflow.com/a/20170989__;!!K7l7YuZ3_aFnun0eduI!nJBCoLL2_SI1ZqRonPeatpXNF5-Oc6CjKJV1nZRVE5pWYFRudcWRBfu4AeUdqRy5eR2mxBeu2bFBNqoJadHDYomRme5lLwvPmw$ typedef typename std::remove_reference<T>::type TR; std::unique_ptr<char, void(*)(void*)> own ( #ifndef _MSC_VER abi::__cxa_demangle(typeid(TR).name(), nullptr, nullptr, nullptr), #else nullptr, #endif std::free ); std::string r = own != nullptr ? own.get() : typeid(TR).name(); if (std::is_const<TR>::value) r += " const"; if (std::is_volatile<TR>::value) r += " volatile"; if (std::is_lvalue_reference<T>::value) r += "&"; else if (std::is_rvalue_reference<T>::value) r += "&&"; return r; } #endif
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
You can’t perform that action at this time.