LLVM
15.0.0git
|
Classes | |
class | Array |
An Array is a JSON array, which contains heterogeneous JSON values. More... | |
class | Object |
An Object is a JSON object, which maps strings to heterogenous JSON values. More... | |
class | ObjectKey |
ObjectKey is a used to capture keys in Object. More... | |
class | ObjectMapper |
Helper for mapping JSON objects onto protocol structs. More... | |
class | OStream |
json::OStream allows writing well-formed JSON without materializing all structures as json::Value ahead of time. More... | |
class | ParseError |
class | Path |
A "cursor" marking a position within a Value. More... | |
class | Value |
A Value is an JSON value of unknown type. More... | |
Functions | |
bool | isUTF8 (llvm::StringRef S, size_t *ErrOffset=nullptr) |
Returns true if S is valid UTF-8, which is required for use as JSON. More... | |
std::string | fixUTF8 (llvm::StringRef S) |
Replaces invalid UTF-8 sequences in S with the replacement character (U+FFFD). More... | |
template<typename T > | |
Value | toJSON (const llvm::Optional< T > &Opt) |
bool | operator== (const Object &LHS, const Object &RHS) |
bool | operator!= (const Object &LHS, const Object &RHS) |
bool | operator!= (const Array &L, const Array &R) |
bool | operator== (const Value &, const Value &) |
bool | operator!= (const Value &L, const Value &R) |
bool | operator== (const ObjectKey &L, const ObjectKey &R) |
bool | operator!= (const ObjectKey &L, const ObjectKey &R) |
bool | operator< (const ObjectKey &L, const ObjectKey &R) |
bool | fromJSON (const Value &E, std::string &Out, Path P) |
bool | fromJSON (const Value &E, int &Out, Path P) |
bool | fromJSON (const Value &E, int64_t &Out, Path P) |
bool | fromJSON (const Value &E, double &Out, Path P) |
bool | fromJSON (const Value &E, bool &Out, Path P) |
bool | fromJSON (const Value &E, uint64_t &Out, Path P) |
bool | fromJSON (const Value &E, std::nullptr_t &Out, Path P) |
template<typename T > | |
bool | fromJSON (const Value &E, llvm::Optional< T > &Out, Path P) |
template<typename T > | |
bool | fromJSON (const Value &E, std::vector< T > &Out, Path P) |
template<typename T > | |
bool | fromJSON (const Value &E, std::map< std::string, T > &Out, Path P) |
llvm::Expected< Value > | parse (llvm::StringRef JSON) |
Parses the provided JSON source, or returns a ParseError. More... | |
template<typename T > | |
Expected< T > | parse (const llvm::StringRef &JSON, const char *RootName="") |
Version of parse() that converts the parsed value to the type T. More... | |
llvm::raw_ostream & | operator<< (llvm::raw_ostream &OS, const Value &V) |
Serializes this Value to JSON, writing it to the provided stream. More... | |
static void | quote (llvm::raw_ostream &OS, llvm::StringRef S) |
std::string llvm::json::fixUTF8 | ( | llvm::StringRef | S | ) |
Replaces invalid UTF-8 sequences in S
with the replacement character (U+FFFD).
The returned string is valid UTF-8. This is much slower than isUTF8, so test that first.
Definition at line 708 of file JSON.cpp.
References llvm::ConvertUTF32toUTF8(), llvm::ConvertUTF8toUTF32(), llvm::lenientConversion, S, and llvm::strictConversion.
Referenced by llvm::json::OStream::attributeBegin(), llvm::json::ObjectKey::ObjectKey(), and llvm::json::Value::Value().
bool llvm::json::fromJSON | ( | const Value & | E, |
llvm::Optional< T > & | Out, | ||
Path | P | ||
) |
Definition at line 730 of file JSON.h.
References E, fromJSON(), move, llvm::None, P, and T.
bool llvm::json::fromJSON | ( | const Value & | E, |
std::map< std::string, T > & | Out, | ||
Path | P | ||
) |
Definition at line 755 of file JSON.h.
References E, fromJSON(), llvm::RISCVFenceField::O, and P.
Definition at line 673 of file JSON.h.
Referenced by fromJSON(), llvm::json::ObjectMapper::map(), llvm::json::ObjectMapper::mapOptional(), and parse().
bool llvm::json::isUTF8 | ( | llvm::StringRef | S, |
size_t * | ErrOffset = nullptr |
||
) |
Returns true if S
is valid UTF-8, which is required for use as JSON.
If it returns false, Offset
is set to a byte offset near the first error.
Definition at line 694 of file JSON.cpp.
References llvm::Data, llvm::isLegalUTF8String(), LLVM_LIKELY, and S.
Referenced by llvm::json::OStream::attributeBegin(), llvm::json::ObjectKey::ObjectKey(), and llvm::json::Value::Value().
Definition at line 516 of file JSON.h.
References llvm::RISCVFenceField::R.
|
inline |
Serializes this Value to JSON, writing it to the provided stream.
The formatting is compact (no extra whitespace) and deterministic. For pretty-printing, use the formatv() format_provider below.
Definition at line 1031 of file JSON.h.
References llvm::json::OStream::value().
Definition at line 182 of file JSON.cpp.
References llvm::json::Value::Array, llvm::json::Value::Boolean, llvm::json::Value::getAsArray(), llvm::json::Value::getAsBoolean(), llvm::json::Value::getAsInteger(), llvm::json::Value::getAsNull(), llvm::json::Value::getAsNumber(), llvm::json::Value::getAsObject(), llvm::json::Value::getAsString(), llvm::json::Value::kind(), llvm_unreachable, llvm::json::Value::Null, llvm::json::Value::Number, llvm::json::Value::Object, and llvm::json::Value::String.
Expected<T> llvm::json::parse | ( | const llvm::StringRef & | JSON, |
const char * | RootName = "" |
||
) |
Expected< Value > llvm::json::parse | ( | llvm::StringRef | JSON | ) |
|
static |
Definition at line 725 of file JSON.cpp.
References llvm::Lower, S, and llvm::write_hex().
Referenced by llvm::json::OStream::attributeBegin(), and llvm::json::OStream::value().