-
Notifications
You must be signed in to change notification settings - Fork 1
Added error messages #3
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
Conversation
I'll submit my review tomorrow, there are a few edge cases that I want to test |
@@ -65,7 +81,20 @@ std::int32_t pini::get_int32(std::string const& key, std::uint32_t def) const { | |||
|
|||
std::string_view pini::get_string(std::string const& key) const { | |||
auto it = key_value_pairs.find(key); | |||
if (it == key_value_pairs.end()) { return {}; } | |||
if (it == key_value_pairs.end()) { | |||
if (pn::pini::on_msg_t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you ok with repeating this pattern every time you need to log stuff? There are ways to make it more succinct.
} | ||
return ret; | ||
} | ||
|
||
std::unordered_map<std::string, std::string> insert_pairs(std::vector<std::string> file_lines) { | ||
std::unordered_map<std::string, std::string> key_value_pairs; | ||
|
||
std::size_t line_number = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, you used size_t and not int
// std::filesystem::path filename{"/test/test.ini"}; | ||
if (!pin.load_text(raw_input)) { return 1; } | ||
if (pin.get_int32("a") != 5) { return 1; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with this line?
if (pin.get_int32("a") != 5) { return 1; } | ||
std::cout << pin.get_int32("a"); | ||
std::cout << pin.get_int32("b"); | ||
std::cout << pin.get_int32("c"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put some more failure cases instead of just printing stuff: you won't see these logs via ctest / through CI etc.
Added:
#
which can be considered comments are ignored