class ObjectMapper

Declaration

class ObjectMapper { /* full declaration omitted */ };

Description

Helper for mapping JSON objects onto protocol structs. Example:

Declared at: llvm/include/llvm/Support/JSON.h:818

Member Variables

private const llvm::json::Object* O
private llvm::json::Path P

Method Overview

  • public ObjectMapper(const llvm::json::Value & E, llvm::json::Path P)
  • public template <typename T>bool map(llvm::StringLiteral Prop, T & Out)
  • public template <typename T>bool map(llvm::StringLiteral Prop, llvm::Optional<T> & Out)
  • public template <typename T>bool mapOptional(llvm::StringLiteral Prop, T & Out)
  • public bool operator bool() const

Methods

ObjectMapper(const llvm::json::Value& E,
             llvm::json::Path P)

Description

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

Declared at: llvm/include/llvm/Support/JSON.h:821

Parameters

const llvm::json::Value& E
llvm::json::Path P

template <typename T>
bool map(llvm::StringLiteral Prop, T& Out)

Description

Maps a property to a field. If the property is missing or invalid, reports an error.

Declared at: llvm/include/llvm/Support/JSON.h:832

Templates

T

Parameters

llvm::StringLiteral Prop
T& Out

template <typename T>
bool map(llvm::StringLiteral Prop,
         llvm::Optional<T>& Out)

Description

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).

Declared at: llvm/include/llvm/Support/JSON.h:843

Templates

T

Parameters

llvm::StringLiteral Prop
llvm::Optional<T>& Out

template <typename T>
bool mapOptional(llvm::StringLiteral Prop, T& Out)

Description

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.

Declared at: llvm/include/llvm/Support/JSON.h:854

Templates

T

Parameters

llvm::StringLiteral Prop
T& Out

bool operator bool() const

Description

True if the expression is an object. Must be checked before calling map().

Declared at: llvm/include/llvm/Support/JSON.h:828