integers of different sizes #209
-
i am looking for support for representing integers of different sizes like int8 , int16, int32 , int64 , i don't see any support readily available in the library. please advise. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Have you already checked |
Beta Was this translation helpful? Give feedback.
-
yeah, but pardon my C++ ignorance, i looked but still clueless on the usage. any example would be of great help. my requirement is i have sized integers like int8 , int16 , int32 , int64 in my example and i am clueless on how to define them. |
Beta Was this translation helpful? Give feedback.
-
Could you please elaborate on how exactly your question is connected to parsing? What are you trying to achieve with your example? Parse integers? |
Beta Was this translation helpful? Give feedback.
-
yes, while parsing integers how do we enforce the limits for different sizes ?? |
Beta Was this translation helpful? Give feedback.
-
You can use |
Beta Was this translation helpful? Give feedback.
You can use
maximum_rule< std::uint8_t >
, as seen intao/pegtl/contrib/uri.hpp
. The maximum_rule allows you to specify the datatype into which a parsed number must fit, as well as an optional maximum value. You could usemaximum_rule< std::uint8_t, 123 >
as a rule that parses/matches any number from 0 to 123.