36b19974b0e35f54f8caac26c09f6352bca202a3
[oota-llvm.git] / lib / Object / YAML.cpp
1 //===- YAML.cpp - YAMLIO utilities for object files -----------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines utility classes for handling the YAML representation of
11 // object files.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "llvm/Object/YAML.h"
16
17 using namespace llvm;
18
19 void yaml::ScalarTraits<object::yaml::BinaryRef>::output(
20     const object::yaml::BinaryRef &Val, void *, llvm::raw_ostream &Out) {
21   ArrayRef<uint8_t> Data = Val.getBinary();
22   for (ArrayRef<uint8_t>::iterator I = Data.begin(), E = Data.end(); I != E;
23        ++I) {
24     uint8_t Byte = *I;
25     Out << hexdigit(Byte >> 4);
26     Out << hexdigit(Byte & 0xf);
27   }
28 }
29
30 StringRef yaml::ScalarTraits<object::yaml::BinaryRef>::input(
31     StringRef Scalar, void *, object::yaml::BinaryRef &Val) {
32   Val = object::yaml::BinaryRef(Scalar);
33   return StringRef();
34 }