boostorg / boostorg/hana

Question: Attribute Annotations

Open
#314 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.9k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

I'm interested in the "struct reflection" features of Boost.Hana. I think that this part of Boost.Hana is especially suited for all kinds of serialization/marshalling + deserialization/unmarshalling (file reading/writing, network/API protocols, database access, etc.).

Other languages offer a functionality to "annotate" member variables:
- Python and Java have "@" (used for Hibernate, Jackson, etc.)
- In Go you can use something like `json:"var_name"` (example: https://play.golang.org/p/BMeR8p1cKf)
- etc.

Use cases include JSON/XML attribute names (API naming conventions can be different to variable naming), parser information (i.e. CSV column names, XPath for XML to struct parsing), optional/required/versioning information for formats like Protocol Buffers or Flatbuffers, or database information ("PRIMARY KEY", "UNIQUE", "NOT NULL", etc. - this way SELECT, CREATE TABLE statements, etc. could be automatically generated from the struct definition at compile time - see https://github.com/rbock/sqlpp11).

Is there already a way to do something like this (i.e. generic additional attribute "tags") or (if that's not the case) are there any plans to extend Boost.Hana?

Contributor guide

Open the contributing guide

Research direction

Start with Boost.Hana's struct reflection features and the annotation use cases described in the issue. Determine whether generic member attributes or tags already exist; otherwise, the work would need a maintainer decision on the design and scope of an extension.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.