LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
system_error.cpp
Go to the documentation of this file.
1 //===---------------------- system_error.cpp ------------------------------===//
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 was lifted from libc++ and modified for C++03.
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/Support/Errno.h"
16 #include <cstring>
17 #include <string>
18 
19 namespace llvm {
20 
21 // class error_category
22 
23 error_category::error_category() {
24 }
25 
27 }
28 
31  return error_condition(ev, *this);
32 }
33 
34 bool
35 error_category::equivalent(int code, const error_condition& condition) const {
36  return default_error_condition(code) == condition;
37 }
38 
39 bool
40 error_category::equivalent(const error_code& code, int condition) const {
41  return *this == code.category() && code.value() == condition;
42 }
43 
44 std::string
45 _do_message::message(int ev) const {
46  return std::string(sys::StrError(ev));
47 }
48 
50 public:
51  virtual const char* name() const LLVM_OVERRIDE;
52  virtual std::string message(int ev) const LLVM_OVERRIDE;
53 };
54 
55 const char*
57  return "generic";
58 }
59 
60 std::string
62 #ifdef ELAST
63  if (ev > ELAST)
64  return std::string("unspecified generic_category error");
65 #endif // ELAST
66  return _do_message::message(ev);
67 }
68 
69 const error_category&
71  static _generic_error_category s;
72  return s;
73 }
74 
76 public:
77  virtual const char* name() const LLVM_OVERRIDE;
78  virtual std::string message(int ev) const LLVM_OVERRIDE;
80 };
81 
82 const char*
84  return "system";
85 }
86 
87 // std::string _system_error_category::message(int ev) const {
88 // Is in Platform/system_error.inc
89 
90 // error_condition _system_error_category::default_error_condition(int ev) const
91 // Is in Platform/system_error.inc
92 
93 const error_category&
95  static _system_error_category s;
96  return s;
97 }
98 
99 const error_category&
101 #ifdef LLVM_ON_WIN32
102  return generic_category();
103 #else
104  return system_category();
105 #endif
106 }
107 
108 // error_condition
109 
110 std::string
112  return _cat_->message(_val_);
113 }
114 
115 // error_code
116 
117 std::string
119  return _cat_->message(_val_);
120 }
121 
122 } // end namespace llvm
123 
124 // Include the truly platform-specific parts of this class.
125 #if defined(LLVM_ON_UNIX)
126 #include "Unix/system_error.inc"
127 #endif
128 #if defined(LLVM_ON_WIN32)
129 #include "Windows/system_error.inc"
130 #endif
const error_category & system_category()
virtual error_condition default_error_condition(int ev) const LLVM_OVERRIDE
const error_category & category() const
Definition: system_error.h:767
virtual const char * name() const LLVM_OVERRIDE
std::string StrError()
Definition: Errno.cpp:32
virtual std::string message(int ev) const LLVM_OVERRIDE
const error_category & posix_category()
virtual const char * name() const LLVM_OVERRIDE
virtual error_condition default_error_condition(int _ev) const
virtual bool equivalent(int _code, const error_condition &_condition) const
virtual std::string message(int ev) const LLVM_OVERRIDE
std::string message() const
virtual std::string message(int _ev) const =0
std::string message() const
int value() const
Definition: system_error.h:765
const error_category & generic_category()
virtual std::string message(int ev) const LLVM_OVERRIDE
#define LLVM_OVERRIDE
Definition: Compiler.h:155