Add json extraction operator for vector

This commit is contained in:
Danny Robson 2011-10-29 21:17:48 +11:00
parent b774a6490d
commit 205b43b682
2 changed files with 12 additions and 0 deletions

View File

@ -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;
}

View File

@ -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