Program Listing for File json.h

Return to documentation for file (src/json/pv/json.h)

/*
 * Copyright information and license terms for this software can be
 * found in the file LICENSE that is included with the distribution
 */
#ifndef PV_JSON_H
#define PV_JSON_H

#include <istream>
#include <ostream>
#include <string>
#include <map>

#include <pv/pvdVersion.h>
#include <pv/pvData.h>

#ifdef epicsExportSharedSymbols
#   define pvjson_epicsExportSharedSymbols
#   undef epicsExportSharedSymbols
#endif

#include <yajl_parse.h>

#ifdef pvjson_epicsExportSharedSymbols
#   define epicsExportSharedSymbols
#   include "shareLib.h"
#endif

#include <shareLib.h>

namespace epics{namespace pvData{

class BitSet;

struct epicsShareClass JSONPrintOptions
{
    bool multiLine;
    bool ignoreUnprintable;
    unsigned indent;
    bool json5;
    JSONPrintOptions();
};

epicsShareFunc
void printJSON(std::ostream& strm,
               const PVStructure& val,
               const BitSet& mask,
               const JSONPrintOptions& opts = JSONPrintOptions());

epicsShareFunc
void printJSON(std::ostream& strm,
               const PVField& val,
               const JSONPrintOptions& opts = JSONPrintOptions());

// To be deprecated in favor of previous form
FORCE_INLINE
void printJSON(std::ostream& strm,
               const PVField::const_shared_pointer& val,
               const JSONPrintOptions& opts = JSONPrintOptions())
{
    printJSON(strm, *val, opts);
}

epicsShareFunc
PVStructure::shared_pointer parseJSON(std::istream& strm);

epicsShareFunc
void parseJSON(std::istream& strm,
               PVField& dest,
               BitSet *assigned=0);

// To be deprecated in favor of previous form
FORCE_INLINE
void parseJSON(std::istream& strm,
               const PVField::shared_pointer& dest,
               BitSet *assigned=0)
{
    parseJSON(strm, *dest, assigned);
}


epicsShareFunc
bool yajl_parse_helper(std::istream& src,
                       yajl_handle handle);

namespace yajl {
// undef implies API version 0
#ifndef EPICS_YAJL_VERSION
typedef long integer_arg;
typedef unsigned size_arg;
#else
typedef long long integer_arg;
typedef size_t size_arg;
#endif
} // namespace epics::pvData::yajl

}} // namespace epics::pvData

#endif // PV_JSON_H