/** * src/config/config.h * * Copyright (c) 2021-2022 Bartek Kryza * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "class_diagram/model/diagram.h" #include "common/model/enums.h" #include "option.h" #include "util/util.h" #include #include #include #include #include #include #include #include namespace clanguml { namespace config { enum class method_arguments { full, abbreviated, none }; enum class comment_parser_t { plain, clang }; struct plantuml { std::vector before; std::vector after; void append(const plantuml &r); }; struct filter { std::vector namespaces; std::vector elements; // E.g.: // - inheritance/extension // - dependency // - instantiation std::vector relationships; // E.g.: // - public // - protected // - private std::vector access; std::vector subclasses; std::vector specializations; std::vector dependants; std::vector dependencies; std::vector context; std::vector paths; }; enum class hint_t { up, down, left, right }; struct layout_hint { hint_t hint{hint_t::up}; std::string entity; }; using layout_hints = std::map>; struct generate_links_config { std::string link; std::string tooltip; }; struct git_config { std::string branch; std::string revision; std::string commit; std::string toplevel; }; struct relationship_hint_t { std::map argument_hints; common::model::relationship_t default_hint; relationship_hint_t(common::model::relationship_t def = common::model::relationship_t::kAggregation) : default_hint{def} { } common::model::relationship_t get(unsigned int argument_index) const { if (argument_hints.count(argument_index) > 0) return argument_hints.at(argument_index); return default_hint; } }; using relationship_hints_t = std::map; using type_aliases_t = std::map; std::string to_string(hint_t t); struct inheritable_diagram_options { option> glob{"glob"}; option using_namespace{"using_namespace"}; option include_relations_also_as_members{ "include_relations_also_as_members", true}; option include{"include"}; option exclude{"exclude"}; option puml{"plantuml", option_inherit_mode::kAppend}; option generate_method_arguments{ "generate_method_arguments", method_arguments::full}; option generate_packages{"generate_packages", false}; option generate_links{"generate_links"}; option git{"git"}; option base_directory{"__parent_path"}; option relative_to{"relative_to"}; option generate_system_headers{"generate_system_headers", false}; option relationship_hints{"relationship_hints"}; option type_aliases{"type_aliases"}; option comment_parser{ "comment_parser", comment_parser_t::plain}; option combine_free_functions_into_file_participants{ "combine_free_functions_into_file_participants", false}; option> participants_order{"participants_order"}; void inherit(const inheritable_diagram_options &parent); std::string simplify_template_type(std::string full_name) const; }; struct diagram : public inheritable_diagram_options { virtual ~diagram() = default; virtual common::model::diagram_t type() const = 0; std::vector get_translation_units( const std::filesystem::path &root_directory) const; void initialize_type_aliases(); std::string name; }; struct source_location { enum class location_t { usr, marker, fileline, function }; location_t location_type{location_t::function}; std::string location; }; struct class_diagram : public diagram { ~class_diagram() override = default; common::model::diagram_t type() const override; option> classes{"classes"}; option layout{"layout"}; void initialize_relationship_hints(); }; struct sequence_diagram : public diagram { ~sequence_diagram() override = default; common::model::diagram_t type() const override; option> start_from{"start_from"}; }; struct package_diagram : public diagram { ~package_diagram() override = default; common::model::diagram_t type() const override; option layout{"layout"}; }; struct include_diagram : public diagram { ~include_diagram() override = default; common::model::diagram_t type() const override; option layout{"layout"}; }; struct config : public inheritable_diagram_options { // the glob list is additive and relative to the current // directory option compilation_database_dir{ "compilation_database_dir", "."}; option output_directory{"output_directory"}; std::map> diagrams; }; config load(const std::string &config_file); } // namespace config } // namespace clanguml