OpenShot Library | libopenshot-audio
0.2.0
|
26 DynamicObject::DynamicObject()
30 DynamicObject::DynamicObject (
const DynamicObject& other)
31 : ReferenceCountedObject(), properties (other.properties)
35 DynamicObject::~DynamicObject()
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;)
103 const int numValues = properties.
size();
105 for (
int i = 0; i < numValues; ++i)
108 JSONFormatter::writeSpaces (out, indentLevel + JSONFormatter::indentSize);
111 JSONFormatter::writeString (out, properties.
getName (i));
113 JSONFormatter::write (out, properties.
getValueAt (i), indentLevel + JSONFormatter::indentSize, allOnOneLine, maximumDecimalPlaces);
115 if (i < numValues - 1)
120 out <<
',' << newLine;
122 else if (! allOnOneLine)
127 JSONFormatter::writeSpaces (out, indentLevel);
virtual void setProperty(const Identifier &propertyName, const var &newValue)
Sets a named property.
const var & getValueAt(int index) const noexcept
Returns the value of the item at a given index.
virtual Ptr clone()
Returns a clone of this object.
void cloneAllProperties()
Calls var::clone() on all the properties that this object contains.
var * getVarPointer(const Identifier &name) const noexcept
Returns a pointer to the var that holds a named value, or null if there is no value with this name.
Identifier getName(int index) const noexcept
Returns the name of the value at a given index.
virtual bool hasMethod(const Identifier &methodName) const
Checks whether this object has the specified method.
Represents a dynamically implemented object.
bool remove(const Identifier &name)
Removes a value from the set.
void clear()
Removes all properties and methods from the object.
The base class for streams that write data to some kind of destination.
bool set(const Identifier &name, const var &newValue)
Changes or adds a named value.
var * getVarPointerAt(int index) const noexcept
Returns the value of the item at a given index.
A variant class, that can be used to hold a range of primitive values.
virtual bool hasProperty(const Identifier &propertyName) const
Returns true if the object has a property with this name.
void setMethod(Identifier methodName, var::NativeFunction function)
Adds a method to the class.
virtual const var & getProperty(const Identifier &propertyName) const
Returns a named property.
virtual void removeProperty(const Identifier &propertyName)
Removes a named property.
Represents a string identifier, designed for accessing properties by name.
int size() const noexcept
Returns the total number of values that the set contains.
This structure is passed to a NativeFunction callback, and contains invocation details about the func...
void clear()
Removes all values.
virtual void writeAsJSON(OutputStream &, int indentLevel, bool allOnOneLine, int maximumDecimalPlaces)
Writes this object to a text stream in JSON format.
virtual var invokeMethod(Identifier methodName, const var::NativeFunctionArgs &args)
Invokes a named method on this object.