/
cleantype_configuration.hpp
96 lines (80 loc) · 3.39 KB
/
cleantype_configuration.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// This file is part of cleantype: Clean Types for C++
// Copyright Pascal Thomet - 2018
// Distributed under the Boost Software License, Version 1.0. (see LICENSE.md)
#pragma once
#include <array>
#include <fstream>
#include <map>
#include <string>
#include <vector>
// In order to configure the behavior of clean types :
//
// * Duplicate the file .cleantype.json at the root of the cleantype repository,
// and save this file in anywhere in the hierarchy of the parent directories
// of the execution directory.
// * Edit this file as a normal json file (you can use also use an online editor like
// https://jsoneditoronline.org/)
// * #define CLEANTYPE_USE_NLOHMANN_JSON before including this file and
// add the include path to nlohmann/json.hpp)
namespace cleantype
{
struct CleanConfiguration;
namespace internal
{
CleanConfiguration ImplGlobalConfig();
} // namespace internal
struct CleanConfiguration
{
std::vector<std::string> suppress_extra_namespaces_ = {"::__1", "::__cxx11"};
// unnecessary class, struct given by msvc
std::vector<std::string> suppress_extract_struct_class_ = {"class ", "struct "};
// add your custom suppressions here
std::vector<std::string> suppress_custom_ = {" __ptr64"};
// these node are suppressed after parse of the template tree of a type
std::vector<std::string> undesirable_type_nodes_ = {
"std::char_traits", "std::allocator", "std::less"};
std::map<std::string, std::string> replacements_after_undesirable_node_extractions = {
{"std::basic_string<char>", "std::string"},
{"basic_string<_CharT, _Traits, _Allocator>", "std::string"}};
// set this to true in order to force the results to be east const
// this is experimental, and can fail
bool force_east_const_ = false;
// * any type with a depth <= indent_depth_limit
// will be presented on a single line
// * any type with a depth > indent_depth_limit
// will be presented on several indented lines
// set indent_depth_limit = 0 to disable indentation
std::size_t indent_depth_limit = 3;
inline static CleanConfiguration & GlobalConfig()
{
thread_local CleanConfiguration gCleanConfiguration = internal::ImplGlobalConfig();
return gCleanConfiguration;
}
inline static CleanConfiguration _EmptyConfig()
{
CleanConfiguration r;
r.suppress_extra_namespaces_ = {};
r.suppress_extract_struct_class_ = {};
r.suppress_custom_ = {};
r.undesirable_type_nodes_ = {};
r.replacements_after_undesirable_node_extractions = {};
r.force_east_const_ = false;
r.indent_depth_limit = 0;
return r;
}
};
inline bool force_east_const() { return CleanConfiguration::GlobalConfig().force_east_const_; }
inline void set_force_east_const(bool v)
{
CleanConfiguration::GlobalConfig().force_east_const_ = v;
}
inline std::size_t indent_depth_limit()
{
return CleanConfiguration::GlobalConfig().indent_depth_limit;
}
inline void set_indent_depth_limit(std::size_t v)
{
CleanConfiguration::GlobalConfig().indent_depth_limit = v;
}
} // namespace cleantype
#include <cleantype/details/cleantype_configuration_json.hpp>