Skip to content

[C++] Add a struct_ overload taking a vector of (name, type) pairs #36867

Closed

Description

@pitrou

Describe the enhancement requested

It would be nice to be able to write:

 struct_({{"a", int8()}, {"b", utf8()}});

instead of:

 struct_({field("a", int8()), field("b", utf8())});

Same with the schema factory.

Component(s)

C++

Activity

  1. jsjtxietian commented on Jul 25, 2023

    @jsjtxietian
    Contributor

    I can take this issue if no one has started working on it yet.

  2. pitrou commented on Jul 25, 2023

    @pitrou
    MemberAuthor

    @jsjtxietian Yes, you can submit a PR if you want.

  3. jsjtxietian commented on Jul 26, 2023

    @jsjtxietian
    Contributor

    @pitrou Hi,I have a question regarding this issue and I want to ask for your advice.

    In this code, because field is a function with default parameters, one can pass not only name and type to this function, but also nullable and metadata
    struct_({field("a", int8()), field("b", utf8())});

    but in the following form, I can use std::initializer_list<std::pair<std::string, std::shared_ptr>> as the input parameter, but in this way it's hard to add support for passing in nullable and metadata conveniently like the field function. std::tuple doesn't support default parameters too.
    struct_({{"a", int8()}, {"b", utf8()}});

    I guess there is a better way to write this overload function or shall we just support (name, type) pairs for now?
    Thanks for your time.

  4. pitrou commented on Jul 26, 2023

    @pitrou
    MemberAuthor

    hi @jsjtxietian

    I guess there is a better way to write this overload function or shall we just support (name, type) pairs for now?

    We can just support (name, type) pairs since that's the common case anyway.

  5. added a commit that references this issue on Aug 9, 2023
  6. added this to the 14.0.0 milestone on Aug 9, 2023
  7. added a commit that references this issue on Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions