21 #ifndef __XUSD_Format__
22 #define __XUSD_Format__
51 #include <pxr/base/vt/array.h>
64 #define FORMAT_VAL(TYPE, GET_VAL)\
65 static SYS_FORCE_INLINE size_t \
66 format(char *buffer, size_t bufsize, const TYPE &val) \
68 UT::Format::Writer writer(buffer, bufsize); \
69 UT::Format::Formatter f; \
70 return f.format(writer, "{}", {val.GET_VAL()}); \
94 const char *tname =
nullptr;
103 default: tname =
"<undefined_type>";
break;
105 return f.
format(writer,
"{}[{}]", {tname, size});
110 template <
typename T>
112 formatVector(
char *buffer,
size_t bufsize,
const T *
data,
size_t size)
117 tmp.
format(
"{}", data[0]);
118 for (
size_t i = 1; i <
size; ++i)
123 return f.
format(writer,
"[{}]", {tmp});
133 tmp.
format(
"{}",
float(data[0]));
134 for (
size_t i = 1; i <
size; ++i)
139 return f.
format(writer,
"[{}]", {tmp});
142 template <
typename T>
144 formatIterator(
char *buffer,
size_t bufsize, T
begin,
const T &
end)
150 for (++begin; begin !=
end; ++
begin)
155 return f.
format(writer,
"[{}]", {tmp});
163 return formatVector(buffer, bufsize, &vtok[0], vtok.size());
166 #define FORMAT_TYPE(TYPE, METHOD, SIZE) \
167 static SYS_FORCE_INLINE size_t \
168 format(char *buffer, size_t bufsize, const TYPE &val) \
169 { return formatVector(buffer, bufsize, val.METHOD(), SIZE); }
193 template <
typename T>
197 return formatIterator(buffer, bufsize, arr.begin(), arr.end());
200 template <
typename T>
206 return f.
format(writer,
"{}", val.
Get<T>());
215 os << val << std::ends;
216 return f.
format(writer,
"{}", {os.
str()});
237 template <
typename T>
239 formatQuat(
char *buffer,
size_t bufsize,
const T &
q)
241 const auto &ii = q.GetImaginary();
244 return f.
format(writer,
"{0}+({1},{2},{3})i",
245 {q.GetReal(), ii[0], ii[1], ii[2]});
252 return formatQuat(buffer, bufsize, q);
257 return formatQuat(buffer, bufsize, q);
double GetMin() const
Returns the minimum value of the range.
GLenum GLuint GLsizei bufsize
An output stream object that owns its own string buffer storage.
GLdouble GLdouble GLdouble q
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
GfHalf GetReal() const
Return the real coefficient.
size_t appendFormat(const char *fmt, const Args &...args)
double GetMax() const
Returns the maximum value of the range.
GLint GLint GLsizei GLint GLenum format
const GfVec3h & GetImaginary() const
Return the imaginary coefficient.
void pathStr(UT_WorkBuffer &outpath) const
std::vector< TfToken > TfTokenVector
Convenience types.
float GetMin() const
Returns the minimum value of the range.
size_t format(const char *fmt, const Args &...args)
HD_API HdFormat HdGetComponentFormat(HdFormat f)
Return the single-channel version of a given format.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
HD_API size_t HdGetComponentCount(HdType t)
float GetMax() const
Returns the maximum value of the range.
#define PXR_NAMESPACE_CLOSE_SCOPE
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.