9 #define epicsExportSharedSymbols 16 void check_trailing(
const std::string&
line)
18 size_t idx = line.find_first_not_of(
" \t\n\r");
19 if(idx==line.npos)
return;
22 throw std::runtime_error(
"Trailing junk");
27 namespace epics{
namespace pvData{
33 #ifndef EPICS_YAJL_VERSION 38 while(std::getline(src, line)) {
41 #ifndef EPICS_YAJL_VERSION 54 if(consumed<line.size()) {
55 check_trailing(line.substr(consumed));
58 #ifndef EPICS_YAJL_VERSION 65 #ifndef EPICS_YAJL_VERSION 66 case yajl_status_insufficient_data:
72 std::ostringstream msg;
73 unsigned char *raw =
yajl_get_error(handle, 1, (
const unsigned char*)line.c_str(), line.size());
75 msg<<
"Unknown error on line "<<linenum;
78 msg<<
"Error on line "<<linenum<<
" : "<<(
const char*)raw;
85 throw std::runtime_error(msg.str());
90 if(!src.eof() || src.bad()) {
91 std::ostringstream msg;
92 msg<<
"I/O error after line "<<linenum;
93 throw std::runtime_error(msg.str());
95 #ifndef EPICS_YAJL_VERSION 97 switch(yajl_parse_complete(handle)) {
106 #ifndef EPICS_YAJL_VERSION 107 case yajl_status_insufficient_data:
108 throw std::runtime_error(
"unexpected end of input");
111 throw std::runtime_error(
"Error while completing parsing");
unsigned char * yajl_get_error(yajl_handle hand, int verbose, const unsigned char *jsonText, size_t jsonTextLen)
TODO only here because of the Lockable.
void yajl_free_error(yajl_handle hand, unsigned char *str)
yajl_status yajl_parse(yajl_handle hand, const unsigned char *jsonText, size_t jsonTextLen)
bool yajl_parse_helper(std::istream &src, yajl_handle handle)
yajl_status yajl_complete_parse(yajl_handle hand)
size_t yajl_get_bytes_consumed(yajl_handle hand)