-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaptest.cpp
75 lines (55 loc) · 1.5 KB
/
maptest.cpp
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
#include "tpwmap.hpp"
void
tuple_test()
{
TPW::Connection conn("localhost", 3301);
using TesterMap =
TPW::Map<uint64_t, std::tuple<std::string, uint64_t> >;
TesterMap tester_map(conn, "tester");
TesterMap::mapped_type tpl = tester_map[5];
std::cout << std::get<0>(tpl) << ':' << std::get<1>(tpl) << std::endl;
tester_map[5] = std::make_tuple<std::string, uint64_t>("Diameter",
std::get<1>(tpl) * 2);
tpl = static_cast<decltype(tester_map)::mapped_type>(tester_map[5]);
std::cout << std::get<0>(tpl) << ':' << std::get<1>(tpl) << std::endl;
std::cout << "There are " << tester_map.size() <<
" elements in the container" << std::endl;
}
struct TesterObject
{
std::string property;
uint64_t value;
};
inline TPW::ITStream&
operator>>(TPW::ITStream& in, TesterObject& obj)
{
in >> obj.property >> obj.value;
}
inline TPW::OTStream&
operator<<(TPW::OTStream& out, const TesterObject& obj)
{
out << obj.property << obj.value;
}
inline std::ostream&
operator<<(std::ostream& out, const TesterObject& obj)
{
out << "property:" << obj.property << ", value:" << obj.value << std::endl;
}
void
object_test()
{
TPW::Connection conn("localhost", 3301);
using TesterMap =
TPW::Map<uint64_t, TesterObject>;
TesterMap tester_map(conn, "tester");
TesterObject tester_object = tester_map[5];
std::cout << tester_object;
tester_map[5] = TesterObject{"Diameter", tester_object.value * 2};
std::cout << tester_map[5];
}
int
main(int, char**)
{
tuple_test();
object_test();
}