LLVM 20.0.0git
|
Helper for mapping JSON objects onto protocol structs. More...
#include "llvm/Support/JSON.h"
Public Member Functions | |
ObjectMapper (const Value &E, Path P) | |
If O is not an object, this mapper is invalid and an error is reported. | |
operator bool () const | |
True if the expression is an object. | |
template<typename T > | |
bool | map (StringLiteral Prop, T &Out) |
Maps a property to a field. | |
template<typename T > | |
bool | map (StringLiteral Prop, std::optional< T > &Out) |
Maps a property to a field, if it exists. | |
template<typename T > | |
bool | mapOptional (StringLiteral Prop, T &Out) |
Maps a property to a field, if it exists. | |
Helper for mapping JSON objects onto protocol structs.
Example:
|
inline |
Maps a property to a field, if it exists.
If the property exists and is invalid, reports an error. (Optional requires special handling, because missing keys are OK).
Definition at line 867 of file JSON.h.
References assert(), E, llvm::json::Path::field(), llvm::json::fromJSON(), and llvm::json::Object::get().
|
inline |
Maps a property to a field.
If the property is missing or invalid, reports an error.
Definition at line 856 of file JSON.h.
References assert(), E, llvm::json::Path::field(), llvm::json::fromJSON(), llvm::json::Object::get(), and llvm::json::Path::report().
Referenced by llvm::getTensorSpecFromJSON().
|
inline |
Maps a property to a field, if it exists.
If the property exists and is invalid, reports an error. If the property does not exist, Out is unchanged.
Definition at line 878 of file JSON.h.
References assert(), E, llvm::json::Path::field(), llvm::json::fromJSON(), and llvm::json::Object::get().
|
inline |