9 #ifndef __PDG_ATTRIBUTE_REF_H__
10 #define __PDG_ATTRIBUTE_REF_H__
86 inline operator bool()
const
94 return (myError == eErrorNone);
130 bool report_errors=
true,
131 bool as_warning=
false)
const;
142 static void attributeModified(
156 template <
typename Attribute,
typename Holder>
181 return myHolder->template attribute<const Attribute>();
188 return myHolder->template attribute<const T>();
200 return myHolder->template hasData<Attribute>();
206 return myHolder->isOwner();
212 return myHolder->type();
218 return myHolder->flags();
224 return myHolder->hasAnyFlags();
230 return myHolder->hasFlag(flag);
236 return myHolder->hasFlags(flags);
242 return myHolder->hasAnyFlags(flags);
264 bool has_component)
const
270 return myHolder->template attribute<PDG_AttributePyObject>()->
query(
271 number, query, index);
273 return asNumber(number, index);
283 if (myHolder->template attribute<PDG_AttributeInteger>()->value(
294 if (myHolder->template attribute<PDG_AttributeFloat>()->value(
314 bool own =
false)
const
320 switch (myHolder->type())
324 if (!myHolder->template attribute<PDG_AttributePyObject>()->str(
335 if (!myHolder->template attribute<PDG_AttributeString>()->value(
347 if (myHolder->template attribute<PDG_AttributeFile>()->value(
350 file_path = temp.
data();
353 file_tag = temp.
tag();
356 file_hash = temp.
hash();
368 file =
PDG_File(file_path, file_tag, file_hash, own);
379 bool has_component)
const
385 return myHolder->template attribute<PDG_AttributePyObject>()->
query(
386 buffer, query, index);
388 return asString(buffer, index, pad);
397 switch (myHolder->type())
402 if (myHolder->template attribute<PDG_AttributeInteger>()->value(
414 if (myHolder->template attribute<PDG_AttributeFloat>()->value(
433 if (myHolder->template attribute<PDG_AttributeString>()->value(
436 buffer.
sprintf(
"%s", temp.c_str());
445 if (myHolder->template attribute<PDG_AttributeFile>()->value(
457 if (myHolder->template attribute<PDG_AttributePyObject>()->str(
475 switch (myHolder->type())
479 auto&&
values = myHolder->template
480 attribute<PDG_AttributeInteger>()->
values();
489 auto&&
values = myHolder->template
490 attribute<PDG_AttributeFloat>()->
values();
509 auto&&
values = myHolder->template
510 attribute<PDG_AttributeString>()->
values();
524 auto&&
values = myHolder->template
525 attribute<PDG_AttributeFile>()->
values();
540 if (myHolder->template attribute<PDG_AttributePyObject>()->str(
559 switch (myHolder->type())
609 template <
typename Attribute>
625 template <
typename Attribute>
665 :
Base(std::move(other))
666 , myModified(other.myModified)
668 other.myModified =
false;
686 Base::operator=(other);
700 myModified = other.myModified;
701 other.myModified =
false;
703 Base::operator=(std::move(other));
712 if (Base::myOwner && myModified)
713 Base::attributeModified(Base::myOwner,
Base::type(), Base::myName);
729 Base::myHolder->own();
730 Base::myHolder->setIsChanged(
true);
733 return Base::myHolder->template attribute<Attribute>();
749 if (!Base::isValid())
752 if (Base::myOwner && !Base::myOwner->isAttribFlagValid(flag))
753 return Base::eErrorInvalidFlag;
755 changed = Base::myHolder->setFlag(flag, set);
756 return Base::eErrorNone;
764 return setFlag(flag, set, discard);
771 if (!Base::isValid())
774 if (Base::myOwner && !Base::myOwner->areAttribFlagsValid(flags))
775 return Base::eErrorInvalidFlag;
777 changed = Base::myHolder->setFlags(flags);
778 return Base::eErrorNone;
786 return setFlags(flags, discard);
792 switch (Base::myHolder->
type())
796 return Base::myHolder->template
attribute<
802 return Base::myHolder->template
attribute<
808 return Base::myHolder->template
attribute<
814 return Base::myHolder->template
attribute<
A single, opaque PyObject.
const T * attributeT() const
PDG_RWAttributeRef(PDG_AttributeHolder *holder, const UT_StringHolder &name, const PDG_AttributeOwner *owner, PDG_AttributeRef::Error error=PDG_AttributeRef::eErrorNone)
bool isOwner() const
Returns true if the contained attribute holder owns its data.
GLsizei const GLfloat * value
const UT_StringHolder & name() const
Returns the name of the attribute referenced by this attrib ref.
bool isEmpty() const
Same as !isstring()
bool isArray() const
Returns true if the attribute is an array.
Error error() const
Returns the error state of the handle.
GLuint GLsizei GLsizei * length
An array of UT_StringHolder values.
The entire attribute map is read only.
The requested attribute was not found - the ref is invalid.
No error was specified, i.e. the ref is valid.
Base::Error setFlag(PDG_AttributeFlag flag, bool set)
Sets the specific flag on or off.
Base::Error setFlag(PDG_AttributeFlag flag, bool set, bool &changed)
Base::Error setFlags(uint16 flags)
Sets all flags.
~PDG_RWAttributeRef()
Emits data changed events if this attribute ref recorded a modification.
bool hasAnyFlags(uint16 flags) const
Returns true if the contained holder has any of the specified flags set.
Cast failed due to a type mismatch (string vs. int)
bool hasFlag(PDG_AttributeFlag flag) const
Returns true if the contained holder has the specified flag set.
const char * buffer() const
void truncate(int length)
Truncates the array stored in the attribute.
int64 Hash
The file hash/modtime type.
An array of PDG_File values, e.g. File info structs.
An unspecified error occured - the ref is invalid.
bool removeTrailingSpace()
Remove trailing whitespace, return true if whitespace was removed.
const UT_StringHolder & tag() const
bool hasAnyFlags() const
Returns true if the contained holder has any flags set.
void clearEvents()
Clears any pending events.
The requested attribute is static and was not upgraded to dynamic.
static const UT_StringHolder theEmptyString
PDG_AttributeCast
Enumeration of attribute cast results.
Attribute * operator->()
Returns a non-const pointer to the underlying attribute instance.
PDG_AttributeCast asNumber(fpreal &number, int index) const
PDG_AttributeCast asFile(PDG_File &file, int index, const UT_StringHolder &tag=UT_StringHolder::theEmptyString, PDG_File::Hash hash=0, bool own=false) const
bool hasData() const
Returns true if the contained attribute has any data.
Holder * holder() const
Returns the underlying attribute holder.
SYS_FORCE_INLINE const char * c_str() const
PDG_RWAttributeRef(const UT_StringHolder &name, const PDG_AttributeOwner *owner)
Constructs an uninitialized RW ref.
const UT_StringHolder & data() const
GLuint const GLchar * name
const Attribute * attribute() const
Returns a const pointer to the underlying attribute instance.
const PDG_AttributeOwner * myOwner
PDG_AttributeFlag
Enumeration of extra attribute flags. Flags can be ORed together.
const PDG_AttributeOwner * owner() const
Returns the PDG_AttributeOwner that owns the underlying attribute.
A single PDG_ApplicationShim::Geometry instance.
fpreal32 SYSrint(fpreal32 val)
PDG_AttributeRef(const UT_StringHolder &name, const PDG_AttributeOwner *owner, Error error=eErrorNone)
int sprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
PDG_RWAttributeRef(const Self &other)
An array of fpreal values.
PDG_AttributeCast asNumber(fpreal &number, const UT_StringHolder &query, int index, bool has_component) const
PDG_AttributeRefT(Holder *holder, const UT_StringHolder &name, const PDG_AttributeOwner *owner, PDG_AttributeRef::Error error=eErrorNone)
int int appendSprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
int size() const
Returns the size of the data stored in the attribute.
PDG_AttributeType
Enumeration of possible attribute types.
GLenum GLsizei GLsizei GLint * values
PDG_AttributeCast asStringValues(UT_WorkBuffer &buffer, int pad=0) const
Prints the values contained in the attribute to space-separated string.
PDG_AttributeType type() const
Returns the type of the contained attribute.
uint16 flags() const
Returns the flags on the contained holder.
bool isNumeric() const
Returns true if the attribute is numeric.
PDG_AttributeCast asString(UT_WorkBuffer &buffer, const UT_StringHolder &query, int index, int pad, bool has_component) const
PDG_AttributeCast asString(UT_WorkBuffer &buffer, int index, int pad=0) const
No cast error occured (success)
PDG_RWAttributeRef(Self &&other)
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
void protectString(bool protect_empty=false)
const Attribute * operator->() const
Returns a const pointer to the underlying attribute instance.
void emitEvents()
Emits pending events from the ref.
Base::Error setFlags(uint16 flags, bool &changed)
Directly sets the flag bits to the specified flags.
Cast failed due to an index being out of bounds.
Self & operator=(Self &&other)
Self & operator=(const Self &other)
The ref is uninitialized and needs to be created at a later point.
bool isValid() const
Returns true if the handle is valid.
bool hasFlags(uint16 flags) const
Returns true if the contained holder has all of the specified flags set.