1 //===---------------------- system_error.cpp ------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This was lifted from libc++ and modified for C++03.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/system_error.h"
15 #include "llvm/Support/Errno.h"
21 // class error_category
23 error_category::error_category() {
26 error_category::~error_category() {
30 error_category::default_error_condition(int ev) const {
31 return error_condition(ev, *this);
35 error_category::equivalent(int code, const error_condition& condition) const {
36 return default_error_condition(code) == condition;
40 error_category::equivalent(const error_code& code, int condition) const {
41 return *this == code.category() && code.value() == condition;
45 _do_message::message(int ev) const {
46 return std::string(sys::StrError(ev));
49 class _generic_error_category : public _do_message {
51 virtual const char* name() const;
52 virtual std::string message(int ev) const;
56 _generic_error_category::name() const {
61 _generic_error_category::message(int ev) const {
64 return std::string("unspecified generic_category error");
66 return _do_message::message(ev);
71 static _generic_error_category s;
75 class _system_error_category : public _do_message {
77 virtual const char* name() const;
78 virtual std::string message(int ev) const;
79 virtual error_condition default_error_condition(int ev) const;
83 _system_error_category::name() const {
87 // std::string _system_error_category::message(int ev) const {
88 // Is in Platform/system_error.inc
90 // error_condition _system_error_category::default_error_condition(int ev) const
91 // Is in Platform/system_error.inc
95 static _system_error_category s;
102 return generic_category();
104 return system_category();
111 error_condition::message() const {
112 return _cat_->message(_val_);
118 error_code::message() const {
119 return _cat_->message(_val_);
122 } // end namespace llvm
124 // Include the truly platform-specific parts of this class.
125 #if defined(LLVM_ON_UNIX)
126 #include "Unix/system_error.inc"
128 #if defined(LLVM_ON_WIN32)
129 #include "Windows/system_error.inc"