diff --git a/vector.cpp b/vector.cpp index 049a7433..fcb1a0b4 100644 --- a/vector.cpp +++ b/vector.cpp @@ -181,3 +181,12 @@ operator<< (std::ostream &os, const util::vector &v) { return os; } + +const json::node& +operator>> (const json::node &node, util::vector &v) { + v.x = node[0].to_number (); + v.y = node[1].to_number (); + v.z = node[2].to_number (); + + return node; +} diff --git a/vector.hpp b/vector.hpp index b61fce2b..e07ac756 100644 --- a/vector.hpp +++ b/vector.hpp @@ -20,6 +20,8 @@ #ifndef __UTIL_VECTOR_HPP #define __UTIL_VECTOR_HPP +#include "json.hpp" + #include namespace util { @@ -58,5 +60,6 @@ namespace util { util::vector operator* (double, const util::vector&); std::ostream& operator<< (std::ostream&, const util::vector&); +const json::node& operator>> (const json::node&, util::vector&); #endif