Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[struct_pack] Add support for unique_ptr #122

Merged
merged 5 commits into from Dec 14, 2022

Conversation

poor-circle
Copy link
Collaborator

Why

struct_pack should support recursion type. So we should support pointer/references.

What is changing

Add support for unique_ptr-like pointer.

Example

struct my_tree {
  std::unique_ptr<my_tree> left_child;
  std::unique_ptr<my_tree> right_child;
  std::string name;
  int value;
};

my_tree root;
auto buffer=struct_pack::serialize(root);
auto result=struct_pack::deserialize(buffer);
//CHECK(root == result);

@github-actions
Copy link

Code Coverage Report
for detail, goto summary download Artifacts

Filename                                       Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
asio_util/asio_coro_util.hpp                          36                 2    94.44%         166                 2    98.80%           0                 0         -
asio_util/asio_util.hpp                                4                 1    75.00%          22                 5    77.27%           0                 0         -
asio_util/io_context_pool.hpp                          8                 3    62.50%          51                12    76.47%          12                 1    91.67%
coro_rpc/coro_rpc/async_connection.hpp                35                 1    97.14%         384                22    94.27%          60                 7    88.33%
coro_rpc/coro_rpc/async_rpc_server.hpp                16                 2    87.50%         211                28    86.73%          52                17    67.31%
coro_rpc/coro_rpc/common_service.hpp                   3                 0   100.00%          55                 0   100.00%          10                 0   100.00%
coro_rpc/coro_rpc/connection.hpp                       4                 0   100.00%          63                 1    98.41%           6                 0   100.00%
coro_rpc/coro_rpc/coro_connection.hpp                 24                 1    95.83%         326                31    90.49%          76                10    86.84%
coro_rpc/coro_rpc/coro_rpc_client.hpp                 28                 3    89.29%         438                50    88.58%          80                15    81.25%
coro_rpc/coro_rpc/coro_rpc_server.hpp                 20                 1    95.00%         222                21    90.54%          48                16    66.67%
coro_rpc/coro_rpc/remote.hpp                          10                 1    90.00%         103                13    87.38%          10                 4    60.00%
coro_rpc/coro_rpc/router_impl.hpp                     10                 0   100.00%         310                 8    97.42%          12                 1    91.67%
logging/easylog.hpp                                   15                 4    73.33%         131                78    40.46%          22                 7    68.18%
struct_pack/struct_pack.hpp                           11                 3    72.73%          87                25    71.26%          22                 9    59.09%
struct_pack/struct_pack/error_code.h                   3                 3     0.00%          22                22     0.00%           0                 0         -
struct_pack/struct_pack/md5_constexpr.hpp             20                20     0.00%         163               163     0.00%           0                 0         -
struct_pack/struct_pack/reflection.h                   1                 0   100.00%         536                12    97.76%           0                 0         -
struct_pack/struct_pack/struct_pack_impl.hpp          32                 9    71.88%         781               173    77.85%          86                42    51.16%
struct_pack/struct_pack/tuple.hpp                      1                 1     0.00%           1                 1     0.00%           0                 0         -
util/expected.hpp                                     61                 6    90.16%         171                25    85.38%          28                 6    78.57%
util/magic_names.hpp                                   1                 1     0.00%          11                11     0.00%           0                 0         -
util/meta_string.hpp                                   3                 3     0.00%           8                 8     0.00%           0                 0         -
util/string_finder.hpp                                 2                 2     0.00%          11                11     0.00%           0                 0         -
util/type_traits.h                                     1                 0   100.00%           9                 0   100.00%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                349                67    80.80%        4282               722    83.14%         524               135    74.24%

@github-actions
Copy link

Code Coverage Report
for detail, goto summary download Artifacts

