[yaml2obj][ELF] Add an optional `Size` field to the YAML section declaration.
[oota-llvm.git] / tools / obj2yaml / Error.h
1 //===- Error.h - system_error extensions for obj2yaml -----------*- C++ -*-===//
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 #ifndef LLVM_TOOLS_ERROR_H
11 #define LLVM_TOOLS_ERROR_H
12
13 #include "llvm/Support/system_error.h"
14
15 namespace llvm {
16
17 const error_category &obj2yaml_category();
18
19 struct obj2yaml_error {
20   enum _ {
21     success = 0,
22     file_not_found,
23     unrecognized_file_format,
24     unsupported_obj_file_format
25   };
26   _ v_;
27
28   obj2yaml_error(_ v) : v_(v) {}
29   explicit obj2yaml_error(int v) : v_(_(v)) {}
30   operator int() const {return v_;}
31 };
32
33 inline error_code make_error_code(obj2yaml_error e) {
34   return error_code(static_cast<int>(e), obj2yaml_category());
35 }
36
37 template <> struct is_error_code_enum<obj2yaml_error> : std::true_type { };
38 template <> struct is_error_code_enum<obj2yaml_error::_> : std::true_type { };
39
40 } // namespace llvm
41
42 #endif