1224133Sdim//===- Error.h - system_error extensions for Object -------------*- C++ -*-===//
2224133Sdim//
3224133Sdim//                     The LLVM Compiler Infrastructure
4224133Sdim//
5224133Sdim// This file is distributed under the University of Illinois Open Source
6224133Sdim// License. See LICENSE.TXT for details.
7224133Sdim//
8224133Sdim//===----------------------------------------------------------------------===//
9224133Sdim//
10224133Sdim// This declares a new error_category for the Object library.
11224133Sdim//
12224133Sdim//===----------------------------------------------------------------------===//
13224133Sdim
14224133Sdim#ifndef LLVM_OBJECT_ERROR_H
15224133Sdim#define LLVM_OBJECT_ERROR_H
16224133Sdim
17224133Sdim#include "llvm/Support/system_error.h"
18224133Sdim
19224133Sdimnamespace llvm {
20224133Sdimnamespace object {
21224133Sdim
22224133Sdimconst error_category &object_category();
23224133Sdim
24224133Sdimstruct object_error {
25263508Sdim  enum Impl {
26263508Sdim    success = 0,
27263508Sdim    arch_not_found,
28263508Sdim    invalid_file_type,
29263508Sdim    parse_failed,
30263508Sdim    unexpected_eof
31263508Sdim  };
32263508Sdim  Impl V;
33224133Sdim
34263508Sdim  object_error(Impl V) : V(V) {}
35263508Sdim  operator Impl() const { return V; }
36224133Sdim};
37224133Sdim
38224133Sdiminline error_code make_error_code(object_error e) {
39224133Sdim  return error_code(static_cast<int>(e), object_category());
40224133Sdim}
41224133Sdim
42224133Sdim} // end namespace object.
43224133Sdim
44224133Sdimtemplate <> struct is_error_code_enum<object::object_error> : true_type { };
45224133Sdim
46263508Sdimtemplate <> struct is_error_code_enum<object::object_error::Impl> : true_type {
47263508Sdim};
48224133Sdim
49224133Sdim} // end namespace llvm.
50224133Sdim
51224133Sdim#endif
52