9 #ifndef __PDG_ATTRIBUTE_ARRAY_H__
10 #define __PDG_ATTRIBUTE_ARRAY_H__
62 return (myData.size() > 0);
70 inline bool valid(
int component)
const
72 return (component >= 0) && (component < myData.size());
77 int real_index = component;
82 if (!valid(real_index))
85 data = myData[real_index];
91 return myData[component];
96 return myData[component];
111 expand(value, component);
116 myData.append(value);
117 return myData.last();
137 myData.truncate(length);
142 myData.concat(other->
myData);
148 myData.setSize(myData.size() +
offset);
155 hash_value = SYShashRange(myData.begin(), myData.end());
161 myData.swap(other->
myData);
172 return ((
const Self*)(other))->myData == myData;
186 myData.append(value);
190 myData.setSizeIfNeeded(component+1);
191 myData[component] =
value;
206 typename JSONType = ArrayType>
222 int64 mem = inclusive ?
sizeof(*this) : 0;
223 mem += getDataMemory(Base::myData);
229 return new Self(Base::myData);
240 if (!value.
import(json_type))
242 for (
auto&& entry: json_type)
243 Base::myData.
append(entry);
250 return UTarrayDeepMemoryUsage(data,
false);
253 template <
typename T>
282 PDG_AttributeType::eFileArray,
292 using Base::appendValue;
310 bool clearExpected();
314 const UT_StringHolder&
path,
315 const UT_StringHolder& tag,
319 bool replace_expected);
321 bool replace_expected);
326 const UT_StringHolder& tag,
330 const UT_StringHolder& tag,
bool jsonValue(bool value)
DataType & value(int component)
GLsizei const GLfloat * value
GLsizei const GLchar *const * path
int64 getMemoryUsage(bool inclusive=false) const
~PDG_AttributeArraySimple() override
std::size_t SYS_HashType
Define the type for hash values.
GLuint GLsizei GLsizei * length
An array of UT_StringHolder values.
Class which writes ASCII or binary JSON streams.
void setValue(const DataType &value, int component)
void truncate(int length)
const DataType & value(int component) const
void copy(const Self *other)
const ArrayType & values() const
int64 getMemoryUsage(bool inclusive) const override
Returns the memory usage of the attribute and its data.
bool concat(const Self *other)
virtual bool loadData(const UT_JSONValue &)=0
Loads data from a JSON value.
int64 Hash
The file hash/modtime type.
An array of PDG_File values, e.g. File info structs.
const DataType & appendValue(const DataType &value)
void setValue(const ArrayType &&data)
void setValue(const ArrayType &data)
virtual PDG_AttributeMergeError merge(PDG_AttributeMergeOp merge_op, int stride)=0
Applies a merge op to the data in this attribute.
PDG_AttributeArray(const ArrayType &data)
PDG_AttributeCast
Enumeration of attribute cast results.
bool hash(SYS_HashType &hash_value, UT_WorkBuffer &errors) const override
Return a hash value derived from the attribute data.
GLint GLenum GLboolean GLsizei stride
virtual bool saveData(UT_JSONWriter &) const =0
Serializes the data to a JSON writer.
bool valid(int component) const
void expand(const DataType &value, int component)
~PDG_AttributeArray() override
PDG_AttributeMergeOp
Enumeration of different ways that attributes can be combined.
bool saveData(UT_JSONWriter &writer) const override
Serializes the data to a JSON writer.
bool adjustSize(int offset)
An array of fpreal values.
PDG_AttributeType
Enumeration of possible attribute types.
SYS_FORCE_INLINE bool import(bool &result) const
Extract a bool (returns false if type is invalid)
GLenum GLsizei GLsizei GLint * values
virtual int64 getMemoryUsage(bool inclusive) const =0
Returns the memory usage of the attribute and its data.
bool value(DataType &data, int component) const
Class to store JSON objects as C++ objects.
PDG_AttributeArray< AttribType, DataType, ArrayType > Self
PDG_AttributeMergeError
Enumerations of errors that can occur when merging attributes.
PDG_AttributeMergeError merge(PDG_AttributeMergeOp merge_op, int stride) override
Applies a merge op to the data in this attribute.
size_t hash_value(const CH_ChannelRef &ref)
bool compare(const PDG_AttributeData *other) const override
Compares this data object with another data object.
virtual PDG_AttributeData * clone() const =0
Deep copies this attribute.
PDG_AttributeData * clone() const override
Deep copies this attribute.
bool loadData(const UT_JSONValue &value) override
Loads data from a JSON value.