Add json extraction operator for vector
This commit is contained in:
parent
b774a6490d
commit
205b43b682
@ -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;
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
#ifndef __UTIL_VECTOR_HPP
|
||||
#define __UTIL_VECTOR_HPP
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user