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 "platform_config.hpp"
13 
14 #include <boost/config/warning_disable.hpp>
15 
16 #include <boost/filesystem/path_traits.hpp>
17 #include <boost/system/error_code.hpp>
18 #include <locale>
19 #include <vector>
20 #include <cstdlib>
21 #include <cassert>
22 
23 //--------------------------------------------------------------------------------------//
24 
25 namespace
26 {
27   class codecvt_error_cat : public boost::system::error_category
28   {
29   public:
codecvt_error_cat()30     codecvt_error_cat(){}
31     const char*   name() const BOOST_SYSTEM_NOEXCEPT BOOST_OVERRIDE;
32     std::string    message(int ev) const BOOST_OVERRIDE;
33   };
34 
name() const35   const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT
36   {
37     return "codecvt";
38   }
39 
message(int ev) const40   std::string codecvt_error_cat::message(int ev) const
41   {
42     std::string str;
43     switch (ev)
44     {
45     case std::codecvt_base::ok:
46       str = "ok";
47       break;
48     case std::codecvt_base::partial:
49       str = "partial";
50       break;
51     case std::codecvt_base::error:
52       str = "error";
53       break;
54     case std::codecvt_base::noconv:
55       str = "noconv";
56       break;
57     default:
58       str = "unknown error";
59     }
60     return str;
61   }
62 
63 } // unnamed namespace
64 
65 namespace boost
66 {
67   namespace filesystem
68   {
69 
codecvt_error_category()70     BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
71     {
72       static const codecvt_error_cat  codecvt_error_cat_const;
73       return codecvt_error_cat_const;
74     }
75 
76   } // namespace filesystem
77 } // namespace boost
78