Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / filesystem / src / codecvt_error_category.cpp
1 //  codecvt_error_category implementation file  ----------------------------------------//
2
3 //  Copyright Beman Dawes 2009
4
5 //  Distributed under the Boost Software License, Version 1.0.
6 //  See http://www.boost.org/LICENSE_1_0.txt)
7
8 //  Library home page at http://www.boost.org/libs/filesystem
9
10 //--------------------------------------------------------------------------------------//
11
12 #include <boost/config/warning_disable.hpp>
13
14 #ifndef BOOST_SYSTEM_NO_DEPRECATED
15 #  define BOOST_SYSTEM_NO_DEPRECATED
16 #endif
17
18 #include <boost/filesystem/config.hpp>
19 #include <boost/filesystem/path_traits.hpp>
20 #include <boost/system/error_code.hpp>
21 #include <locale>
22 #include <vector>
23 #include <cstdlib>
24 #include <cassert>
25
26 //--------------------------------------------------------------------------------------//
27
28 namespace
29 {
30   class codecvt_error_cat : public boost::system::error_category
31   {
32   public:
33     codecvt_error_cat(){}
34     const char*   name() const BOOST_SYSTEM_NOEXCEPT;
35     std::string    message(int ev) const;
36   };
37
38   const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT
39   {
40     return "codecvt";
41   }
42
43   std::string codecvt_error_cat::message(int ev) const
44   {
45     std::string str;
46     switch (ev)
47     {
48     case std::codecvt_base::ok:
49       str = "ok";
50       break;
51     case std::codecvt_base::partial:
52       str = "partial";
53       break;
54     case std::codecvt_base::error:
55       str = "error";
56       break;
57     case std::codecvt_base::noconv:
58       str = "noconv";
59       break;
60     default:
61       str = "unknown error";
62     }
63     return str;
64   }
65
66 } // unnamed namespace
67
68 namespace boost
69 {
70   namespace filesystem
71   {
72
73     BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
74     {
75       static const codecvt_error_cat  codecvt_error_cat_const;
76       return codecvt_error_cat_const;
77     }
78
79   } // namespace filesystem
80 } // namespace boost