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// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
15// the library is being built (possibly exporting rather than importing code)
16#define BOOST_FILESYSTEM_SOURCE
17
18#ifndef BOOST_SYSTEM_NO_DEPRECATED
19# define BOOST_SYSTEM_NO_DEPRECATED
20#endif
21
22#include <boost/filesystem/config.hpp>
23#include <boost/filesystem/path_traits.hpp>
24#include <boost/system/error_code.hpp>
25#include <locale>
26#include <vector>
27#include <cstdlib>
28#include <cassert>
29
30//--------------------------------------------------------------------------------------//
31
32namespace
33{
34 class codecvt_error_cat : public boost::system::error_category
35 {
36 public:
37 codecvt_error_cat(){}
38 const char* name() const BOOST_SYSTEM_NOEXCEPT;
39 std::string message(int ev) const;
40 };
41
42 const char* codecvt_error_cat::name() const BOOST_SYSTEM_NOEXCEPT
43 {
44 return "codecvt";
45 }
46
47 std::string codecvt_error_cat::message(int ev) const
48 {
49 std::string str;
50 switch (ev)
51 {
52 case std::codecvt_base::ok:
53 str = "ok";
54 break;
55 case std::codecvt_base::partial:
56 str = "partial";
57 break;
58 case std::codecvt_base::error:
59 str = "error";
60 break;
61 case std::codecvt_base::noconv:
62 str = "noconv";
63 break;
64 default:
65 str = "unknown error";
66 }
67 return str;
68 }
69
70} // unnamed namespace
71
72namespace boost
73{
74 namespace filesystem
75 {
76
77 BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
78 {
79 static const codecvt_error_cat codecvt_error_cat_const;
80 return codecvt_error_cat_const;
81 }
82
83 } // namespace filesystem
84} // namespace boost
85