static void format_json_number(output_data &out, const ndt::type &dt, const char *arrmeta, const char *data) { stringstream ss; dt.print_data(ss, arrmeta, data); out.write(ss.str()); }
static void raise_string_cast_overflow_error(const ndt::type& dst_tp, const ndt::type& string_tp, const char *metadata, const char *data) { stringstream ss; ss << "overflow converting string "; string_tp.print_data(ss, metadata, data); ss << " to " << dst_tp; throw runtime_error(ss.str()); }
inline void raise_string_cast_overflow_error(const ndt::type &dst_tp, const ndt::type &string_tp, const char *arrmeta, const char *data) { std::stringstream ss; ss << "overflow converting string "; string_tp.print_data(ss, arrmeta, data); ss << " to " << dst_tp; throw std::overflow_error(ss.str()); }
inline void raise_string_cast_error(const ndt::type &dst_tp, const ndt::type &string_tp, const char *arrmeta, const char *data) { std::stringstream ss; ss << "cannot cast string "; string_tp.print_data(ss, arrmeta, data); ss << " to " << dst_tp; throw std::invalid_argument(ss.str()); }
static void format_json_type(output_data &out, const ndt::type &dt, const char *arrmeta, const char *data) { switch (dt.get_type_id()) { case type_type_id: { stringstream ss; dt.print_data(ss, arrmeta, data); std::string s = ss.str(); format_json_encoded_string(out, s.data(), s.data() + s.size(), string_encoding_ascii); break; } default: { stringstream ss; ss << "Formatting dynd type \"" << dt << "\" as JSON is not implemented yet"; throw runtime_error(ss.str()); } } }