FValue

FValue

new FValue(valueopt, parseopt, sort_namesopt)

Description:
  • Implements a minimal C/C++ JSON dynamic data structure.

    Extends: Value. This class extends Value, with all public methods available.

Parameters:
Name Type Attributes Default Description
value string | bool | int | uint | double | float | JSON <optional>

The initial value.

parse bool <optional>
false

For a string value, if true parses the string, else only copy it.

sort_names bool <optional>
false

For a parsed string value, if true sorts the names in alphabetic order, as performed by Value::sortNames().

Methods

set(name, getter, cacheopt) → {Value}

Description:
  • Sets the calculation of a given field of this structure.

    • Setting a value:
    // Defines calculations for a given field
    class DynamicFields {
    public:
      static wjson::Value sqrt_x(const wjson::Value& value) {
       return (int) sqrt(value.get("x", 0));
      }
    };
    // Sets sqrt_x as a dynamic calculated field
    fvalue.set("sqrt_x", DynamicFields::sqrt_x);
    // Gets the calculation result
    double sqrt_x = fvalue.get("sqrt_x", 0);
    
Parameters:
Name Type Attributes Default Description
name string

The field name

getter function

A static method of type wjson::Value (*getter)(const wjson::Value&).

cache bool <optional>
true

If true, memorizes the last calculated value in the static Value data structure

Returns:

This value allowing to chain set methods.

Type
Value