Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
JSONUtils.hpp
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <vector>
4#include <glm/glm.hpp>
5
10namespace JSONUtils {
16 std::string indent(int level);
22 std::string quote(const std::string& value);
28 std::string vec3ToJson(const glm::vec3& v);
34 std::string vec4ToJson(const glm::vec4& v);
35
42 std::string extractStringValue(const std::string& source, const std::string& key);
51 bool extractFloatArray(const std::string& source, const std::string& key, float* values, size_t count);
59 bool extractFloatValue(const std::string& source, const std::string& key, float& value);
65 std::vector<std::string> extractEntityObjects(const std::string& source);
73 bool extractIntVector(const std::string& source, const std::string& key, std::vector<int>& values);
81 bool extractStringVector(const std::string& source, const std::string& key, std::vector<std::string>& values);
82
89 std::string extractSubObject(const std::string& source, const std::string& key);
90}
91
Set of lightweight JSON parsing and formatting helper utilities.
std::string vec4ToJson(const glm::vec4 &v)
Serializes a glm::vec4 to a JSON array.
Definition JSONUtils.cpp:44
std::string extractSubObject(const std::string &source, const std::string &key)
Extracts a sub-object JSON string (enclosed in { ... }) for a given key.
Definition JSONUtils.cpp:273
std::string quote(const std::string &value)
Wraps a string in double quotes.
Definition JSONUtils.cpp:24
bool extractFloatArray(const std::string &source, const std::string &key, float *values, size_t count)
Finds and extracts an array of floats associated with a JSON key.
Definition JSONUtils.cpp:81
bool extractStringVector(const std::string &source, const std::string &key, std::vector< std::string > &values)
Finds and extracts an array of quoted strings associated with a JSON key.
Definition JSONUtils.cpp:237
std::vector< std::string > extractEntityObjects(const std::string &source)
Extracts individual entity JSON blocks from a main scene array.
Definition JSONUtils.cpp:140
bool extractIntVector(const std::string &source, const std::string &key, std::vector< int > &values)
Finds and extracts an array of integers associated with a JSON key.
Definition JSONUtils.cpp:203
std::string indent(int level)
Generates indentation string according to spacing level.
Definition JSONUtils.cpp:15
std::string extractStringValue(const std::string &source, const std::string &key)
Finds and extracts a string value associated with a JSON key.
Definition JSONUtils.cpp:56
std::string vec3ToJson(const glm::vec3 &v)
Serializes a glm::vec3 to a JSON array.
Definition JSONUtils.cpp:33
bool extractFloatValue(const std::string &source, const std::string &key, float &value)
Finds and extracts a single float value associated with a JSON key.
Definition JSONUtils.cpp:118
dst values count
Definition ufbx.cpp:10795
static ufbxi_noinline ufbxi_aa_node value
Definition ufbx.cpp:4444
const ufbx_keyframe * key
Definition ufbx.cpp:25982