Line data Source code
1 : //
2 : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2013-2015, 2017
3 : //
4 : // Copyright: See COPYING file that comes with this distribution
5 : //
6 : #pragma once
7 :
8 : #include <wlog/formatter/formatter_options.hpp>
9 : #include <wlogjson/resolutions_json.hpp>
10 : #include <wlogjson/colorized_flags_json.hpp>
11 : #include <wlogjson/hide_flags_json.hpp>
12 : #include <wjson/json.hpp>
13 : #include <wjson/name.hpp>
14 :
15 : namespace wlog{
16 :
17 : struct formatter_options_json
18 : {
19 12 : JSON_NAME(name_width)
20 12 : JSON_NAME(ident_width)
21 :
22 12 : JSON_NAME(colorized)
23 12 : JSON_NAME(resolution)
24 12 : JSON_NAME(hide)
25 12 : JSON_NAME(locale)
26 12 : JSON_NAME(datetime_format)
27 12 : JSON_NAME(color_map)
28 :
29 : struct full_color
30 : {
31 6 : colorized_flags operator()(const formatter_options& opt) const
32 : {
33 6 : return opt.colorized == colorized_flags::all ? colorized_flags::all4json : opt.colorized;
34 : }
35 :
36 6 : void operator()(formatter_options& opt, colorized_flags value) const
37 : {
38 6 : opt.colorized = value == colorized_flags::all4json ? colorized_flags::all : value;
39 6 : }
40 : };
41 :
42 : typedef wjson::object<
43 : formatter_options,
44 : wjson::member_list<
45 : wjson::member<n_name_width, formatter_options, int, &formatter_options::name_width>,
46 : wjson::member<n_ident_width, formatter_options, int, &formatter_options::ident_width>,
47 : wjson::member<n_resolution, formatter_options, resolutions, &formatter_options::resolution, resolutions_json>,
48 : wjson::member<n_datetime_format, formatter_options, std::string, &formatter_options::datetime_format>,
49 : wjson::member<n_hide, formatter_options, hide_flags, &formatter_options::hide, hide_flags_json>,
50 : wjson::member<n_locale, formatter_options, std::string, &formatter_options::locale>,
51 : wjson::member_p<n_colorized, formatter_options, colorized_flags, full_color, colorized_flags_json>,
52 : wjson::member<n_color_map, formatter_options, std::map<std::string, std::string>, &formatter_options::color_map,
53 : wjson::dict_map< wjson::value<std::string> > >
54 : >,
55 : wjson::strict_mode
56 : > type;
57 : typedef type::serializer serializer;
58 : typedef type::target target;
59 : typedef type::member_list member_list;
60 : };
61 :
62 :
63 : }
|