forked from CobaltFusion/DebugViewPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceType.cpp
More file actions
84 lines (71 loc) · 1.9 KB
/
Copy pathSourceType.cpp
File metadata and controls
84 lines (71 loc) · 1.9 KB
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
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2013.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <stdexcept>
#include <cassert>
#include "DebugViewppLib/SourceType.h"
namespace fusion {
namespace debugviewpp {
SourceInfo::SourceInfo(const std::wstring& description, SourceType::type type) :
enabled(false),
description(description),
type(type),
port(0)
{
}
SourceInfo::SourceInfo(const std::wstring& description, SourceType::type type, const std::wstring& address, int port) :
enabled(false),
description(description),
type(type),
address(address),
port(port)
{
}
int SourceTypeToInt(SourceType::type value)
{
#define SOURCE_TYPE(en, id, name) \
case SourceType::en: return id;
switch (value)
{
SOURCE_TYPES()
default: assert(!"Unexpected SourceType"); break;
}
#undef SOURCE_TYPE
throw std::invalid_argument("bad SourceType!");
}
SourceType::type IntToSourceType(int value)
{
#define SOURCE_TYPE(en, id, name) \
case id: return SourceType::en;
switch (value)
{
SOURCE_TYPES()
default: assert(!"Unexpected SourceType"); break;
}
#undef SOURCE_TYPE
throw std::invalid_argument("bad SourceType!");
}
std::string SourceTypeToString(SourceType::type value)
{
#define SOURCE_TYPE(en, id, name) \
case SourceType::en: return name;
switch (value)
{
SOURCE_TYPES()
default: assert(!"Unexpected SourceType"); break;
}
#undef SOURCE_TYPE
throw std::invalid_argument("bad SourceType!");
}
SourceType::type StringToSourceType(const std::string& s)
{
#define SOURCE_TYPE(en, id, name) \
if (s == name) \
return SourceType::en;
SOURCE_TYPES()
#undef SOURCE_TYPE
throw std::invalid_argument("bad SourceType!");
}
} // namespace debugviewpp
} // namespace fusion