Browse Source

Fix missing headers breaking compilation on GCC-10; minor improvements to app_parameters

master
Jessica James 3 years ago
parent
commit
25198a3c77
  1. 2
      src/bot/main.cpp
  2. 6
      src/common/app_parameters.cpp
  3. 4
      src/include/jessilib/app_parameters.hpp
  4. 1
      src/include/jessilib/split.hpp
  5. 1
      src/include/jessilib/word_split.hpp

2
src/bot/main.cpp

@ -24,7 +24,7 @@
int main(int argc, char** argv) {
jessilib::app_parameters parameters{ argc, argv };
if (parameters.hasSwitch("echoParameters")) {
if (parameters.has_switch("echoParameters")) {
// TODO: Write pretty JSON serializer based on JSON serializer
std::cout << std::endl << jessilib::json_parser{}.serialize(parameters) << std::endl;
}

6
src/common/app_parameters.cpp

@ -130,16 +130,16 @@ object app_parameters::as_object() const {
};
}
bool app_parameters::hasSwitch(std::string_view in_switch) const {
bool app_parameters::has_switch(std::string_view in_switch) const {
return m_switches_set.find(in_switch) != m_switches_set.end();
}
std::string_view app_parameters::getValue(std::string_view in_key) const {
std::string_view app_parameters::get_value(std::string_view in_key, std::string_view in_default) const {
auto result = m_values.find(in_key);
// Safety check
if (result == m_values.end()) {
return {};
return in_default;
}
return result->second;

4
src/include/jessilib/app_parameters.hpp

@ -32,8 +32,8 @@ public:
const std::unordered_map<std::string_view, std::string>& values() const;
jessilib::object as_object() const;
bool hasSwitch(std::string_view in_switch) const;
std::string_view getValue(std::string_view in_key) const;
bool has_switch(std::string_view in_switch) const;
std::string_view get_value(std::string_view in_key, std::string_view in_default = {}) const;
operator jessilib::object() const { return as_object(); }

1
src/include/jessilib/split.hpp

@ -27,6 +27,7 @@
#include <string_view>
#include <vector>
#include <tuple>
namespace jessilib {

1
src/include/jessilib/word_split.hpp

@ -27,6 +27,7 @@
#include <string_view>
#include <vector>
#include <tuple>
namespace jessilib {

Loading…
Cancel
Save