Clean includes and usings
These changes are based on suggestions made by the include-what-you-use
tool. Some suggestions were not implemented because they did not
decrease build time (forward-declaring some classes), or because they
would make the include section too complicated (Spirit headers and MPL
headers). On my computer, this change decreases the build time by about
27%:
before
real 1m45.807s
user 5m40.648s
sys 0m18.274s
after
real 1m18.013s
user 3m57.866s
sys 0m12.946s
Change-Id: I11e4f30f4e7518506a213537daae9c41d52b4ac4
diff --git a/src/ast_commands.hpp b/src/ast_commands.hpp
index 32dba64..5f8f052 100644
--- a/src/ast_commands.hpp
+++ b/src/ast_commands.hpp
@@ -8,31 +8,11 @@
#pragma once
#include <boost/mpl/vector.hpp>
+#include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
#include "ast_path.hpp"
#include "ast_values.hpp"
namespace x3 = boost::spirit::x3;
-namespace ascii = boost::spirit::x3::ascii;
-
-using ascii::space;
-using x3::_attr;
-using x3::alnum;
-using x3::alpha;
-using x3::char_;
-using x3::double_;
-using x3::expect;
-using x3::int8;
-using x3::int16;
-using x3::int32;
-using x3::int64;
-using x3::lexeme;
-using x3::lit;
-using x3::uint8;
-using x3::uint16;
-using x3::uint32;
-using x3::uint64;
-
-struct parser_context_tag;
using keyValue_ = std::pair<std::string, std::string>;
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 69af5ac..fd7f52e 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -9,8 +9,11 @@
#pragma once
#include <boost/mpl/for_each.hpp>
+#include <boost/spirit/home/x3.hpp>
+#include <boost/spirit/home/x3/support/utility/error_reporting.hpp>
+
+
#include "ast_commands.hpp"
-#include "parser_context.hpp"
#include "schema.hpp"
#include "utils.hpp"
namespace x3 = boost::spirit::x3;
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index 3547f04..861e52d 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -7,6 +7,7 @@
*/
#include <experimental/iterator>
+#include <sstream>
#include "ast_path.hpp"
#include "utils.hpp"
diff --git a/src/ast_path.hpp b/src/ast_path.hpp
index dcd13ff..a893e19 100644
--- a/src/ast_path.hpp
+++ b/src/ast_path.hpp
@@ -7,14 +7,10 @@
*/
#pragma once
-#include <boost/spirit/home/x3.hpp>
-#include <boost/spirit/home/x3/support/ast/position_tagged.hpp>
-#include <boost/spirit/home/x3/support/utility/error_reporting.hpp>
-
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/std_pair.hpp>
-#include <boost/variant.hpp>
+#include <boost/variant/variant.hpp>
#include <map>
#include <vector>
diff --git a/src/grammars.hpp b/src/grammars.hpp
index 276e716..95814e7 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -8,6 +8,7 @@
#pragma once
+#include <boost/spirit/home/x3.hpp>
#include "ast_commands.hpp"
#include "ast_handlers.hpp"
@@ -81,6 +82,26 @@
#pragma GCC diagnostic ignored "-Woverloaded-shift-op-parentheses"
#endif
+namespace ascii = boost::spirit::x3::ascii;
+
+using ascii::space;
+using x3::_attr;
+using x3::alnum;
+using x3::alpha;
+using x3::char_;
+using x3::double_;
+using x3::expect;
+using x3::lexeme;
+using x3::lit;
+using x3::int8;
+using x3::int16;
+using x3::int32;
+using x3::int64;
+using x3::uint8;
+using x3::uint16;
+using x3::uint32;
+using x3::uint64;
+
auto const key_identifier_def =
lexeme[
((alpha | char_("_")) >> *(alnum | char_("_") | char_("-") | char_(".")))
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index d9d5214..b469149 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -6,9 +6,11 @@
*
*/
+#include <boost/mpl/for_each.hpp>
#include <iostream>
#include "datastore_access.hpp"
#include "interpreter.hpp"
+#include "utils.hpp"
void Interpreter::operator()(const commit_&) const
{
diff --git a/src/main.cpp b/src/main.cpp
index 3019d36..354114f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,14 +6,13 @@
*
*/
#include <docopt.h>
-#include <experimental/filesystem>
#include <iostream>
+#include <sstream>
#include <optional>
#include <replxx.hxx>
#include "NETCONF_CLI_VERSION.h"
#include "interpreter.hpp"
#include "sysrepo_access.hpp"
-#include "yang_schema.hpp"
const auto HISTORY_FILE_NAME = "netconf-cli_history";
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index d10dd2f..73d8433 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -12,7 +12,6 @@
#include <nc_client.h>
}
#include <sstream>
-#include <tuple>
#include "netconf-client.h"
namespace libnetconf {
diff --git a/src/netconf_access.hpp b/src/netconf_access.hpp
index 1c9fb04..4c0e813 100644
--- a/src/netconf_access.hpp
+++ b/src/netconf_access.hpp
@@ -8,7 +8,6 @@
#pragma once
#include <string>
-#include "ast_commands.hpp"
#include "datastore_access.hpp"
/*! \class NetconfAccess
diff --git a/src/parser.cpp b/src/parser.cpp
index 26e417f..420db27 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -6,7 +6,9 @@
*
*/
#include <ostream>
+#include "grammars.hpp"
#include "parser.hpp"
+#include "parser_context.hpp"
TooManyArgumentsException::~TooManyArgumentsException() = default;
diff --git a/src/parser.hpp b/src/parser.hpp
index 8c9290f..29ce3f1 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -7,8 +7,9 @@
*/
#pragma once
-#include <boost/spirit/home/x3.hpp>
-#include "grammars.hpp"
+#include "ast_commands.hpp"
+#include "ast_path.hpp"
+#include "schema.hpp"
class InvalidCommandException : public std::invalid_argument {
diff --git a/src/schema.hpp b/src/schema.hpp
index 145ab07..199cb96 100644
--- a/src/schema.hpp
+++ b/src/schema.hpp
@@ -9,7 +9,7 @@
#pragma once
-#include <boost/variant.hpp>
+#include <boost/variant/variant.hpp>
#include <set>
#include <stdexcept>
#include <unordered_map>
diff --git a/src/static_schema.hpp b/src/static_schema.hpp
index 3071e4c..3121e0e 100644
--- a/src/static_schema.hpp
+++ b/src/static_schema.hpp
@@ -9,7 +9,6 @@
#pragma once
#include <set>
-#include <stdexcept>
#include <unordered_map>
#include "ast_path.hpp"
#include "schema.hpp"
diff --git a/src/sysrepo_access.hpp b/src/sysrepo_access.hpp
index a771360..8df1153 100644
--- a/src/sysrepo_access.hpp
+++ b/src/sysrepo_access.hpp
@@ -9,7 +9,6 @@
#pragma once
#include <string>
-#include "ast_commands.hpp"
#include "datastore_access.hpp"
/*! \class DatastoreAccess
diff --git a/src/utils.cpp b/src/utils.cpp
index cd1cf4b..d06d35b 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -5,8 +5,8 @@
* Written by Václav Kubernát <kubervac@fit.cvut.cz>
*
*/
-#include <boost/algorithm/string/erase.hpp>
#include <boost/algorithm/string/predicate.hpp>
+#include <sstream>
#include "utils.hpp"
std::string joinPaths(const std::string& prefix, const std::string& suffix)
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index 4565150..3621c17 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -11,8 +11,6 @@
#include <functional>
#include <optional>
#include <set>
-#include <stdexcept>
-#include <unordered_map>
#include "ast_path.hpp"
#include "schema.hpp"
diff --git a/tests/enum_completion.cpp b/tests/enum_completion.cpp
index 5cb5744..f3cb2e9 100644
--- a/tests/enum_completion.cpp
+++ b/tests/enum_completion.cpp
@@ -8,7 +8,6 @@
*/
#include "trompeloeil_doctest.h"
-#include "ast_commands.hpp"
#include "parser.hpp"
#include "static_schema.hpp"
diff --git a/tests/leaf_editing.cpp b/tests/leaf_editing.cpp
index 1ec4be4..b0db594 100644
--- a/tests/leaf_editing.cpp
+++ b/tests/leaf_editing.cpp
@@ -11,6 +11,7 @@
#include "ast_commands.hpp"
#include "parser.hpp"
#include "static_schema.hpp"
+#include "utils.hpp"
std::ostream& operator<<(std::ostream& s, const set_ cmd)
{
diff --git a/tests/path_completion.cpp b/tests/path_completion.cpp
index 0e66595..6744aed 100644
--- a/tests/path_completion.cpp
+++ b/tests/path_completion.cpp
@@ -7,7 +7,6 @@
*/
#include "trompeloeil_doctest.h"
-#include "ast_commands.hpp"
#include "parser.hpp"
#include "static_schema.hpp"