changeset 840:fdb1e0f5fd6d

irccd: use std::size_t rather than unsigned
author David Demelier <markand@malikania.fr>
date Tue, 30 Apr 2019 13:49:11 +0200
parents e7709755e557
children 1399755352e7
files irccdctl/cli.cpp libirccd-daemon/irccd/daemon/rule_service.cpp libirccd-daemon/irccd/daemon/rule_service.hpp libirccd-daemon/irccd/daemon/transport_command.cpp
diffstat 4 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/irccdctl/cli.cpp	Mon Apr 29 12:22:44 2019 +0200
+++ b/irccdctl/cli.cpp	Tue Apr 30 13:49:11 2019 +0200
@@ -535,7 +535,7 @@
 	}
 
 	// Index.
-	std::optional<unsigned> index;
+	std::optional<std::size_t> index;
 
 	if (result.count("-i") > 0 && !(index = string_util::to_uint(result.find("-i")->second)))
 		throw std::invalid_argument("invalid index argument");
--- a/libirccd-daemon/irccd/daemon/rule_service.cpp	Mon Apr 29 12:22:44 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/rule_service.cpp	Tue Apr 30 13:49:11 2019 +0200
@@ -45,21 +45,21 @@
 	rules_.push_back(std::move(rule));
 }
 
-void rule_service::insert(rule rule, unsigned position)
+void rule_service::insert(rule rule, std::size_t position)
 {
 	assert(position <= rules_.size());
 
 	rules_.insert(rules_.begin() + position, std::move(rule));
 }
 
-void rule_service::remove(unsigned position)
+void rule_service::remove(std::size_t position)
 {
 	assert(position < rules_.size());
 
 	rules_.erase(rules_.begin() + position);
 }
 
-auto rule_service::require(unsigned position) const -> const rule&
+auto rule_service::require(std::size_t position) const -> const rule&
 {
 	if (position >= rules_.size())
 		throw rule_error(rule_error::invalid_index);
@@ -67,7 +67,7 @@
 	return rules_[position];
 }
 
-auto rule_service::require(unsigned position) -> rule&
+auto rule_service::require(std::size_t position) -> rule&
 {
 	if (position >= rules_.size())
 		throw rule_error(rule_error::invalid_index);
--- a/libirccd-daemon/irccd/daemon/rule_service.hpp	Mon Apr 29 12:22:44 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/rule_service.hpp	Tue Apr 30 13:49:11 2019 +0200
@@ -77,7 +77,7 @@
 	 * \param rule the rule
 	 * \param position the position
 	 */
-	void insert(rule rule, unsigned position);
+	void insert(rule rule, std::size_t position);
 
 	/**
 	 * Remove a new rule from the specified position.
@@ -85,7 +85,7 @@
 	 * \pre position must be valid
 	 * \param position the position
 	 */
-	void remove(unsigned position);
+	void remove(std::size_t position);
 
 	/**
 	 * Get a rule at the specified index or throw an exception if not found.
@@ -94,14 +94,14 @@
 	 * \return the rule
 	 * \throw std::out_of_range if position is invalid
 	 */
-	auto require(unsigned position) const -> const rule&;
+	auto require(std::size_t position) const -> const rule&;
 
 	/**
 	 * Overloaded function.
 	 *
 	 * \copydoc require
 	 */
-	auto require(unsigned position) -> rule&;
+	auto require(std::size_t position) -> rule&;
 
 	/**
 	 * Resolve the action to execute with the specified list of rules.
--- a/libirccd-daemon/irccd/daemon/transport_command.cpp	Mon Apr 29 12:22:44 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/transport_command.cpp	Tue Apr 30 13:49:11 2019 +0200
@@ -268,7 +268,7 @@
 
 void rule_add_command::exec(bot& bot, transport_client& client, const document& args)
 {
-	const auto index = args.optional<unsigned>("index", bot.rules().list().size());
+	const auto index = args.optional<std::size_t>("index", bot.rules().list().size());
 
 	if (!index || *index > bot.rules().list().size())
 		throw rule_error(rule_error::error::invalid_index);
@@ -299,7 +299,7 @@
 		}
 	};
 
-	const auto index = args.get<unsigned>("index");
+	const auto index = args.get<std::size_t>("index");
 
 	if (!index)
 		throw rule_error(rule_error::invalid_index);
@@ -342,7 +342,7 @@
 
 void rule_info_command::exec(bot& bot, transport_client& client, const document& args)
 {
-	const auto index = args.get<unsigned>("index");
+	const auto index = args.get<std::size_t>("index");
 
 	if (!index)
 		throw rule_error(rule_error::invalid_index);
@@ -386,8 +386,8 @@
 
 void rule_move_command::exec(bot& bot, transport_client& client, const document& args)
 {
-	const auto from = args.get<unsigned>("from");
-	const auto to = args.get<unsigned>("to");
+	const auto from = args.get<std::size_t>("from");
+	const auto to = args.get<std::size_t>("to");
 
 	if (!from || !to)
 		throw rule_error(rule_error::invalid_index);
@@ -449,7 +449,7 @@
 
 void rule_remove_command::exec(bot& bot, transport_client& client, const document& args)
 {
-	const auto index = args.get<unsigned>("index");
+	const auto index = args.get<std::size_t>("index");
 
 	if (!index || *index >= bot.rules().list().size())
 		throw rule_error(rule_error::invalid_index);