25 return static_cast<const IntValue *
>(
this);
49 return static_cast<const EnumValue *
>(
this);
74 for (
const std::shared_ptr<Value> &item_value : value.
elements()) {
75 nlohmann::ordered_json json_item;
77 j.push_back(json_item);
87 nlohmann::ordered_json json_item;
95 switch (value.
type()) {
143 std::unique_ptr<ArrayValue>
array = std::make_unique<ArrayValue>();
144 for (
auto element : j.items()) {
151 const nlohmann::ordered_json &j)
153 std::unique_ptr<DictionaryValue>
object = std::make_unique<DictionaryValue>();
154 for (
auto element : j.items()) {
163 case nlohmann::json::value_t::array: {
167 case nlohmann::json::value_t::object: {
171 case nlohmann::json::value_t::string: {
172 std::string value = j;
173 return std::make_unique<StringValue>(value);
176 case nlohmann::json::value_t::null: {
177 return std::make_unique<NullValue>();
180 case nlohmann::json::value_t::boolean: {
181 return std::make_unique<BooleanValue>(j);
183 case nlohmann::json::value_t::number_integer:
184 case nlohmann::json::value_t::number_unsigned: {
185 return std::make_unique<IntValue>(j);
188 case nlohmann::json::value_t::number_float: {
189 return std::make_unique<DoubleValue>(j);
192 case nlohmann::json::value_t::binary:
193 case nlohmann::json::value_t::discarded:
201 return std::make_unique<NullValue>();
205 return std::make_unique<NullValue>();
210 values_.append(std::move(value));
215 this->
append(std::make_shared<BooleanValue>(value));
220 this->
append(std::make_shared<IntValue>(value));
225 this->
append(std::make_shared<DoubleValue>(value));
230 this->
append(std::make_shared<StringValue>(std::move(value)));
235 this->
append(std::make_shared<NullValue>());
240 auto value = std::make_shared<DictionaryValue>();
247 auto value = std::make_shared<ArrayValue>();
255 for (
const Item &item : values_) {
256 result.add_as(item.first, item.second);
263 for (
const auto &item : values_) {
264 if (item.first == key) {
273 if (
const std::shared_ptr<Value> *value = this->
lookup(key)) {
283 if (
const std::shared_ptr<Value> *value = this->
lookup(key)) {
284 if (
const IntValue *int_value = (*value)->as_int_value()) {
285 return int_value->value();
293 if (
const std::shared_ptr<Value> *value = this->
lookup(key)) {
294 if (
const DoubleValue *double_value = (*value)->as_double_value()) {
295 return double_value->value();
303 if (
const std::shared_ptr<Value> *value = this->
lookup(key)) {
304 return (*value)->as_dictionary_value();
311 if (
const std::shared_ptr<Value> *value = this->
lookup(key)) {
312 return (*value)->as_array_value();
319 values_.
append({std::move(key), std::move(value)});
324 this->
append(std::move(key), std::make_shared<IntValue>(value));
329 this->
append(std::move(key), std::make_shared<DoubleValue>(value));
334 this->
append(std::move(key), std::make_shared<StringValue>(std::move(value)));
339 auto value = std::make_shared<DictionaryValue>();
340 this->
append(std::move(key), value);
346 auto value = std::make_shared<ArrayValue>();
347 this->
append(std::move(key), value);
353 nlohmann::ordered_json j;
365 nlohmann::ordered_json j;
378 fstream stream(path, std::ios::out);
385 fstream stream(path, std::ios::in);
#define BLI_assert_unreachable()
File and directory operations.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
ATTR_WARN_UNUSED_RESULT const void * element
void append(const array< T > &from)
void append_int(int value)
void append_double(double value)
void append(std::shared_ptr< Value > value)
Span< std::shared_ptr< Value > > elements() const
std::shared_ptr< ArrayValue > append_array()
void append_str(std::string value)
void append_bool(bool value)
std::shared_ptr< DictionaryValue > append_dict()
void append(std::string key, std::shared_ptr< Value > value)
const std::shared_ptr< Value > * lookup(const StringRef key) const
void append_str(std::string key, std::string value)
std::shared_ptr< DictionaryValue > append_dict(std::string key)
std::pair< std::string, std::shared_ptr< Value > > Item
const DictionaryValue * lookup_dict(const StringRef key) const
Span< Item > elements() const
void append_double(std::string key, double value)
void append_int(std::string key, int64_t value)
const ArrayValue * lookup_array(const StringRef key) const
Map< std::string, std::shared_ptr< Value > > Lookup
std::optional< int64_t > lookup_int(const StringRef key) const
std::shared_ptr< ArrayValue > append_array(std::string key)
std::optional< StringRefNull > lookup_str(const StringRef key) const
std::optional< double > lookup_double(const StringRef key) const
Lookup create_lookup() const
const std::string & value() const
const EnumValue * as_enum_value() const
const BooleanValue * as_boolean_value() const
const ArrayValue * as_array_value() const
const StringValue * as_string_value() const
const IntValue * as_int_value() const
const DoubleValue * as_double_value() const
const DictionaryValue * as_dictionary_value() const
static std::unique_ptr< DictionaryValue > convert_from_json_to_object(const nlohmann::ordered_json &j)
void write_json_file(StringRef path, const Value &value)
PrimitiveValue< int64_t, eValueType::Int > IntValue
PrimitiveValue< bool, eValueType::Boolean > BooleanValue
PrimitiveValue< int, eValueType::Enum > EnumValue
static std::unique_ptr< Value > convert_from_json(const nlohmann::ordered_json &j)
PrimitiveValue< double, eValueType::Double > DoubleValue
static void convert_to_json(nlohmann::ordered_json &j, const Value &value)
static std::unique_ptr< ArrayValue > convert_from_json_to_array(const nlohmann::ordered_json &j)
std::shared_ptr< Value > read_json_file(StringRef path)