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

Add support for binary integer values #236

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 22 additions & 13 deletions doc/libconfig.texi
Copy link
Owner

Choose a reason for hiding this comment

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

Please also update the C++ section of the documentation; there's a 'format' enum there as well

Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ application:
bigint = 9223372036854775807L;
columns = [ "Last Name", "First Name", "MI" ];
bitmask = 0x1FC3; // hex
bitmask2 = 0b1011; // binary
umask = 0027; // octal. Range limited to that of "int"
@};
@};
Expand Down Expand Up @@ -509,24 +510,26 @@ The last element in a list may be followed by a comma, which will be ignored.
@comment node-name, next, previous, up
@section Integer Values

Integers can be represented in one of two ways: as a series of one or
more decimal digits (@samp{0} - @samp{9}), with an optional leading
sign character (@samp{+} or @samp{-}); or as a hexadecimal value
consisting of the characters @samp{0x} followed by a series of one or
more hexadecimal digits (@samp{0} - @samp{9}, @samp{A} - @samp{F},
@samp{a} - @samp{f}). Additionally, octal notation integers (that is,
those having a leading zero with non-zero value) are also allowed.
Integers can be represented in one of two ways: as a series of one or more
Copy link
Owner

@hyperrealm hyperrealm Apr 25, 2024

Choose a reason for hiding this comment

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

s/one of two/the following/

decimal digits (@samp{0} - @samp{9}), with an optional leading sign character
(@samp{+} or @samp{-}); as a hexadecimal value consisting of the characters
@samp{0x} followed by a series of one or more hexadecimal digits (@samp{0} -
@samp{9}, @samp{A} - @samp{F}, @samp{a} - @samp{f}); or (as of version 1.7.4 of
the library) as a binary value consisting of the characters @samp{0b} followed
by a series of @samp{0}s or @samp{1}s. Additionally, octal notation integers
(that is, those having a leading zero with non-zero value) are also allowed.

@node 64-bit Integer Values, Floating Point Values, Integer Values, Configuration Files
@comment node-name, next, previous, up
@section 64-bit Integer Values

Long long (64-bit) integers are represented identically to integers,
except that an `L' character is appended to indicate a 64-bit
value. For example, @samp{0L} indicates a 64-bit integer value 0. As
of version 1.5 of the library, the trailing `L' is optional; if the
integer value exceeds the range of a 32-bit integer, it will
automatically be interpreted as a 64-bit integer.
Long long (64-bit) integers are represented identically to integers, except
that an `L' character is appended to indicate a 64-bit value. For example,
@samp{0L} indicates a 64-bit integer value 0. As of version 1.5 of the
library, the trailing `L' is optional; if the integer value exceeds the range
of a 32-bit integer, it will automatically be interpreted as a 64-bit integer.
As of version 1.7.4 of the library this behavior is extended to hexadecimal
(and binary) integers as well.
Copy link
Owner

Choose a reason for hiding this comment

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

no need for parens around 'and binary'


The @i{integer} and @i{64-bit integer} setting types are interchangeable to the
extent that a conversion between the corresponding native types would not
Expand Down Expand Up @@ -2464,6 +2467,8 @@ directives are not part of the grammar, so they are not included here.
<boolean>
| <integer>
| <integer64>
| <bin>
| <bin64>
| <hex>
| <hex64>
| <float>
Expand Down Expand Up @@ -2501,6 +2506,10 @@ Terminals are defined below as regular expressions:
@code{[-+]?[0-9]+}
@item @code{<integer64>} @tab
@code{[-+]?[0-9]+L(L)?}
@item @code{<bin>} @tab
@code{0[bB][01]+}
@item @code{<bin64>} @tab
@code{0[bB][01]+L(L)?}
@item @code{<hex>} @tab
@code{0[Xx][0-9A-Fa-f]+}
@item @code{<hex64>} @tab
Expand Down
Loading