Filename                                       Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
asio_util/asio_coro_util.hpp                          36                 2    94.44%         166                 2    98.80%           0                 0         -
asio_util/asio_util.hpp                                4                 1    75.00%          22                 5    77.27%           0                 0         -
asio_util/io_context_pool.hpp                          8                 3    62.50%          51                12    76.47%          12                 1    91.67%
coro_rpc/coro_rpc/async_connection.hpp                35                 1    97.14%         384                22    94.27%          60                 7    88.33%
coro_rpc/coro_rpc/async_rpc_server.hpp                16                 2    87.50%         211                28    86.73%          52                17    67.31%
coro_rpc/coro_rpc/common_service.hpp                   3                 0   100.00%          55                 0   100.00%          10                 0   100.00%
coro_rpc/coro_rpc/connection.hpp                       4                 0   100.00%          63                 1    98.41%           6                 0   100.00%
coro_rpc/coro_rpc/coro_connection.hpp                 24                 1    95.83%         326                31    90.49%          76                10    86.84%
coro_rpc/coro_rpc/coro_rpc_client.hpp                 28                 3    89.29%         438                50    88.58%          80                15    81.25%
coro_rpc/coro_rpc/coro_rpc_server.hpp                 20                 1    95.00%         222                21    90.54%          48                16    66.67%
coro_rpc/coro_rpc/remote.hpp                          10                 1    90.00%         103                13    87.38%          10                 4    60.00%
coro_rpc/coro_rpc/router_impl.hpp                     10                 0   100.00%         310                 8    97.42%          12                 1    91.67%
logging/easylog.hpp                                   15                 4    73.33%         131                78    40.46%          22                 7    68.18%
struct_pack/struct_pack.hpp                           11                 3    72.73%          87                25    71.26%          22                 9    59.09%
struct_pack/struct_pack/error_code.h                   3                 3     0.00%          22                22     0.00%           0                 0         -
struct_pack/struct_pack/md5_constexpr.hpp             20                20     0.00%         163               163     0.00%           0                 0         -
struct_pack/struct_pack/reflection.h                   1                 0   100.00%         536                12    97.76%           0                 0         -
struct_pack/struct_pack/struct_pack_impl.hpp          32                 9    71.88%         781               173    77.85%          86                42    51.16%
struct_pack/struct_pack/tuple.hpp                      1                 1     0.00%           1                 1     0.00%           0                 0         -
util/expected.hpp                                     61                 6    90.16%         171                25    85.38%          28                 6    78.57%
util/magic_names.hpp                                   1                 1     0.00%          11                11     0.00%           0                 0         -
util/meta_string.hpp                                   3                 3     0.00%           8                 8     0.00%           0                 0         -
util/string_finder.hpp                                 2                 2     0.00%          11                11     0.00%           0                 0         -
util/type_traits.h                                     1                 0   100.00%           9                 0   100.00%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                349                67    80.80%        4282               722    83.14%         524               135    74.24%

@github-actions
Copy link

Code Coverage Report
for detail, goto summary download Artifacts

