aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Object/YAML.cpp
blob: 36b19974b0e35f54f8caac26c09f6352bca202a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//===- YAML.cpp - YAMLIO utilities for object files -----------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines utility classes for handling the YAML representation of
// object files.
//
//===----------------------------------------------------------------------===//

#include "llvm/Object/YAML.h"

using namespace llvm;

void yaml::ScalarTraits<object::yaml::BinaryRef>::output(
    const object::yaml::BinaryRef &Val, void *, llvm::raw_ostream &Out) {
  ArrayRef<uint8_t> Data = Val.getBinary();
  for (ArrayRef<uint8_t>::iterator I = Data.begin(), E = Data.end(); I != E;
       ++I) {
    uint8_t Byte = *I;
    Out << hexdigit(Byte >> 4);
    Out << hexdigit(Byte & 0xf);
  }
}

StringRef yaml::ScalarTraits<object::yaml::BinaryRef>::input(
    StringRef Scalar, void *, object::yaml::BinaryRef &Val) {
  Val = object::yaml::BinaryRef(Scalar);
  return StringRef();
}