| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | #pragma once | 
| 2 |  |  |  |  |  |  | #include "base.h" | 
| 3 |  |  |  |  |  |  | #include "../Hash.h" | 
| 4 |  |  |  |  |  |  | #include "../Array.h" | 
| 5 |  |  |  |  |  |  | #include "../Simple.h" | 
| 6 |  |  |  |  |  |  | #include | 
| 7 |  |  |  |  |  |  | #include | 
| 8 |  |  |  |  |  |  | #include | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | namespace xs { | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | namespace typemap { namespace containers { | 
| 13 |  |  |  |  |  |  | inline const panda::string& to_key (const panda::string& value) { return value; } | 
| 14 |  |  |  |  |  |  | inline panda::string_view   to_key (const std::string& value)   { return panda::string_view(value.data(), value.size()); } | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | template | 
| 17 |  |  |  |  |  |  | panda::string to_key (T&& value) { return panda::to_string(std::forward(value)); } | 
| 18 |  |  |  |  |  |  | }} | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | template  struct VectorTypemap : TypemapBase> { | 
| 21 | 7 |  |  |  |  |  | static Sv out(const std::vector& data, const Sv& = {}){ | 
| 22 | 14 | 50 |  |  |  |  | auto out = Array::create(data.size()); | 
|  |  | 50 |  |  |  |  |  | 
| 23 | 75 | 100 |  |  |  |  | for(const auto& i : data){ | 
|  |  | 100 |  |  |  |  |  | 
| 24 | 68 | 50 |  |  |  |  | out.push(xs::out(i)); | 
|  |  | 50 |  |  |  |  |  | 
|  |  | 50 |  |  |  |  |  | 
|  |  | 50 |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | } | 
| 26 | 14 | 50 |  |  |  |  | return Ref::create(out); | 
|  |  | 50 |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | static std::vector in (Array arg){ | 
| 30 |  |  |  |  |  |  | std::vector out; | 
| 31 |  |  |  |  |  |  | out.reserve(arg.size()); | 
| 32 |  |  |  |  |  |  | for(const auto& i : arg){ | 
| 33 |  |  |  |  |  |  | out.emplace_back(xs::in(i)); | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  | return out; | 
| 36 |  |  |  |  |  |  | } | 
| 37 |  |  |  |  |  |  | }; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | template  struct Typemap> : VectorTypemap {}; | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | template  struct Typemap, std::map> : TypemapBase> { | 
| 42 |  |  |  |  |  |  | static Sv out (const std::map& data, const Sv& = {}) { | 
| 43 |  |  |  |  |  |  | auto out = Hash::create(data.size()); | 
| 44 |  |  |  |  |  |  | for(const auto& i : data){ | 
| 45 |  |  |  |  |  |  | auto key = typemap::containers::to_key(i.first); | 
| 46 |  |  |  |  |  |  | out.store(key, xs::out(i.second)); | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  | return Ref::create(out); | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | static std::map in (Hash arg) { | 
| 52 |  |  |  |  |  |  | std::map out; | 
| 53 |  |  |  |  |  |  | for (const auto& element : arg){ | 
| 54 |  |  |  |  |  |  | K key = xs::in(Simple(element.key())); | 
| 55 |  |  |  |  |  |  | V value = xs::in(element.value()); | 
| 56 |  |  |  |  |  |  | out.emplace(key, value); | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  | return out; | 
| 59 |  |  |  |  |  |  | } | 
| 60 |  |  |  |  |  |  | }; | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | template  struct Typemap, std::unordered_map> : TypemapBase> { | 
| 63 |  |  |  |  |  |  | static Sv out (const std::unordered_map& data, const Sv& = {}) { | 
| 64 |  |  |  |  |  |  | auto out = Hash::create(data.size()); | 
| 65 |  |  |  |  |  |  | for(const auto& i : data){ | 
| 66 |  |  |  |  |  |  | auto key = typemap::containers::to_key(i.first); | 
| 67 |  |  |  |  |  |  | out.store(key, xs::out(i.second)); | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  | return Ref::create(out); | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | static std::unordered_map in (Hash arg) { | 
| 73 |  |  |  |  |  |  | std::unordered_map out; | 
| 74 |  |  |  |  |  |  | for (const auto& element : arg){ | 
| 75 |  |  |  |  |  |  | K key = xs::in(Simple(element.key())); | 
| 76 |  |  |  |  |  |  | V value = xs::in(element.value()); | 
| 77 |  |  |  |  |  |  | out.emplace(key, value); | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  | return out; | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | }; | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | } |