diff options
Diffstat (limited to 'libcody/packet.cc')
-rw-r--r-- | libcody/packet.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/libcody/packet.cc b/libcody/packet.cc new file mode 100644 index 0000000..65dc8f4 --- /dev/null +++ b/libcody/packet.cc @@ -0,0 +1,50 @@ +// CODYlib -*- mode:c++ -*- +// Copyright (C) 2020 Nathan Sidwell, nathan@acm.org +// License: Apache v2.0 + +// Cody +#include "internal.hh" + +namespace Cody { + +void Packet::Destroy () +{ + switch (cat) + { + case STRING: + // Silly scope destructor name rules + using S = std::string; + string.~S (); + break; + + case VECTOR: + using V = std::vector<std::string>; + vector.~V (); + break; + + default:; + } +} + +void Packet::Create (Packet &&t) +{ + cat = t.cat; + code = t.code; + request = t.request; + switch (cat) + { + case STRING: + new (&string) std::string (std::move (t.string)); + break; + + case VECTOR: + new (&vector) std::vector<std::string> (std::move (t.vector)); + break; + + default: + integer = t.integer; + break; + } +} + +} |