LLVM: llvm::json::ObjectMapper Class Reference (original) (raw)

Helper for mapping JSON objects onto protocol structs. More...

#include "[llvm/Support/JSON.h](JSON%5F8h%5Fsource.html)"

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:

return O && O.map("mandatory_field", R.MandatoryField) &&

O.mapOptional("optional_field", R.OptionalField);

}

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

ObjectMapper(const Value &E, Path P)

If O is not an object, this mapper is invalid and an error is reported.

A "cursor" marking a position within a Value.

A Value is an JSON value of unknown type.

bool fromJSON(const Value &E, std::string &Out, Path P)

Definition at line 863 of file JSON.h.

If O is not an object, this mapper is invalid and an error is reported.

Definition at line 866 of file JSON.h.

References E().

map() [1/2]

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 888 of file JSON.h.

References assert(), E(), and llvm::json::fromJSON().

map() [2/2]

mapOptional()

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 899 of file JSON.h.

References assert(), E(), llvm::json::fromJSON(), and T.

operator bool()

llvm::json::ObjectMapper::operator bool ( ) const inline

True if the expression is an object.

Must be checked before calling map().

Definition at line 873 of file JSON.h.


The documentation for this class was generated from the following file: