21 #ifndef __XUSD_Format__
22 #define __XUSD_Format__
51 #include <pxr/base/vt/array.h>
65 #define FORMAT_VAL(TYPE, GET_VAL)\
66 static SYS_FORCE_INLINE size_t \
67 format(char *buffer, size_t bufsize, const TYPE &val) \
69 UT::Format::Writer writer(buffer, bufsize); \
70 UT::Format::Formatter f; \
71 return f.format(writer, "{}", {val.GET_VAL()}); \
95 const char *tname =
nullptr;
106 default: tname =
"<undefined_type>";
break;
108 return f.
format(writer,
"{}[{}]", {tname, size});
113 template <
typename T>
115 formatVector(
char *buffer,
size_t bufsize,
const T *
data,
size_t size)
120 tmp.
format(
"{}", data[0]);
121 for (
size_t i = 1; i <
size; ++i)
126 return f.
format(writer,
"[{}]", {tmp});
136 tmp.
format(
"{}",
float(data[0]));
137 for (
size_t i = 1; i <
size; ++i)
142 return f.
format(writer,
"[{}]", {tmp});
145 template <
typename T>
147 formatIterator(
char *buffer,
size_t bufsize, T
begin,
const T &
end)
153 for (++begin; begin !=
end; ++
begin)
158 return f.
format(writer,
"[{}]", {tmp});
166 return formatVector(buffer, bufsize, &vtok[0], vtok.size());
169 #define FORMAT_TYPE(TYPE, METHOD, SIZE) \
170 static SYS_FORCE_INLINE size_t \
171 format(char *buffer, size_t bufsize, const TYPE &val) \
172 { return formatVector(buffer, bufsize, val.METHOD(), SIZE); }
196 template <
typename T>
200 return formatIterator(buffer, bufsize, arr.begin(), arr.end());
203 template <
typename T>
209 return f.
format(writer,
"{}", val.
Get<T>());
218 os << val << std::ends;
219 return f.
format(writer,
"{}", {os.
str()});
240 template <
typename T>
242 formatQuat(
char *buffer,
size_t bufsize,
const T &
q)
244 const auto &ii = q.GetImaginary();
247 return f.
format(writer,
"{0}+({1},{2},{3})i",
248 {q.GetReal(), ii[0], ii[1], ii[2]});
255 return formatQuat(buffer, bufsize, q);
260 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.