7 #ifndef PXR_BASE_JS_VALUE_H
8 #define PXR_BASE_JS_VALUE_H
20 #include <type_traits>
28 #define JS_VALUE_API_VERSION 2
144 template <
typename T,
145 typename ReturnType =
typename std::conditional<
151 return _Get(static_cast<T*>(
nullptr));
160 template <
typename T>
192 template <
typename T>
194 return _Is(static_cast<T*>(
nullptr));
199 template <
typename T>
217 template <
typename T>
218 struct _InvalidTypeHelper :
public std::false_type { };
223 "Invalid type for JsValue");
229 const std::string& _Get(std::string*)
const {
return GetString(); }
230 bool _Get(
bool*)
const {
return GetBool(); }
231 int _Get(
int*)
const {
return GetInt(); }
232 int64_t _Get(int64_t*)
const {
return GetInt64(); }
233 uint64_t _Get(uint64_t*)
const {
return GetUInt64(); }
234 double _Get(
double*)
const {
return GetReal(); }
239 "Invalid type for JsValue");
245 bool _Is(std::string*)
const {
return IsString(); }
246 bool _Is(
bool*)
const {
return IsBool(); }
247 bool _Is(
int*)
const {
return IsInt(); }
248 bool _Is(int64_t*)
const {
return IsInt(); }
249 bool _Is(uint64_t*)
const {
return IsUInt64(); }
250 bool _Is(
double*)
const {
return IsReal(); }
253 std::shared_ptr<_Holder> _holder;
256 template <
typename T>
260 std::vector<T>
result(array.size());
266 template <
typename T>
273 return std::all_of(array.begin(), array.end(),
279 #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 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.
GLint GLint GLsizei GLint GLenum GLenum 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.