Code quality: Large clean-up of the codebase and especially of the include/ folder
This commit is contained in:
33
lib/model/json/to_array.hpp
Normal file
33
lib/model/json/to_array.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef ISAAC_MODEL_TOOLS_HPP
|
||||
#define ISAAC_MODEL_TOOLS_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
namespace isaac
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
template<class T>
|
||||
std::vector<T> to_int_array(rapidjson::Value const & a)
|
||||
{
|
||||
size_t N = a.Size();
|
||||
std::vector<T> res(N);
|
||||
for(size_t i = 0 ; i < N ; ++i) res[i] = a[i].GetInt();
|
||||
return res;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::vector<T> to_float_array(rapidjson::Value const & a)
|
||||
{
|
||||
size_t N = a.Size();
|
||||
std::vector<T> res(N);
|
||||
for(size_t i = 0 ; i < N ; ++i) res[i] = a[i].GetDouble();
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user