Filename                                       Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
asio_util/asio_coro_util.hpp                          36                 2    94.44%         166                 2    98.80%           0                 0         -
asio_util/asio_util.hpp                                4                 1    75.00%          22                 5    77.27%           0                 0         -
asio_util/io_context_pool.hpp                          8                 3    62.50%          51                12    76.47%          12                 1    91.67%
coro_rpc/coro_rpc/async_connection.hpp                35                 1    97.14%         384                22    94.27%          60                 7    88.33%
coro_rpc/coro_rpc/async_rpc_server.hpp                16                 2    87.50%         211                28    86.73%          52                17    67.31%
coro_rpc/coro_rpc/common_service.hpp                   3                 0   100.00%          55                 0   100.00%          10                 0   100.00%
coro_rpc/coro_rpc/connection.hpp                       4                 0   100.00%          63                 1    98.41%           6                 0   100.00%
coro_rpc/coro_rpc/coro_connection.hpp                 24                 1    95.83%         326                31    90.49%          76                10    86.84%
coro_rpc/coro_rpc/coro_rpc_client.hpp                 28                 3    89.29%         438                50    88.58%          80                15    81.25%
coro_rpc/coro_rpc/coro_rpc_server.hpp                 20                 1    95.00%         222                21    90.54%          48                16    66.67%
coro_rpc/coro_rpc/remote.hpp                          10                 1    90.00%         103                13    87.38%          10                 4    60.00%
coro_rpc/coro_rpc/router_impl.hpp                     10                 0   100.00%         310                 8    97.42%          12                 1    91.67%
logging/easylog.hpp                                   15                 4    73.33%         131                78    40.46%          22                 7    68.18%
struct_pack/struct_pack.hpp                           11                 3    72.73%          87                25    71.26%          22                 9    59.09%
struct_pack/struct_pack/error_code.h                   3                 3     0.00%          22                22     0.00%           0                 0         -
struct_pack/struct_pack/md5_constexpr.hpp             20                20     0.00%         163               163     0.00%           0                 0         -
struct_pack/struct_pack/reflection.h                   1                 0   100.00%         536                12    97.76%           0                 0         -
struct_pack/struct_pack/struct_pack_impl.hpp          32                 9    71.88%         781               173    77.85%          86                42    51.16%
struct_pack/struct_pack/tuple.hpp                      1                 1     0.00%           1                 1     0.00%           0                 0         -
util/expected.hpp                                     61                 6    90.16%         171                25    85.38%          28                 6    78.57%
util/magic_names.hpp                                   1                 1     0.00%          11                11     0.00%           0                 0         -
util/meta_string.hpp                                   3                 3     0.00%           8                 8     0.00%           0                 0         -
util/string_finder.hpp                                 2                 2     0.00%          11                11     0.00%           0                 0         -
util/type_traits.h                                     1                 0   100.00%           9                 0   100.00%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                349                67    80.80%        4282               722    83.14%         524               135    74.24%

@github-actions
Copy link

Code Coverage Report
for detail, goto summary download Artifacts

Filename                                       Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
asio_util/asio_coro_util.hpp                          36                 2    94.44%         166                 2    98.80%           0                 0         -
asio_util/asio_util.hpp                                4                 1    75.00%          22                 5    77.27%           0                 0         -
asio_util/io_context_pool.hpp                          8                 3    62.50%          51                12    76.47%          12                 1    91.67%
coro_rpc/coro_rpc/async_connection.hpp                35                 1    97.14%         384                22    94.27%          60                 7    88.33%
coro_rpc/coro_rpc/async_rpc_server.hpp                16                 2    87.50%         211                28    86.73%          52                17    67.31%
coro_rpc/coro_rpc/common_service.hpp                   3                 0   100.00%          55                 0   100.00%          10                 0   100.00%
coro_rpc/coro_rpc/connection.hpp                       4                 0   100.00%          63                 1    98.41%           6                 0   100.00%
coro_rpc/coro_rpc/coro_connection.hpp                 24                 1    95.83%         326                31    90.49%          76                10    86.84%
coro_rpc/coro_rpc/coro_rpc_client.hpp                 28                 3    89.29%         438                50    88.58%          80                15    81.25%
coro_rpc/coro_rpc/coro_rpc_server.hpp                 20                 1    95.00%         222                21    90.54%          48                16    66.67%
coro_rpc/coro_rpc/remote.hpp                          10                 1    90.00%         103                13    87.38%          10                 4    60.00%
coro_rpc/coro_rpc/router_impl.hpp                     10                 0   100.00%         310                 8    97.42%          12                 1    91.67%
logging/easylog.hpp                                   15                 4    73.33%         131                78    40.46%          22                 7    68.18%
struct_pack/struct_pack.hpp                           11                 3    72.73%          87                25    71.26%          22                 9    59.09%
struct_pack/struct_pack/error_code.h                   3                 3     0.00%          22                22     0.00%           0                 0         -
struct_pack/struct_pack/md5_constexpr.hpp             20                20     0.00%         163               163     0.00%           0                 0         -
struct_pack/struct_pack/reflection.h                   1                 0   100.00%         536                12    97.76%           0                 0         -
struct_pack/struct_pack/struct_pack_impl.hpp          32                 9    71.88%         781               173    77.85%          86                42    51.16%
struct_pack/struct_pack/tuple.hpp                      1                 1     0.00%           1                 1     0.00%           0                 0         -
util/expected.hpp                                     61                 6    90.16%         171                25    85.38%          28                 6    78.57%
util/magic_names.hpp                                   1                 1     0.00%          11                11     0.00%           0                 0         -
util/meta_string.hpp                                   3                 3     0.00%           8                 8     0.00%           0                 0         -
util/string_finder.hpp                                 2                 2     0.00%          11                11     0.00%           0                 0         -
util/type_traits.h                                     1                 0   100.00%           9                 0   100.00%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                349                67    80.80%        4282               722    83.14%         524               135    74.24%

