Skip to content

Add reader class #1

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

Merged
merged 8 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix get_pairs()
  • Loading branch information
NikolaJelic committed Jun 27, 2021
commit 9670b767c24e91e096522af167cb5fca76811e35
2 changes: 0 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ int main() {
std::string_view raw_input{"a=5\nb=10\n23=c"};
std::filesystem::path filename{"test/test.ini"};

std::unordered_map<std::string, std::string> map = pin.get_pairs();

std::cout << std::boolalpha << pin.load_file(filename) << "\n";
std::cout << "attack: " << pin.get_uint32("attack ") << "\n";
std::cout << "def " << pin.get_uint64("def ") << "\n";
Expand Down
2 changes: 0 additions & 2 deletions src/pini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

namespace pn {
namespace {

pini::map_type read_file(std::filesystem::path const& filename) {
std::vector<std::string> lines = util::get_lines(filename);

return util::insert_pairs(lines);
}

Expand Down
2 changes: 1 addition & 1 deletion src/pini.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class pini {
public:
using map_type = std::unordered_map<std::string, std::string>;

map_type get_pairs() { return key_value_pairs; }
const map_type& get_pairs() const { return key_value_pairs; }
bool load_file(std::filesystem::path const& filename);
bool load_text(std::string_view text);

Expand Down