~ubuntu-branches/ubuntu/quantal/llvm-3.1/quantal

« back to all changes in this revision

Viewing changes to include/llvm/Object/Error.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-03-29 19:09:51 UTC
  • Revision ID: package-import@ubuntu.com-20120329190951-aq83ivog4cg8bxun
Tags: upstream-3.1~svn153643
ImportĀ upstreamĀ versionĀ 3.1~svn153643

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- Error.h - system_error extensions for Object -------------*- 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
// This declares a new error_category for the Object library.
 
11
//
 
12
//===----------------------------------------------------------------------===//
 
13
 
 
14
#ifndef LLVM_OBJECT_ERROR_H
 
15
#define LLVM_OBJECT_ERROR_H
 
16
 
 
17
#include "llvm/Support/system_error.h"
 
18
 
 
19
namespace llvm {
 
20
namespace object {
 
21
 
 
22
const error_category &object_category();
 
23
 
 
24
struct object_error {
 
25
enum _ {
 
26
  success = 0,
 
27
  invalid_file_type,
 
28
  parse_failed,
 
29
  unexpected_eof
 
30
};
 
31
  _ v_;
 
32
 
 
33
  object_error(_ v) : v_(v) {}
 
34
  explicit object_error(int v) : v_(_(v)) {}
 
35
  operator int() const {return v_;}
 
36
};
 
37
 
 
38
inline error_code make_error_code(object_error e) {
 
39
  return error_code(static_cast<int>(e), object_category());
 
40
}
 
41
 
 
42
} // end namespace object.
 
43
 
 
44
template <> struct is_error_code_enum<object::object_error> : true_type { };
 
45
 
 
46
template <> struct is_error_code_enum<object::object_error::_> : true_type { };
 
47
 
 
48
} // end namespace llvm.
 
49
 
 
50
#endif