llvm/llvm/include/llvm/BinaryFormat/MsgPackReader.h

//===- MsgPackReader.h - Simple MsgPack reader ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
///  \file
///  This is a MessagePack reader.
///
///  See https://github.com/msgpack/msgpack/blob/master/spec.md for the full
///  standard.
///
///  Typical usage:
///  \code
///  StringRef input = GetInput();
///  msgpack::Reader MPReader(input);
///  msgpack::Object Obj;
///
///  while (true) {
///    Expected<bool> ReadObj = MPReader.read(&Obj);
///    if (!ReadObj)
///      // Handle error...
///    if (!ReadObj.get())
///      break; // Reached end of input
///    switch (Obj.Kind) {
///    case msgpack::Type::Int:
//       // Use Obj.Int
///      break;
///    // ...
///    }
///  }
///  \endcode
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_BINARYFORMAT_MSGPACKREADER_H
#define LLVM_BINARYFORMAT_MSGPACKREADER_H

#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBufferRef.h"
#include <cstdint>

namespace llvm {
namespace msgpack {

/// MessagePack types as defined in the standard, with the exception of Integer
/// being divided into a signed Int and unsigned UInt variant in order to map
/// directly to C++ types.
///
/// The types map onto corresponding union members of the \c Object struct.
enum class Type : uint8_t {};

/// Extension types are composed of a user-defined type ID and an uninterpreted
/// sequence of bytes.
struct ExtensionType {};

/// MessagePack object, represented as a tagged union of C++ types.
///
/// All types except \c Type::Nil (which has only one value, and so is
/// completely represented by the \c Kind itself) map to a exactly one union
/// member.
struct Object {};

/// Reads MessagePack objects from memory, one at a time.
class Reader {};

} // end namespace msgpack
} // end namespace llvm

#endif // LLVM_BINARYFORMAT_MSGPACKREADER_H