24 #ifndef PXR_BASE_JS_VALUE_H
25 #define PXR_BASE_JS_VALUE_H
37 #include <type_traits>
45 #define JS_VALUE_API_VERSION 2
161 template <
typename T,
162 typename ReturnType =
typename std::conditional<
168 return _Get(static_cast<T*>(
nullptr));
177 template <
typename T>
209 template <
typename T>
211 return _Is(static_cast<T*>(
nullptr));
216 template <
typename T>
223 JS_API explicit operator bool()
const;
234 template <
typename T>
235 struct _InvalidTypeHelper :
public std::false_type { };
240 "Invalid type for JsValue");
247 bool _Get(
bool*)
const {
return GetBool(); }
248 int _Get(
int*)
const {
return GetInt(); }
249 int64_t _Get(int64_t*)
const {
return GetInt64(); }
250 uint64_t _Get(uint64_t*)
const {
return GetUInt64(); }
251 double _Get(
double*)
const {
return GetReal(); }
256 "Invalid type for JsValue");
263 bool _Is(
bool*)
const {
return IsBool(); }
264 bool _Is(
int*)
const {
return IsInt(); }
265 bool _Is(int64_t*)
const {
return IsInt(); }
266 bool _Is(uint64_t*)
const {
return IsUInt64(); }
267 bool _Is(
double*)
const {
return IsReal(); }
270 std::shared_ptr<_Holder> _holder;
273 template <
typename T>
277 std::vector<T>
result(array.size());
283 template <
typename T>
290 return std::all_of(array.begin(), array.end(),
296 #endif // PXR_BASE_JS_VALUE_H
JS_API int GetInt() const
JS_API int64_t GetInt64() const
JS_API bool IsString() const
Returns true if this value is holding a string type.
JS_API bool IsObject() const
Returns true if this value is holding an object type.
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
JS_API bool operator!=(const JsValue &other) const
JS_API bool IsArray() const
Returns true if this value is holding an array type.
JS_API double GetReal() const
**But if you need a result
std::vector< JsValue > JsArray
JS_API const std::string & GetString() const
JS_API bool IsInt() const
Returns true if this value is holding an integer type.
JS_API bool IsBool() const
Returns true if this value is holding a boolean type.
JS_API bool operator==(const JsValue &other) const
JS_API JsValue()
Constructs a null value.
std::map< std::string, JsValue > JsObject
GA_API const UT_StringHolder transform
JS_API bool IsNull() const
Returns true if this value is null, false otherwise.
JS_API Type GetType() const
Returns the type of this value.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
JS_API bool IsReal() const
Returns true if this value is holding a real type.
JS_API uint64_t GetUInt64() const
JS_API bool GetBool() const
JS_API const JsArray & GetJsArray() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Type
Type held by this JSON value.
JS_API std::string GetTypeName() const
Returns a display name for the type of this value.
JS_API const JsObject & GetJsObject() const
std::vector< T > GetArrayOf() const
JS_API bool IsUInt64() const
Returns true if this value is holding a 64-bit unsigned integer.