@github-actions
Copy link

Code Coverage Report
for detail, goto summary download Artifacts

Filename                                       Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
asio_util/asio_coro_util.hpp                          36                 2    94.44%         166                 2    98.80%           0                 0         -
asio_util/asio_util.hpp                                4                 1    75.00%          22                 5    77.27%           0                 0         -
asio_util/io_context_pool.hpp                          8                 3    62.50%          51                12    76.47%          12                 1    91.67%
coro_rpc/coro_rpc/async_connection.hpp                35                 1    97.14%         384                22    94.27%          60                 7    88.33%
coro_rpc/coro_rpc/async_rpc_server.hpp                16                 2    87.50%         211                28    86.73%          52                17    67.31%
coro_rpc/coro_rpc/common_service.hpp                   3                 0   100.00%          55                 0   100.00%          10                 0   100.00%
coro_rpc/coro_rpc/connection.hpp                       4                 0   100.00%          63                 1    98.41%           6                 0   100.00%
coro_rpc/coro_rpc/coro_connection.hpp                 24                 1    95.83%         326                31    90.49%          76                10    86.84%
coro_rpc/coro_rpc/coro_rpc_client.hpp                 28                 3    89.29%         438                50    88.58%          80                15    81.25%
coro_rpc/coro_rpc/coro_rpc_server.hpp                 20                 1    95.00%         222                21    90.54%          48                16    66.67%
coro_rpc/coro_rpc/remote.hpp                          10                 1    90.00%         103                13    87.38%          10                 4    60.00%
coro_rpc/coro_rpc/router_impl.hpp                     10                 0   100.00%         310                 8    97.42%          12                 1    91.67%
logging/easylog.hpp                                   15                 4    73.33%         131                78    40.46%          22                 7    68.18%
struct_pack/struct_pack.hpp                           11                 3    72.73%          87                25    71.26%          22                 9    59.09%
struct_pack/struct_pack/error_code.h                   3                 3     0.00%          22                22     0.00%           0                 0         -
struct_pack/struct_pack/md5_constexpr.hpp             20                20     0.00%         163               163     0.00%           0                 0         -
struct_pack/struct_pack/reflection.h                   1                 0   100.00%         536                12    97.76%           0                 0         -
struct_pack/struct_pack/struct_pack_impl.hpp          32                 9    71.88%         781               173    77.85%          86                42    51.16%
struct_pack/struct_pack/tuple.hpp                      1                 1     0.00%           1                 1     0.00%           0                 0         -
util/expected.hpp                                     61                 6    90.16%         171                25    85.38%          28                 6    78.57%
util/magic_names.hpp                                   1                 1     0.00%          11                11     0.00%           0                 0         -
util/meta_string.hpp                                   3                 3     0.00%           8                 8     0.00%           0                 0         -
util/string_finder.hpp                                 2                 2     0.00%          11                11     0.00%           0                 0         -
util/type_traits.h                                     1                 0   100.00%           9                 0   100.00%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                349                67    80.80%        4282               722    83.14%         524               135    74.24%

Copy link
Collaborator

@PikachuHyA PikachuHyA left a comment

Choose a reason for hiding this comment

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

LGTM

@poor-circle poor-circle merged commit e4ccc5a into alibaba:main Dec 14, 2022
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.

None yet

2 participants