Remove unnecessary Boost header includes

Don't bother using Boost.Format for exception messages, just concat
strings, and don't unnecessarily use case-insensitive comparisons for
message types.
This commit is contained in:
Oliver Hamlet
2018-08-21 19:28:57 +01:00
parent 0c43424a6e
commit f0283435f6
14 changed files with 23 additions and 58 deletions
-2
View File
@@ -27,8 +27,6 @@
#include <unordered_map>
#include <vector>
#include <boost/algorithm/string.hpp>
#include "api/game/game.h"
#include "api/metadata/condition_evaluator.h"
#include "api/metadata/yaml/plugin_metadata.h"
-1
View File
@@ -26,7 +26,6 @@
#include <thread>
#include <boost/algorithm/string.hpp>
#include <boost/locale.hpp>
using boost::locale::to_lower;
+1 -6
View File
@@ -24,13 +24,9 @@
#include "api/game/load_order_handler.h"
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include "api/helpers/logging.h"
#include "loot/exception/error_categories.h"
using boost::format;
using std::string;
namespace loot {
@@ -194,8 +190,7 @@ void LoadOrderHandler::HandleError(const std::string& operation,
err = "libloadorder failed to " + operation +
". Details could not be fetched.";
} else {
err = (format("libloadorder failed to " + operation + ". Details: %1%") % e)
.str();
err = "libloadorder failed to " + operation + ". Details: " + e;
}
auto logger = getLogger();
+3 -5
View File
@@ -26,7 +26,7 @@
#include <boost/crc.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/format.hpp>
#include "api/helpers/logging.h"
#include "loot/exception/file_access_error.h"
@@ -77,10 +77,8 @@ uint32_t GetCrc32(const boost::filesystem::path& filename) {
return checksum;
} catch (std::exception& e) {
throw FileAccessError(
(boost::format("Unable to open \"%1%\" for CRC calculation: %2%") %
filename.string() % e.what())
.str());
throw FileAccessError("Unable to open \"" + filename.string() +
"\" for CRC calulation: " + e.what());
}
}
}
+1 -4
View File
@@ -27,8 +27,6 @@
#include <iomanip>
#include <sstream>
#include <boost/format.hpp>
#include "api/helpers/logging.h"
#include "loot/exception/error_categories.h"
#include "loot/exception/git_state_error.h"
@@ -154,8 +152,7 @@ void GitHelper::Call(int error_code) {
gitError = std::to_string(error_code) + "; " + last_error->message;
giterr_clear();
auto message =
(boost::format("Git operation failed. Details: %1%") % gitError).str();
auto message = "Git operation failed. Details: " + gitError;
throw std::system_error(error_code, libgit2_category(), message);
}
-3
View File
@@ -24,15 +24,12 @@
#include "api/masterlist.h"
#include <boost/format.hpp>
#include "api/game/game.h"
#include "api/helpers/git_helper.h"
#include "api/helpers/logging.h"
#include "loot/exception/file_access_error.h"
#include "loot/exception/git_state_error.h"
using boost::format;
using std::string;
namespace fs = boost::filesystem;
+7 -18
View File
@@ -24,16 +24,11 @@
#include "api/metadata/condition_evaluator.h"
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include "api/helpers/crc.h"
#include "api/helpers/logging.h"
#include "api/metadata/condition_grammar.h"
#include "loot/exception/condition_syntax_error.h"
using boost::format;
namespace loot {
ConditionEvaluator::ConditionEvaluator() :
gameType_(GameType::tes4),
@@ -318,8 +313,7 @@ void ConditionEvaluator::validatePath(const boost::filesystem::path& path) {
continue;
if (component == ".." && temp.filename() == "..") {
throw ConditionSyntaxError(
(format("Invalid file path: %1%") % path.string()).str());
throw ConditionSyntaxError("Invalid file path: " + path.string());
}
temp /= component;
@@ -329,9 +323,8 @@ void ConditionEvaluator::validateRegex(const std::string& regexString) {
try {
std::regex(regexString, std::regex::ECMAScript | std::regex::icase);
} catch (std::regex_error& e) {
throw ConditionSyntaxError(
(format("Invalid regex string \"%1%\": %2%") % regexString % e.what())
.str());
throw ConditionSyntaxError("Invalid regex string \"" + regexString +
"\": " + e.what());
}
}
@@ -373,9 +366,8 @@ std::pair<boost::filesystem::path, std::regex> ConditionEvaluator::splitRegex(
try {
reg = std::regex(filename, std::regex::ECMAScript | std::regex::icase);
} catch (std::regex_error& e) {
throw ConditionSyntaxError(
(format("Invalid regex string \"%1%\": %2%") % filename % e.what())
.str());
throw ConditionSyntaxError("Invalid regex string \"" + filename +
"\": " + e.what());
}
return std::pair<boost::filesystem::path, std::regex>(parent, reg);
@@ -445,11 +437,8 @@ bool ConditionEvaluator::parseCondition(const std::string& condition) const {
boost::spirit::qi::phrase_parse(begin, end, grammar, skipper, evaluation);
if (!parseResult || begin != end) {
throw ConditionSyntaxError(
(boost::format("Failed to parse condition \"%1%\": only partially "
"matched expected syntax.") %
condition)
.str());
throw ConditionSyntaxError("Failed to parse condition \"" + condition +
"\": only partially matched expected syntax.");
}
return evaluation;
+6 -8
View File
@@ -33,15 +33,15 @@
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#endif
#include <cstdint>
#include <regex>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/spirit/include/phoenix_bind.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/qi.hpp>
#include <cstdint>
#include <regex>
#include "api/game/game.h"
#include "api/helpers/logging.h"
@@ -286,11 +286,9 @@ private:
std::string context(errorpos, last);
boost::trim(context);
throw ConditionSyntaxError(
(boost::format("Failed to parse condition \"%1%\": expected \"%2%\" at "
"\"%3%\".") %
condition % what.tag % context)
.str());
throw ConditionSyntaxError("Failed to parse condition \"" + condition +
"\": expected \"" + what.tag + "\" at \"" +
context + "\".");
}
boost::spirit::qi::rule<Iterator, bool(), Skipper> expression_, compound_,
-2
View File
@@ -24,8 +24,6 @@
#include "loot/metadata/group.h"
#include <boost/algorithm/string.hpp>
#include "api/metadata/yaml/group.h"
namespace loot {
+2 -3
View File
@@ -28,7 +28,6 @@
#include <vector>
#include <yaml-cpp/yaml.h>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include "loot/metadata/message.h"
@@ -70,9 +69,9 @@ struct convert<loot::Message> {
type = node["type"].as<std::string>();
loot::MessageType typeNo = loot::MessageType::say;
if (boost::iequals(type, "warn"))
if (type == "warn")
typeNo = loot::MessageType::warn;
else if (boost::iequals(type, "error"))
else if (type == "error")
typeNo = loot::MessageType::error;
std::vector<loot::MessageContent> content;
-1
View File
@@ -24,7 +24,6 @@
#include "api/metadata_list.h"
#include <boost/algorithm/string.hpp>
#include <boost/filesystem/fstream.hpp>
#include "api/game/game.h"
+1 -4
View File
@@ -28,7 +28,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/locale.hpp>
#include "api/game/game.h"
@@ -125,9 +124,7 @@ Plugin::Plugin(const GameType gameType,
logger->error(
"Cannot read plugin file \"{}\". Details: {}", name_, e.what());
}
throw FileAccessError(
(boost::format("Cannot read \"%1%\". Details: %2%") % name % e.what())
.str());
throw FileAccessError("Cannot read \"" + name + "\". Details: " + e.what());
}
if (logger) {
-1
View File
@@ -31,7 +31,6 @@
#include <type_traits>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <esplugin.hpp>
#include "api/game/load_order_handler.h"
+2
View File
@@ -24,6 +24,8 @@
#include "plugin_sorting_data.h"
#include <boost/algorithm/string.hpp>
namespace loot {
PluginSortingData::PluginSortingData(const Plugin& plugin,
const PluginMetadata&& metadata) :