19 #include <initializer_list> 
   23 #include <type_traits> 
   25 template <
typename T> 
class UT_Array;
 
  161 namespace UT { 
namespace Format {
 
  193         myBufferSize(buffer ? buffer_size : 0) { }
 
  198         myBufferSize = buffer_size;
 
  201     size_t operator()(
const char *
begin, 
const char *
end) 
override;
 
  217     template<
typename> 
struct TrueType : std::true_type {};
 
  224     static auto TestHasFormat(
int) ->
 
  226                                  size_t(), std::declval<T>()))>;
 
  228     static auto TestHasFormat(
long) -> std::false_type;
 
  234     static constexpr 
bool value = decltype(Impl::TestHasFormat<T>(0))::
value;
 
  246         Int8, UInt8, Int16, UInt16, Int32, UInt32, 
Int64, UInt64,
 
  247         Float16, Float32, Float64,
 
  265 #if (defined(LINUX) && defined(AMD64)) || (defined(LINUX) && defined(ARM64)) 
  269     static_assert(
sizeof(
long long) == 8, 
"long long should be 8 bytes.");
 
  271     ArgValue(
unsigned long long v) : myType(
Type::UInt64), myU64(
uint64(v)) {}
 
  273 #if defined(MBSD) && defined(__clang__) 
  275     ArgValue(
size_t myValuePtr) : myType(
Type::UInt64), myU64(
uint64(myValuePtr)) {}
 
  281 #elif defined(_WIN32) 
  290             mySizedStr.myStr = 
"true";
 
  291             mySizedStr.mySize = 4;
 
  295             mySizedStr.myStr = 
"false";
 
  296             mySizedStr.mySize = 5;
 
  312         myType(
Type::Pointer), myPtr(v)
 
  316         myType(
Type::Pointer), myPtr(v)
 
  320 #define UT_ENABLE_IF(T)     typename std::enable_if<T>::type * = nullptr 
  321 #define UT_HAS_FMT(T)       HasFormat<T>::value 
  322 #define UT_REMOVE_PTR(T)    typename std::remove_pointer<T>::type 
  323 #define UT_IS_PTR(T)        std::is_pointer<T>::value 
  324 #define UT_IS_ENUM(T)       std::is_enum<T>::value 
  333         myType(
Type::Pointer), myPtr(v)
 
  345         myCustom.myFormatFunc = customPtrWrapper<UT_REMOVE_PTR(T)>;
 
  346         myCustom.myValuePtr = 
static_cast<const void *
>(
v);
 
  350     template<
typename T, 
unsigned N>
 
  354         myCustom.myFormatFunc = customArrayWrapper<UT_REMOVE_PTR(T),N>;
 
  355         myCustom.myValuePtr = 
static_cast<const void *
>(&v[0]);
 
  358     template <
typename T>
 
  365     template <
typename T>
 
  370         myCustom.myFormatFunc = customRefWrapper<T>;
 
  371         myCustom.myValuePtr = &
v;
 
  379         static_assert(
UT_HAS_FMT(
T), 
"No formatting function for custom type.");
 
  380         myCustom.myFormatFunc = customRefWrapper<T>;
 
  381         myCustom.myValuePtr = &
t;
 
  384     template <
typename T>
 
  397         return myCustom.myFormatFunc(buffer, buffer_size, myCustom.myValuePtr);
 
  413     bool isEmpty()
 const { 
return myType == Type::None; }
 
  417         return myType == Type::Int8  || myType == Type::UInt8  ||
 
  418                myType == Type::Int16 || myType == Type::UInt16 ||
 
  419                myType == Type::Int32 || myType == Type::UInt32 ||
 
  420                myType == Type::Int64 || myType == Type::UInt64;
 
  425         return myType == Type::Float16 ||
 
  426                myType == Type::Float32 ||
 
  427                myType == Type::Float64;
 
  432         return myType == Type::Int8  ||
 
  433                myType == Type::Int16 ||
 
  434                myType == Type::Int32 ||
 
  435                myType == Type::Int64 ||
 
  446         return myType == Type::CharString ||
 
  447                myType == Type::ZeroString ||
 
  448                myType == Type::SizedString;
 
  453         return myType == Type::Pointer;
 
  458         return myType == Type::Custom;
 
  461     bool matchKeyword(
const char* str, std::size_t len) 
const;
 
  469     void setKeyword(
const char* kw);
 
  508     SizedString myKeyword = SizedString(
nullptr, 0);
 
  511     template <
typename T>
 
  513     customRefWrapper(
char *
buffer, 
size_t buffer_size, 
const void *
value)
 
  515         return format(buffer, buffer_size, *static_cast<const T*>(value));
 
  518     template <
