1 | // CODYlib -*- mode:c++ -*- |
---|---|
2 | // Copyright (C) 2020 Nathan Sidwell, nathan@acm.org |
3 | // License: Apache v2.0 |
4 | |
5 | // Cody |
6 | #include "internal.hh" |
7 | |
8 | namespace Cody { |
9 | |
10 | void Packet::Destroy () |
11 | { |
12 | switch (cat) |
13 | { |
14 | case STRING: |
15 | // Silly scope destructor name rules |
16 | using S = std::string; |
17 | string.~S (); |
18 | break; |
19 | |
20 | case VECTOR: |
21 | using V = std::vector<std::string>; |
22 | vector.~V (); |
23 | break; |
24 | |
25 | default:; |
26 | } |
27 | } |
28 | |
29 | void Packet::Create (Packet &&t) |
30 | { |
31 | cat = t.cat; |
32 | code = t.code; |
33 | request = t.request; |
34 | switch (cat) |
35 | { |
36 | case STRING: |
37 | new (&string) std::string (std::move (t.string)); |
38 | break; |
39 | |
40 | case VECTOR: |
41 | new (&vector) std::vector<std::string> (std::move (t.vector)); |
42 | break; |
43 | |
44 | default: |
45 | integer = t.integer; |
46 | break; |
47 | } |
48 | } |
49 | |
50 | } |
51 |