Skip to content

Add non-template get_xxx/is_xxx methods to element#949

Merged
jkeiser merged 6 commits intomasterfrom
jkeiser/get-type
Jun 21, 2020
Merged

Add non-template get_xxx/is_xxx methods to element#949
jkeiser merged 6 commits intomasterfrom
jkeiser/get-type

Conversation

@jkeiser
Copy link
Copy Markdown
Member

@jkeiser jkeiser commented Jun 19, 2020

This fixes #781, adding to both element and result:

  • get_array, get_object, get_string, get_c_str, get_int64_t, get_uint64_t, get_double, get_bool
  • is_array, is_object, is_string, is_c_str, is_int64_t, is_uint64_t, is_double, is_bool

I'm unsure about the naming of get_double, get_int64_t and get_uint64_t. I could see get_float, get_integer and get_unsigned as well, but went with this because then I don't have to introduce concepts.

To accomplish this, I also had to move internal::tape_ref out of the way: it has some methods with the same name, and that was causing C++ confusion. Instead of being a base class of element, internal::tape_ref is now a member. I did the same for array and object and their iterators as well, for consistency. This is nice in part because now there isn't a distracting private base class for these classes in the documentation. It's all hidden exactly as it should be.

I also refactored the casting tests some so that I could easily add tests for this functionality.

@jkeiser
Copy link
Copy Markdown
Member Author

jkeiser commented Jun 20, 2020

@lemire the other PR is based on this one (because tests), FYI, in case you didn't see this.

@jkeiser
Copy link
Copy Markdown
Member Author

jkeiser commented Jun 20, 2020

(As usual, no actual rush.)

@jkeiser
Copy link
Copy Markdown
Member Author

jkeiser commented Jun 20, 2020

(I just rebased the other PR without this, not too many changes, that way progress can occur.)

Copy link
Copy Markdown
Member

@lemire lemire left a comment

Choose a reason for hiding this comment

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

Obviously very nice.

I guess that there is no need to update the markdown documentation?

@jkeiser
Copy link
Copy Markdown
Member Author

jkeiser commented Jun 21, 2020

@lemire I think it could use some ... I'm just not sure what yet. The get(T) patch interacts with it a ton.

@jkeiser
Copy link
Copy Markdown
Member Author

jkeiser commented Jun 21, 2020

@lemire I'm going to merge this and move forward, but we need to think about whether get_unsigned or get_uint64_t or something else suits us better. I haven't found a rubrick that lets me say one is clearly better than the other. I'm a little worried about uint64_t in particular because my impression is different people use different type names for the unsigned 64-bit int.

@jkeiser jkeiser merged commit a5ccff7 into master Jun 21, 2020
@jkeiser jkeiser deleted the jkeiser/get-type branch June 21, 2020 00:35
@lemire
Copy link
Copy Markdown
Member

lemire commented Jun 21, 2020

get_unsigned or get_uint64_t or something else suits us better. I haven't found a rubrick that lets me say one is clearly better than the other. I'm a little worried about uint64_t in particular because my impression is different people use different type names for the unsigned 64-bit int.

I think we need to move to "get_uint64".

I think that the "_t" is actually a mistake. It is meant to tell you that the name is a type.So "get_uint64_t" to me means the type named "get_uint64". The "_t" suffix should be reserved for types.

(Sorry if I did not catch it right away. It took me some time to think it through.)

@jkeiser
Copy link
Copy Markdown
Member Author

jkeiser commented Jun 21, 2020

@lemire I'm good with that. It's a small change we can make pre-0.4.

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.

Add get_string, get_number... methods to the API as well as is_string, is_number... (don't force templates)

2 participants