Polyphase Game Engine
Loading...
Searching...
No Matches
JsonHelpers.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <stddef.h>
5#include <string>
6
7#include "PolyphaseAPI.h"
8
9struct lua_State;
10
11namespace rapidjson
12{
13 // Forward decls (consumer .cpp files include the full rapidjson headers).
14 template<typename Encoding, typename Allocator> class GenericValue;
15 template<typename Encoding, typename Allocator, typename StackAllocator> class GenericDocument;
16 template<typename CharType> struct UTF8;
17 class CrtAllocator;
18 template<typename BaseAllocator> class MemoryPoolAllocator;
21}
22
23// Parse a UTF-8 byte buffer as JSON. On success returns true and `outDoc` is
24// populated. On failure returns false; `outError` carries the parser message.
25POLYPHASE_API bool ParseJsonBytes(const uint8_t* data, size_t size,
26 rapidjson::Document& outDoc,
27 std::string& outError);
28
29// Push a rapidjson value onto the Lua stack. Recursive: object → table,
30// array → integer-indexed table, primitives → primitives.
31POLYPHASE_API void RapidJsonValueToLua(lua_State* L, const rapidjson::Value& v);
32
33// Pop a Lua value at index `idx` and convert it to a rapidjson value.
34// `alloc` must be the document's allocator. Returns true on success.
35POLYPHASE_API bool LuaToRapidJsonValue(lua_State* L, int idx,
36 rapidjson::Value& outVal,
POLYPHASE_API void RapidJsonValueToLua(lua_State *L, const rapidjson::Value &v)
Definition JsonHelpers.cpp:40
POLYPHASE_API bool LuaToRapidJsonValue(lua_State *L, int idx, rapidjson::Value &outVal, rapidjson::Document &doc)
Definition JsonHelpers.cpp:151
POLYPHASE_API bool ParseJsonBytes(const uint8_t *data, size_t size, rapidjson::Document &outDoc, std::string &outError)
Definition JsonHelpers.cpp:21
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition JsonHelpers.h:15
Definition JsonHelpers.h:14
Definition JsonHelpers.h:18
Definition JsonHelpers.h:12
Definition JsonHelpers.h:16