26DynamicObject::DynamicObject()
35DynamicObject::~DynamicObject()
41 const var*
const v = properties.getVarPointer (propertyName);
42 return v !=
nullptr && ! v->isMethod();
47 return properties [propertyName];
52 properties.set (propertyName, newValue);
57 properties.remove (propertyName);
67 if (
auto function = properties [method].getNativeFunction())
68 return function (args);
75 properties.set (name,
var (function));
85 for (
int i = properties.size(); --i >= 0;)
86 if (
auto* v = properties.getVarPointerAt (i))
92 auto result = std::make_unique<DynamicObject> (*
this);
93 result->cloneAllProperties();
103 const int numValues = properties.size();
105 for (
int i = 0; i < numValues; ++i)
108 JSONFormatter::writeSpaces (out, format.
getIndentLevel() + JSONFormatter::indentSize);
111 JSONFormatter::writeString (out, properties.getName (i));
118 properties.getValueAt (i),
121 if (i < numValues - 1)
virtual bool hasProperty(const Identifier &propertyName) const
void setMethod(Identifier methodName, var::NativeFunction function)
virtual void removeProperty(const Identifier &propertyName)
virtual var invokeMethod(Identifier methodName, const var::NativeFunctionArgs &args)
virtual std::unique_ptr< DynamicObject > clone() const
virtual bool hasMethod(const Identifier &methodName) const
void cloneAllProperties()
virtual const var & getProperty(const Identifier &propertyName) const
virtual void setProperty(const Identifier &propertyName, const var &newValue)
virtual void writeAsJSON(OutputStream &, const JSON::FormatOptions &)
@ none
All optional whitespace should be omitted.
@ multiLine
Newlines and spaces will be included in the output, in order to make it easy to read for humans.
@ singleLine
All output should be on a single line, but with some additional spacing, e.g. after commas and colons...
static void writeToStream(OutputStream &output, const var &objectToFormat, bool allOnOneLine=false, int maximumDecimalPlaces=15)