// // Copyright (C) 2011-15 DyND Developers // BSD 2-Clause License, see LICENSE.txt // #pragma once #include #include #include #include #include #include #include #include #include #include namespace dynd { namespace nd { namespace json { extern DYND_API struct DYND_API parse : declfunc { array operator()(const ndt::type &ret_tp, const char *begin, const char *end) { skip_whitespace(begin, end); ndt::type dst_tp2 = ret_tp; char *args_data[2] = {reinterpret_cast(&begin), reinterpret_cast(&end)}; nd::array ret = get()->call(dst_tp2, 0, nullptr, nullptr, args_data, 0, nullptr, std::map()); skip_whitespace(begin, end); if (begin != end) { throw json_parse_error(begin, "unexpected trailing JSON text", ret_tp); } return ret; } array operator()(const ndt::type &ret_tp, const char *begin) { return (*this)(ret_tp, begin, begin + std::strlen(begin)); } array operator()(const ndt::type &ret_tp, const std::string &s) { return (*this)(ret_tp, s.c_str(), s.c_str() + s.size()); } static callable make(); static callable &get(); } parse; } // namespace dynd::nd::json } // namespace dynd::nd } // namespace dynd