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

Allow INIReader to read 64-bit integers #151

Merged
merged 6 commits into from
Jul 7, 2023
Merged

Allow INIReader to read 64-bit integers #151

merged 6 commits into from
Jul 7, 2023

Conversation

mayak-dev
Copy link
Contributor

In some cases, it may be desired to read (unsigned) integer values outside of the 32-bit bounds. In 32-bit code, however, this might not be the case since doing so by default would cost performance. Rather than changing the types delivered by INIReader::GetInteger and INIReader::GetUnsigned, a good way to accommodate is to add separate methods capable of reading (unsigned) 64-bit integers.

Copy link
Owner

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I'm happy to add these, however, one small comment about the test value, and a couple of questions about naming and types.

cpp/INIReader.cpp Outdated Show resolved Hide resolved
examples/test.ini Outdated Show resolved Hide resolved
@mayak-dev mayak-dev changed the title Add INIReader::GetBigInteger and INIReader::GetBigUnsigned Allow INIReader to read 64-bit integers Jul 6, 2023
mayak-dev added 2 commits July 6, 2023 21:14
Fixed-width type definitions were already accessible with `<map>` included, but it's nice to include this header anyways.
@mayak-dev mayak-dev requested a review from benhoyt July 7, 2023 01:44
cpp/INIReader.h Outdated
INI_API unsigned long GetUnsigned(const std::string& section, const std::string& name, unsigned long default_value) const;

// Get an unsigned 64-bit integer (uint64_t) value from INI file, returning default_value if
// not found or not a valid unsigned integer (decimal "1234", "-1234", or hex "0x4d2").
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the "-1234" example here, as it's incorrect for unsigned.

Copy link
Owner

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now! Requesting one very minor change to remove the "-1234" example from GetUnsigned64.

@benhoyt benhoyt merged commit 9cecf06 into benhoyt:master Jul 7, 2023
@benhoyt
Copy link
Owner

benhoyt commented Jul 7, 2023

Thanks for your contribution. Just tagged release r57.

@mayak-dev
Copy link
Contributor Author

Awesome! Glad I could contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants