{"id":22033918,"url":"https://github.com/PragmaTwice/protopuf","last_synced_at":"2025-07-23T15:31:30.024Z","repository":{"id":38021265,"uuid":"305896241","full_name":"PragmaTwice/protopuf","owner":"PragmaTwice","description":"Protocol Puffers: A little, highly templated, and protobuf-compatible serialization/deserialization header-only library written in C++20","archived":false,"fork":false,"pushed_at":"2025-06-20T10:42:31.000Z","size":296,"stargazers_count":184,"open_issues_count":3,"forks_count":17,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-06-20T11:37:55.115Z","etag":null,"topics":["cpp","header-only","library","metaprogramming","protobuf","serialization","template"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PragmaTwice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-21T03:19:26.000Z","updated_at":"2025-06-20T10:42:35.000Z","dependencies_parsed_at":"2025-01-03T05:13:51.823Z","dependency_job_id":"15bebd57-3ee4-4adf-9177-d1123bff33e0","html_url":"https://github.com/PragmaTwice/protopuf","commit_stats":{"total_commits":177,"total_committers":3,"mean_commits":59.0,"dds":"0.011299435028248594","last_synced_commit":"c81bb3bb810164b6cbaedbdf44725711499297e8"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/PragmaTwice/protopuf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PragmaTwice%2Fprotopuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PragmaTwice%2Fprotopuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PragmaTwice%2Fprotopuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PragmaTwice%2Fprotopuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PragmaTwice","download_url":"https://codeload.github.com/PragmaTwice/protopuf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PragmaTwice%2Fprotopuf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266704027,"owners_count":23971403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","header-only","library","metaprogramming","protobuf","serialization","template"],"created_at":"2024-11-30T09:01:46.801Z","updated_at":"2025-07-23T15:31:30.000Z","avatar_url":"https://github.com/PragmaTwice.png","language":"C++","funding_links":[],"categories":["Serialization","Recently Updated"],"sub_categories":["[Nov 28, 2024](/content/2024/11/28/README.md)"],"readme":"# ![puffer](asset/puffer.png) Protocol Puffers\n[![Codacy](https://api.codacy.com/project/badge/Grade/31e7d1d7bcbe43959aaec3b86093b843)](https://app.codacy.com/gh/PragmaTwice/protopuf?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=PragmaTwice/protopuf\u0026utm_campaign=Badge_Grade)\n[![Github Actions](https://github.com/PragmaTwice/protopuf/workflows/BuildAndTest/badge.svg)](https://github.com/PragmaTwice/protopuf/actions)\n[![Vcpkg Port](https://img.shields.io/vcpkg/v/protopuf)](https://github.com/microsoft/vcpkg/blob/master/ports/protopuf/vcpkg.json)\n[![Conan Center](https://img.shields.io/conan/v/protopuf)](https://conan.io/center/recipes/protopuf)\n[![Codecov](https://codecov.io/gh/PragmaTwice/protopuf/branch/master/graph/badge.svg?token=4EPLZ6Z4J5)](https://codecov.io/gh/PragmaTwice/protopuf)\n\n*A little, highly templated, and protobuf-compatible serialization/deserialization library written in C++20*\n\n:closed_book: [Documentation](https://protopuf.surge.sh)\n\n## Requirements\n\n- a compiler and a standard library implementation with C++20 support\n    - GCC 11 or above, or\n    - Clang 12 or above, or\n    - MSVC 14.29 (Visual Studio 2019 Version 16.9) or above\n    - Apple Clang 17 (Xcode 16.4) or above\n- CMake 3\n- GoogleTest (optional, for unit tests)\n- vcpkg (optional, `vcpkg install protopuf` to install)\n\n## Features\n\n- Data structures are described using type in C++ instead of DSLs like the Protocol Buffer Language (`.proto`)\n- Fully compatible with encoding of the Protocol Buffers, capable of mutual serialization/deserialization\n- Extensive compile-time operations aimed to improving run-time performance\n\n## An Example\nFor the following data structure described using `.proto`:\n```proto\nmessage Student {\n    uint32 id = 1;\n    string name = 3;\n}\n\nmessage Class {\n    string name = 8;\n    repeated Student students = 3;\n}\n```\nWe can use *protopuf* to describe it as C++ types:\n```c++\nusing namespace pp;\n\nusing Student = message\u003c\n    uint32_field\u003c\"id\", 1\u003e,\n    string_field\u003c\"name\", 3\u003e\n\u003e;\n\nusing Class = message\u003c\n    string_field\u003c\"name\", 8\u003e,\n    message_field\u003c\"students\", 3, Student, repeated\u003e\n\u003e;\n```\nSubsequently, both serialization and deserialization become so easy to do:\n```c++\n// serialization\nStudent twice {123, \"twice\"}, tom{456, \"tom\"}, jerry{123456, \"jerry\"};\nClass myClass {\"class 101\", {tom, jerry}};\nmyClass[\"students\"_f].push_back(twice);\n\narray\u003cbyte, 64\u003e buffer{};\nauto result = message_coder\u003cClass\u003e::encode(myClass, buffer);\nassert(result.has_value());\nconst auto\u0026 bufferEnd = *result;\nassert(begin_diff(bufferEnd, buffer) == 45);\n\n// deserialization\nauto result2 = message_coder\u003cClass\u003e::decode(buffer);\nassert(result2.has_value());\nconst auto\u0026 [yourClass, bufferEnd2] = *result2;\nassert(yourClass[\"name\"_f] == \"class 101\");\nassert(yourClass[\"students\"_f][2][\"name\"_f] == \"twice\");\nassert(yourClass[\"students\"_f][2][\"id\"_f] == 123);\nassert(yourClass[\"students\"_f][1] == (Student{123456, \"jerry\"}));\nassert(yourClass == myClass);\nassert(begin_diff(bufferEnd2, bufferEnd) == 0);\n```\nMore examples can be found in our test cases ([test/message.cpp](https://github.com/PragmaTwice/protopuf/blob/master/test/message.cpp)).\n\n## Supported Field Types\nCategory|\tSupported Types\n--------|------------------\nVarint  | int32, int64, uint32, uint64, sint32, sint64, bool, enum\n64-bit  | fixed64, sfixed64, double\nLength-delimited| string, bytes, embedded messages, packed repeated fields\n32-bit \t| fixed32, sfixed32, float\n\n## Known issues\n- There is [a known bug](https://developercommunity2.visualstudio.com/t/Wrong-compile-error-in-MSVC:-identifier-/1270794) in Visual Studio 2019 Version 16.8 related to template parameter lists of lambda expressions, which can produce a wrong compilation error while compiling protopuf\n- Although class type in NTTP ([P0732R2](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0732r2.pdf)) is implemented in GCC 10, there is a CTAD bug ([PR96331](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96331), exists until GCC 10.2) to reject valid NTTP usage, which prevent protopuf to compile successfully\n\n## Acknowledgement\n- to @dngrudin for the contribution of out-of-bounds checking and unsafe/safe mode\n- to [JetBrains](https://www.jetbrains.com/?from=protopuf) for its [Open Source License](https://www.jetbrains.com/community/opensource/?from=protopuf) of All Products Pack\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPragmaTwice%2Fprotopuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPragmaTwice%2Fprotopuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPragmaTwice%2Fprotopuf/lists"}