|
🛰️航天仿真算法库 SpaceAST 0.0.1
|
#include <JsonValue.hpp>
Public 成员函数 | |
| JsonValue () | |
| JsonValue (bool value) | |
| JsonValue (int value) | |
| JsonValue (double value) | |
| JsonValue (const char *value) | |
| JsonValue (const std::string &value) | |
| JsonValue (StringView value) | |
| JsonValue (const std::vector< JsonValue > &values) | |
| JsonValue (const std::map< std::string, JsonValue > &values) | |
| JsonValue (const JsonValue &other) | |
| JsonValue (JsonValue &&other) noexcept | |
| JsonValue & | operator= (const JsonValue &other) |
| JsonValue & | operator= (JsonValue &&other) noexcept |
| template<typename T > | |
| JsonValue & | operator= (T value) |
| ~JsonValue () | |
| EJsonValueType | type () const |
| bool | isNull () const |
| bool | isBool () const |
| bool | isNumber () const |
| bool | isString () const |
| bool | isArray () const |
| bool | isObject () const |
| bool | toBool (bool defaultValue=false) const |
| int | toInt (int defaultValue=0) const |
| double | toDouble (double defaultValue=0.0) const |
| std::string | toString (StringView defaultValue=StringView()) const |
| const std::vector< JsonValue > & | getArray (const std::vector< JsonValue > &defaultValue=std::vector< JsonValue >()) const |
| const std::map< std::string, JsonValue > & | getObject (const std::map< std::string, JsonValue > &defaultValue=std::map< std::string, JsonValue >()) const |
| size_t | size () const |
| operator bool () const | |
| operator int () const | |
| operator double () const | |
| operator std::string () const | |
| JsonValue & | operator[] (size_t index) |
| JsonValue & | operator[] (int index) |
| const JsonValue & | operator[] (size_t index) const |
| const JsonValue & | operator[] (int index) const |
| JsonValue & | operator[] (const std::string &key) |
| JsonValue & | operator[] (const char *key) |
| const JsonValue & | operator[] (const std::string &key) const |
| const JsonValue & | operator[] (const char *key) const |
| void | setNull () |
| void | setBool (bool value) |
| void | setInt (int value) |
| void | setDouble (double value) |
| void | setString (StringView value) |
| void | setArray (const std::vector< JsonValue > &values={}) |
| void | setObject (const std::map< std::string, JsonValue > &values={}) |
| void | clear () |
| void | insert (const std::string &name, JsonValue value) |
| template<typename T > | |
| void | insert (const std::string &name, T value) |
| void | append (JsonValue value) |
| template<typename T > | |
| void | append (T value) |
| std::string | toJsonString (int indent=0) const |
| errc_t | parseFromString (StringView json) |
| errc_t | parseFromFile (StringView filepath) |
静态 Public 成员函数 | |
| static JsonValue | FromString (StringView json) |
| static JsonValue | FromFile (const StringView filePath) |
JSON 值类
提供 JSON 值的表示和操作
|
explicit |
从布尔值构造
| value | 布尔值 |
|
explicit |
从整数构造
| value | 整数值 |
|
explicit |
从双精度浮点数构造
| value | 双精度浮点数值 |
|
explicit |
从字符串构造
| value | 字符串值 |
|
explicit |
从字符串构造
| value | 字符串值 |
|
explicit |
从字符串视图构造
| value | 字符串视图 |
|
explicit |
从数组构造
| values | JSON 值数组 |
|
explicit |
从对象构造
| values | JSON 对象(键值对映射) |
| ast::JsonValue::JsonValue | ( | const JsonValue & | other | ) |
拷贝构造函数
| other | 其他 JSON 值 |
|
noexcept |
移动构造函数
| other | 其他 JSON 值 |
| void ast::JsonValue::append | ( | JsonValue | value | ) |
插入键值对(模板重载)
| index | 数组索引 |
| value | 键值 |
|
inline |
插入键值对(模板重载)
| index | 数组索引 |
| value | 键值 |
|
static |
从文件构造 JSON 值
| filePath | JSON 文件路径 |
|
static |
从字符串构造 JSON 值
| json | JSON 字符串 |
| const std::vector< JsonValue > & ast::JsonValue::getArray | ( | const std::vector< JsonValue > & | defaultValue = std::vector<JsonValue>() | ) | const |
获取数组引用(安全版本)
| defaultValue | 默认值 |
| const std::map< std::string, JsonValue > & ast::JsonValue::getObject | ( | const std::map< std::string, JsonValue > & | defaultValue = std::map<std::string, JsonValue>() | ) | const |
获取对象引用(安全版本)
| defaultValue | 默认值 |
| void ast::JsonValue::insert | ( | const std::string & | name, |
| JsonValue | value ) |
插入键值对
| name | 键名 |
| value | 键值 |
|
inline |
插入键值对(模板重载)
| name | 键名 |
| value | 键值 |
| bool ast::JsonValue::isArray | ( | ) | const |
判断是否为数组
| bool ast::JsonValue::isBool | ( | ) | const |
判断是否为布尔值
| bool ast::JsonValue::isNull | ( | ) | const |
判断是否为 null 值
| bool ast::JsonValue::isNumber | ( | ) | const |
判断是否为数值
| bool ast::JsonValue::isObject | ( | ) | const |
判断是否为对象
| bool ast::JsonValue::isString | ( | ) | const |
判断是否为字符串
| ast::JsonValue::operator bool | ( | ) | const |
转换为布尔值运算符
| ast::JsonValue::operator double | ( | ) | const |
转换为双精度浮点数值运算符
| ast::JsonValue::operator int | ( | ) | const |
转换为整数值运算符
| ast::JsonValue::operator std::string | ( | ) | const |
转换为字符串值运算符
拷贝赋值运算符
| other | 其他 JSON 值 |
移动赋值运算符
| other | 其他 JSON 值 |
|
inline |
赋值运算符(模板重载)
| value | 要赋值的值 |
| JsonValue & ast::JsonValue::operator[] | ( | const std::string & | key | ) |
对象下标运算符
| key | 对象键 |
| const JsonValue & ast::JsonValue::operator[] | ( | const std::string & | key | ) | const |
对象下标运算符
| key | 对象键 |
| JsonValue & ast::JsonValue::operator[] | ( | size_t | index | ) |
数组下标运算符
| index | 数组索引 |
| const JsonValue & ast::JsonValue::operator[] | ( | size_t | index | ) | const |
数组下标运算符(常量版本)
| index | 数组索引 |
| errc_t ast::JsonValue::parseFromFile | ( | StringView | filepath | ) |
解析 JSON 文件
| filepath | JSON 文件路径 |
| errc_t ast::JsonValue::parseFromString | ( | StringView | json | ) |
解析 JSON 字符串
| json | JSON 字符串 |
| void ast::JsonValue::setArray | ( | const std::vector< JsonValue > & | values = {} | ) |
设置数组值
| values | JSON 值数组 |
| void ast::JsonValue::setBool | ( | bool | value | ) |
设置布尔值
| value | 布尔值 |
| void ast::JsonValue::setDouble | ( | double | value | ) |
设置双精度浮点数值
| value | 双精度浮点数值 |
| void ast::JsonValue::setInt | ( | int | value | ) |
设置整数值
| value | 整数值 |
| void ast::JsonValue::setObject | ( | const std::map< std::string, JsonValue > & | values = {} | ) |
设置对象值
| values | JSON 对象(键值对映射) |
| void ast::JsonValue::setString | ( | StringView | value | ) |
设置字符串值
| value | 字符串值 |
| bool ast::JsonValue::toBool | ( | bool | defaultValue = false | ) | const |
转换为布尔值(安全版本)
| defaultValue | 默认值 |
| double ast::JsonValue::toDouble | ( | double | defaultValue = 0.0 | ) | const |
转换为双精度浮点数值(安全版本)
| defaultValue | 默认值 |
| int ast::JsonValue::toInt | ( | int | defaultValue = 0 | ) | const |
转换为整数值(安全版本)
| defaultValue | 默认值 |
| std::string ast::JsonValue::toJsonString | ( | int | indent = 0 | ) | const |
转换为 JSON 字符串表示
| std::string ast::JsonValue::toString | ( | StringView | defaultValue = StringView() | ) | const |
转换为字符串值(安全版本)
| defaultValue | 默认值 |
| EJsonValueType ast::JsonValue::type | ( | ) | const |
获取值类型