summaryrefslogtreecommitdiff
path: root/src/squelch
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2017-05-02 19:20:57 +0200
committerBardur Arantsson <bardur@scientician.net>2017-05-02 19:20:57 +0200
commit90a81c722fa22de210878f7cf708dcc13d2520b9 (patch)
treee065e12cc935433b3181ef02a9d9ebcfc248bba0 /src/squelch
parenta031f2e1b6a8742c44db8cac59d3d8f71f80eea4 (diff)
Change Rule::{get_set,}name methods to use std::string
Diffstat (limited to 'src/squelch')
-rw-r--r--src/squelch/automatizer.cc9
-rw-r--r--src/squelch/condition_metadata.cc4
-rw-r--r--src/squelch/rule.cc7
3 files changed, 10 insertions, 10 deletions
diff --git a/src/squelch/automatizer.cc b/src/squelch/automatizer.cc
index 2f177ef9..dbf8fa03 100644
--- a/src/squelch/automatizer.cc
+++ b/src/squelch/automatizer.cc
@@ -205,13 +205,14 @@ void Automatizer::add_new_condition(std::function<std::shared_ptr<Condition> ()>
factory);
}
-void Automatizer::get_rule_names(std::vector<const char *> *names) const
+std::vector<std::string> Automatizer::get_rule_names() const
{
- names->resize(m_rules.size());
- for (size_t i = 0; i < m_rules.size(); i++)
+ std::vector<std::string> names(m_rules.size());
+ for (auto const &rule: m_rules)
{
- (*names)[i] = m_rules.at(i)->get_name();
+ names.push_back(rule->get_name());
}
+ return names;
}
int Automatizer::rules_count() const
diff --git a/src/squelch/condition_metadata.cc b/src/squelch/condition_metadata.cc
index 5f91bbfb..f6d4370c 100644
--- a/src/squelch/condition_metadata.cc
+++ b/src/squelch/condition_metadata.cc
@@ -392,7 +392,7 @@ std::shared_ptr<Condition> new_condition_interactive()
match_type::INVENTORY,
match_type::EQUIPMENT
};
- static std::vector<const char *> condition_type_names;
+ static std::vector<std::string> condition_type_names;
// Fill in types names?
if (condition_type_names.empty())
@@ -412,7 +412,7 @@ std::shared_ptr<Condition> new_condition_interactive()
Term_clear();
Term_get_size(&wid, &hgt);
- display_list(0, 0, hgt - 1, 15, "Rule types", condition_type_names.data(), condition_types.size(), begin, sel, TERM_L_GREEN);
+ display_list(0, 0, hgt - 1, 15, "Rule types", condition_type_names, begin, sel, TERM_L_GREEN);
display_desc(condition_types[sel]);
diff --git a/src/squelch/rule.cc b/src/squelch/rule.cc
index 50a771ae..e35b3ce1 100644
--- a/src/squelch/rule.cc
+++ b/src/squelch/rule.cc
@@ -25,15 +25,14 @@ EnumStringMap<action_type> &action_mapping()
return *m;
}
-void Rule::set_name(const char *new_name)
+void Rule::set_name(std::string const &new_name)
{
- assert(new_name != nullptr);
m_name = new_name;
}
-const char *Rule::get_name() const
+std::string Rule::get_name() const
{
- return m_name.c_str();
+ return m_name;
}
std::shared_ptr<Condition> Rule::get_condition() const