2023-01-19 05:46:11 +02:00
|
|
|
// Copyright 2023 Peter Dimov.
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt
|
|
|
|
|
2023-01-19 11:13:40 +02:00
|
|
|
#include <boost/system/error_category.hpp>
|
2023-01-19 05:46:11 +02:00
|
|
|
#include <boost/core/lightweight_test.hpp>
|
2023-01-20 04:39:08 +02:00
|
|
|
#include <boost/core/snprintf.hpp>
|
2023-01-19 05:46:11 +02:00
|
|
|
#include <system_error>
|
|
|
|
|
2023-01-19 11:13:40 +02:00
|
|
|
// get_user_category
|
|
|
|
|
|
|
|
class user_category: public boost::system::error_category
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2024-01-17 07:14:05 +02:00
|
|
|
virtual const char * name() const noexcept
|
2023-01-19 11:13:40 +02:00
|
|
|
{
|
|
|
|
return "user";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string message( int ev ) const
|
|
|
|
{
|
|
|
|
char buffer[ 256 ];
|
2023-01-20 04:39:08 +02:00
|
|
|
boost::core::snprintf( buffer, sizeof( buffer ), "user message %d", ev );
|
2023-01-19 11:13:40 +02:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
boost::system::error_category const & get_user_category()
|
|
|
|
{
|
|
|
|
static user_category instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2023-01-19 05:46:11 +02:00
|
|
|
bool init_lwt = (boost::core::lwt_init(), true);
|
|
|
|
|
2023-01-19 11:13:40 +02:00
|
|
|
std::error_category const & cat = get_user_category();
|
2023-01-19 05:46:11 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2023-01-19 11:13:40 +02:00
|
|
|
BOOST_TEST_CSTR_EQ( cat.name(), "user" );
|
2023-01-19 05:46:11 +02:00
|
|
|
return boost::report_errors();
|
|
|
|
}
|