handle yajl 2.1.0 API changes

This commit is contained in:
Michael Davidsaver
2017-10-31 17:45:40 -05:00
parent e247a2c4eb
commit 51cbe538e8
5 changed files with 79 additions and 25 deletions

View File

@@ -17,6 +17,8 @@
#include "pv/json.h"
namespace pvd = epics::pvData;
using pvd::yajl::integer_arg;
using pvd::yajl::size_arg;
namespace {
struct context {
@@ -148,7 +150,7 @@ int jtree_boolean(void * ctx, int boolVal)
}CATCH()
}
int jtree_integer(void * ctx, long integerVal)
int jtree_integer(void * ctx, integer_arg integerVal)
{
TRY {
valueAssign<pvd::PVLong, pvd::PVLongArray>(self, integerVal);
@@ -165,7 +167,7 @@ int jtree_double(void * ctx, double doubleVal)
}
int jtree_string(void * ctx, const unsigned char * stringVal,
unsigned int stringLen)
size_arg stringLen)
{
TRY {
std::string val((const char*)stringVal, stringLen);
@@ -200,7 +202,7 @@ int jtree_start_map(void * ctx)
}
int jtree_map_key(void * ctx, const unsigned char * key,
unsigned int stringLen)
size_arg stringLen)
{
TRY {
assert(!self->stack.empty());
@@ -309,16 +311,25 @@ void parseJSON(std::istream& strm,
const PVField::shared_pointer& dest,
BitSet *assigned)
{
#ifndef EPICS_YAJL_VERSION
yajl_parser_config conf;
memset(&conf, 0, sizeof(conf));
conf.allowComments = 1;
conf.checkUTF8 = 1;
#endif
context ctxt(dest, assigned);
#ifndef EPICS_YAJL_VERSION
handler handle(yajl_alloc(&jtree_cbs, &conf, NULL, &ctxt));
#else
handler handle(yajl_alloc(&jtree_cbs, NULL, &ctxt));
if(!yajl_parse_helper(strm, handle, conf))
yajl_config(handle, yajl_allow_comments, 1);
#endif
if(!yajl_parse_helper(strm, handle))
throw std::runtime_error(ctxt.msg);
if(!ctxt.stack.empty())