[CXX-2097] BSON-serializer functions for user-defined objects Created: 26/Aug/20  Updated: 01/Feb/23  Resolved: 09/Oct/20

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Clyde Bazile III (Inactive) Assignee: Raymund Rodriguez
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CXX-2114 BSON serializer can be used on arrays... Closed
Related
related to CXX-2115 BSON serializer can be used with std ... Backlog
Epic Link: CXX usability improvements
Quarter: FY24Q3

 Description   

Like the epic JAVA-1812, we should consider providing an interface that allows users to define serializer functions that convert ordinary C++ objects to BSON objects.

We'd have to allow both internal and external functions (relative to the namespace of the class) for users that want to amend source code they maintain and add serializers for ones they don't.

For example, a user may wish to serialize a class:

struct Person {
  std::string name;
  std::string address;
};

into the BSON object:

{"name" : "bob", "address" : "123 My Street"}

In which case, they should add methods in struct Person to do so.

Alternatively, a user may wish to add a custom serializer function for the standard C++ container unordered_multimap. It would be impractical to add those functions to the std namespace. Therefore, we should consider how we'd handle this case. A suggestion would be to allow users to add functions to one of our namespaces.



 Comments   
Comment by Githook User [ 09/Oct/20 ]

Author:

{'name': 'rayangler', 'email': 'rayangler@users.noreply.github.com', 'username': 'rayangler'}

Message: CXX-2097 Create BSON serializer functions for user-defined objects (#726)
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/5af3405736488be0ea2c06fbcb682278b662a722

Generated at Wed Feb 07 22:04:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.