/* * Copyright information and license terms for this software can be * found in the file LICENSE that is included with the distribution */ #include #include #define epicsExportSharedSymbols #include #if EPICS_VERSION_INT>=VERSION_INT(3,15,0,1) #include "pv/json.h" namespace { void check_trailing(const std::string& line) { size_t idx = line.find_first_not_of(" \t\n\r"); if(idx==line.npos) return; // TODO: detect the end of potentially multi-line comments... // for now trailing comments not allowed throw std::runtime_error("Trailing junk"); } } // namespace namespace epics{namespace pvData{ bool yajl_parse_helper(std::istream& src, yajl_handle handle) { unsigned linenum=0; #ifndef EPICS_YAJL_VERSION bool done = false; #endif std::string line; while(std::getline(src, line)) { linenum++; #ifndef EPICS_YAJL_VERSION if(done) { check_trailing(line); continue; } #endif yajl_status sts = yajl_parse(handle, (const unsigned char*)line.c_str(), line.size()); switch(sts) { case yajl_status_ok: { size_t consumed = yajl_get_bytes_consumed(handle); if(consumed