' PBXB64 JSON core constants and lightweight runtime types
' JSON itself is protocol/data-format support, not a Windows DLL.
#IF NOT %DEF(PBX_JSON_CORE_PBI)
#DEFINE PBX_JSON_CORE_PBI
#include once "win_types.inc"

' JSON value kinds
CONST PBX_JSON_TYPE_INVALID = 0
CONST PBX_JSON_TYPE_NULL = 1
CONST PBX_JSON_TYPE_FALSE = 2
CONST PBX_JSON_TYPE_TRUE = 3
CONST PBX_JSON_TYPE_NUMBER = 4
CONST PBX_JSON_TYPE_STRING = 5
CONST PBX_JSON_TYPE_ARRAY = 6
CONST PBX_JSON_TYPE_OBJECT = 7

' Parser flags
CONST PBX_JSON_PARSE_DEFAULT = 0
CONST PBX_JSON_PARSE_ALLOW_COMMENTS = &H00000001
CONST PBX_JSON_PARSE_ALLOW_TRAILING_COMMA = &H00000002
CONST PBX_JSON_PARSE_ALLOW_SINGLE_QUOTES = &H00000004
CONST PBX_JSON_PARSE_ALLOW_HEX_NUMBERS = &H00000008
CONST PBX_JSON_PARSE_ALLOW_INF_NAN = &H00000010
CONST PBX_JSON_PARSE_REQUIRE_TOP_OBJECT = &H00000100
CONST PBX_JSON_PARSE_REQUIRE_TOP_ARRAY = &H00000200
CONST PBX_JSON_PARSE_UTF8_STRICT = &H00001000
CONST PBX_JSON_PARSE_MAX_DEPTH_DEFAULT = 512

' Writer flags
CONST PBX_JSON_WRITE_COMPACT = 0
CONST PBX_JSON_WRITE_PRETTY = &H00000001
CONST PBX_JSON_WRITE_SORT_KEYS = &H00000002
CONST PBX_JSON_WRITE_ESCAPE_SLASH = &H00000004
CONST PBX_JSON_WRITE_ENSURE_ASCII = &H00000008
CONST PBX_JSON_WRITE_CANONICAL = &H00000010

' Error/result codes
CONST PBX_JSON_OK = 0
CONST PBX_JSON_ERR_GENERIC = -1
CONST PBX_JSON_ERR_OUT_OF_MEMORY = -2
CONST PBX_JSON_ERR_INVALID_HANDLE = -3
CONST PBX_JSON_ERR_INVALID_ARG = -4
CONST PBX_JSON_ERR_SYNTAX = -10
CONST PBX_JSON_ERR_UNEXPECTED_EOF = -11
CONST PBX_JSON_ERR_BAD_ESCAPE = -12
CONST PBX_JSON_ERR_BAD_NUMBER = -13
CONST PBX_JSON_ERR_DEPTH_LIMIT = -14
CONST PBX_JSON_ERR_DUPLICATE_KEY = -15
CONST PBX_JSON_ERR_PATH_NOT_FOUND = -30
CONST PBX_JSON_ERR_TYPE_MISMATCH = -31
CONST PBX_JSON_ERR_INDEX_RANGE = -32

' Common MIME/media types and encodings
CONST PBX_MIME_APPLICATION_JSON = "application/json"
CONST PBX_MIME_APPLICATION_PROBLEM_JSON = "application/problem+json"
CONST PBX_MIME_APPLICATION_JSON_PATCH = "application/json-patch+json"
CONST PBX_MIME_APPLICATION_MERGE_PATCH_JSON = "application/merge-patch+json"
CONST PBX_MIME_APPLICATION_NDJSON = "application/x-ndjson"
CONST PBX_MIME_TEXT_EVENT_STREAM = "text/event-stream"
CONST PBX_CHARSET_UTF8 = "utf-8"

TYPE PBX_JSON_SPAN
    pText AS QUAD
    cbText AS QUAD
END TYPE

TYPE PBX_JSON_LOCATION
    lineNo AS DWORD
    colNo AS DWORD
    byteOffset AS QUAD
END TYPE

TYPE PBX_JSON_ERROR_INFO
    code AS LONG
    location AS PBX_JSON_LOCATION
    messagePtr AS QUAD
END TYPE

#ENDIF