typename T>
 
  520     customPtrWrapper(
char *buffer, 
size_t buffer_size, 
const void *value);
 
  522     template <
typename T, 
unsigned N>
 
  524     customArrayWrapper(
char *buffer, 
size_t buffer_size, 
const void *value);
 
  536     template <
typename T>
 
  560     void setReportErrors(
bool flag) { myReportErrors = flag; }
 
  577                   std::initializer_list<ArgValue> 
args);
 
  594                   std::initializer_list<ArgValue> 
args);
 
  600         size_t field_width = 0;
 
  603         enum { Left, Center, Right, 
Number } align = Left;
 
  604         enum { Minus, Plus, Space } 
sign = Minus;
 
  605         bool alt_form = 
false;
 
  611     bool parseFormatSpec(
const char *&
ptr, 
const ArgValue &
arg,
 
  612                          const ArgValue 
args[], 
size_t nb_args,
 
  614     bool parsePrintfSpec(
const char *&
ptr, 
const ArgValue &
arg,
 
  615                          const ArgValue 
args[], 
size_t nb_args,
 
  618     template <
typename ListT>
 
  619     size_t formatImpl(
W &writer, 
const char *
format, ListT 
args);
 
  621     size_t formatArg(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  622     size_t formatInteger(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  623     size_t formatFloat(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  624     size_t formatString(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  625     size_t formatPointer(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  626     size_t formatCustom(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  627     size_t formatCodePoint(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  628     size_t formatPercentage(
W &writer, 
const FormatSpec &spec, 
const ArgValue &
arg);
 
  630     size_t formatAdjustAndFill(
W &writer, 
const char *str, 
size_t str_size,
 
  631                                const FormatSpec &spec);
 
  636     const ArgValue &getFormatArg(
const char *&
ptr, 
const ArgValue 
args[],
 
  638     const ArgValue &getPrintfArg(
const char *&
ptr, 
const ArgValue 
args[],
 
  640     static int64 getIntValueFromArg(
const ArgValue &
arg);
 
  641     static fpreal64 getFloatValueFromArg(
const ArgValue &
arg);
 
  643     int64 myNextArgIndex = 0;
 
  644     bool myReportErrors = 
true;
 
  645     bool myDigitGroupings = 
false;
 
  649 template <
typename T, 
unsigned N>
 
  651 ArgValue::customArrayWrapper(
 
  652         char *
buffer, 
size_t buffer_size, 
const void *
value)
 
  654     Writer writer(buffer, buffer_size);
 
  657     size_t nb_needed = writer(
"[", 1);
 
  658     for (
unsigned i = 0; i < 
N; ++i)
 
  659         nb_needed += f.format(writer, i ? 
", {}" : 
"{}", {ptr[i]});
 
  660     nb_needed += writer(
"]", 1);
 
  671 template <
typename T>
 
  673 ArgValue::customPtrWrapper(
char *
buffer, 
size_t buffer_size, 
const void *
value)
 
  676         return format(buffer, buffer_size, 
"<{} {}>",
 
  679         return format(buffer, buffer_size, 
"<{}>", {value});
 
  695 template<
typename... Args>
 
  706 template<
typename... Args>
 
  709     return UTformat(stdout, format, args...);
 
  718 template<
typename... Args>
 
  735 template<
typename... Args>
 
  754 template<
typename... Args>
 
  765 template<
typename... Args>
 
  768     return UTprintf(stdout, format, args...);
 
  777 template<
typename... Args>
 
  794 template<
typename... Args>
 
  805 inline namespace Literal
 
  809         const std::size_t len)
 
  816 #endif // __UT_Format__ 
auto printf(const S &fmt, const T &...args) -> int
 
GLsizei const GLfloat * value
 
GLuint GLsizei GLsizei * length
 
unsigned long long uint64
 
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
 
A utility class to do read-only operations on a subset of an existing string. 
 
GLint GLint GLsizei GLint GLenum GLenum type
 
const TypeValidator< double > Number("NUMBER")
Check for a number. 
 
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER typedef long long unsigned int Int64
Int64 - unsigned 64-bit integer. 
 
GLint GLint GLsizei GLint GLenum format
 
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class. 
 
IMATH_HOSTDEVICE constexpr int sign(T a) IMATH_NOEXCEPT
 
GLenum GLint GLint * precision
 
__hostdev__ bool isInteger(GridType gridType)
Return true if the GridType maps to a POD integer type. 
 
LeafData & operator=(const LeafData &)=delete
 
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
 
GA_API const UT_StringHolder N
 
**If you just want to fire and args
 
OIIO_UTIL_API const char * c_str(string_view str)
 
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.