Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use string views #1177

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions include/dpp/appcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ struct DPP_EXPORT command_option_choice : public json_interface<command_option_c
* @param _name name of command option choice in the specified language
* @return command_option_choice& reference to self for fluent chaining
*/
command_option_choice& add_localization(const std::string& language, const std::string& _name);
command_option_choice& add_localization(std::string_view language, std::string_view _name);

/**
* @brief Construct a new command option choice object
*
* @param n name to initialise with
* @param v value to initialise with
*/
command_option_choice(const std::string &n, command_value v);
command_option_choice(std::string_view n, command_value v);
};

/**
Expand Down Expand Up @@ -305,7 +305,7 @@ struct DPP_EXPORT command_option : public json_interface<command_option> {
* @param _description description of slash command option in the specified language (optional)
* @return command_option& reference to self for fluent chaining
*/
command_option& add_localization(const std::string& language, const std::string& _name, const std::string& _description = "");
command_option& add_localization(std::string_view language, std::string_view _name, std::string_view _description = "");

/**
* @brief Construct a new command option object
Expand All @@ -315,7 +315,7 @@ struct DPP_EXPORT command_option : public json_interface<command_option> {
* @param description Option description
* @param required True if this is a mandatory parameter
*/
command_option(command_option_type t, const std::string &name, const std::string &description, bool required = false);
command_option(command_option_type t, std::string_view name, std::string_view description, bool required = false);

/**
* @brief Add a multiple choice option
Expand Down Expand Up @@ -602,23 +602,23 @@ struct DPP_EXPORT interaction_modal_response : public interaction_response, publ
* @param _title Title of the modal form. It will be truncated to the maximum length of 45 UTF-8 characters.
* @param _components Components to add to the modal form
*/
interaction_modal_response(const std::string& _custom_id, const std::string& _title, const std::vector<component> _components = {});
interaction_modal_response(std::string_view _custom_id, std::string_view _title, const std::vector<component> _components = {});

/**
* @brief Set the custom id
*
* @param _custom_id custom id to set
* @return interaction_modal_response& Reference to self
*/
interaction_modal_response& set_custom_id(const std::string& _custom_id);
interaction_modal_response& set_custom_id(std::string_view _custom_id);

/**
* @brief Set the title
*
* @param _title title to set
* @return interaction_modal_response& Reference to self
*/
interaction_modal_response& set_title(const std::string& _title);
interaction_modal_response& set_title(std::string_view _title);

/**
* @brief Add a component to an interaction modal response
Expand Down Expand Up @@ -1445,7 +1445,7 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
* @param _description Command description
* @param _application_id Application id (usually the bot's user id)
*/
slashcommand(const std::string &_name, const std::string &_description, const dpp::snowflake _application_id);
slashcommand(std::string_view _name, std::string_view _description, const dpp::snowflake _application_id);

/**
* @brief Construct a new slashcommand object
Expand All @@ -1454,7 +1454,7 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
* @param _type Context menu type
* @param _application_id Application id (usually the bot's user id)
*/
slashcommand(const std::string &_name, const slashcommand_contextmenu_type _type, const dpp::snowflake _application_id);
slashcommand(std::string_view _name, const slashcommand_contextmenu_type _type, const dpp::snowflake _application_id);

/**
* @brief Destroy the slashcommand object
Expand All @@ -1469,7 +1469,7 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
* @param _description description of slash command in the specified language (optional)
* @return slashcommand& reference to self for chaining of calls
*/
slashcommand& add_localization(const std::string& language, const std::string& _name, const std::string& _description = "");
slashcommand& add_localization(std::string_view language, std::string_view _name, std::string_view _description = "");

/**
* @brief Set the dm permission for the command
Expand Down Expand Up @@ -1523,7 +1523,7 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
* The command name will be set to lowercase when the type is the default dpp::ctxm_chat_input.
* @return slashcommand& reference to self for chaining of calls
*/
slashcommand& set_name(const std::string &n);
slashcommand& set_name(std::string_view n);

/**
* @brief Set the description of the command
Expand All @@ -1533,7 +1533,7 @@ class DPP_EXPORT slashcommand : public managed, public json_interface<slashcomma
* If your command description is longer than this, it will be truncated.
* @return slashcommand& reference to self for chaining of calls
*/
slashcommand& set_description(const std::string &d);
slashcommand& set_description(std::string_view d);

/**
* @brief Set the application id of the command
Expand Down
2 changes: 1 addition & 1 deletion include/dpp/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DPP_EXPORT bignumber {
* @note Prefixing number_string with 0x will parse it as hexadecimal.
* This is not case sensitive.
*/
bignumber(const std::string& number_string);
bignumber(std::string_view number_string);

/**
* @brief Build a bignumber from a vector of 64 bit values.
Expand Down
8 changes: 4 additions & 4 deletions include/dpp/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ struct DPP_EXPORT forum_tag : public managed, public json_interface<forum_tag> {
*
* @param name The name of the tag. It will be truncated to the maximum length of 20 UTF-8 characters.
*/
forum_tag(const std::string& name);
forum_tag(std::string_view name);

/** Destructor */
virtual ~forum_tag() = default;
Expand All @@ -329,7 +329,7 @@ struct DPP_EXPORT forum_tag : public managed, public json_interface<forum_tag> {
*
* @note name will be truncated to 20 chars, if longer
*/
forum_tag& set_name(const std::string& name);
forum_tag& set_name(std::string_view name);
};

/**
Expand Down Expand Up @@ -499,7 +499,7 @@ class DPP_EXPORT channel : public managed, public json_interface<channel> {
* @note name will be truncated to 100 chars, if longer
* @throw dpp::length_exception if length < 1
*/
channel& set_name(const std::string& name);
channel& set_name(std::string_view name);

/**
* @brief Set topic of this channel object
Expand All @@ -509,7 +509,7 @@ class DPP_EXPORT channel : public managed, public json_interface<channel> {
*
* @note topic will be truncated to 1024 chars, if longer
*/
channel& set_topic(const std::string& topic);
channel& set_topic(std::string_view topic);

/**
* @brief Set type of this channel object
Expand Down
Loading
Loading