{"id":16679630,"url":"https://github.com/mrk21/bitfield","last_synced_at":"2025-05-14T10:34:19.452Z","repository":{"id":15618637,"uuid":"18355150","full_name":"mrk21/bitfield","owner":"mrk21","description":"C++11 bitfield template library","archived":false,"fork":false,"pushed_at":"2014-07-09T08:55:11.000Z","size":424,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T17:22:37.133Z","etag":null,"topics":["cpp","cpp11"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrk21.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}},"created_at":"2014-04-02T05:00:48.000Z","updated_at":"2021-12-13T15:18:01.000Z","dependencies_parsed_at":"2022-07-30T02:07:55.623Z","dependency_job_id":null,"html_url":"https://github.com/mrk21/bitfield","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbitfield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbitfield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbitfield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbitfield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrk21","download_url":"https://codeload.github.com/mrk21/bitfield/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254121324,"owners_count":22018142,"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","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","cpp11"],"created_at":"2024-10-12T13:36:32.163Z","updated_at":"2025-05-14T10:34:14.439Z","avatar_url":"https://github.com/mrk21.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"bitfield\n========\n\nC++11 bitfield template library\n\nExamples\n========\n\nAnalyzing the IP header:\n\n```c++\n#include \u003cbitfield/field.hpp\u003e\n#include \u003cbitfield/iostream.hpp\u003e\n\n// IP header\nunion ip_header {\n    using version_type           =                    bitfield::field\u003c 4\u003e;\n    using ihl_type               =           version_type::next_field\u003c 4\u003e;\n    using dscp_type              =               ihl_type::next_field\u003c 6\u003e;\n    using ecn_type               =              dscp_type::next_field\u003c 2\u003e;\n    using total_length_type      =               ecn_type::next_field\u003c16\u003e;\n    using identification_type    =      total_length_type::next_field\u003c16\u003e;\n    using flags_type             =    identification_type::next_field\u003c 3\u003e;\n    using fragment_offset_type   =             flags_type::next_field\u003c13\u003e;\n    using time_to_live_type      =   fragment_offset_type::next_field\u003c 8\u003e;\n    using protocol_type          =      time_to_live_type::next_field\u003c 8\u003e;\n    using header_checksum_type   =          protocol_type::next_field\u003c16\u003e;\n    using source_ip_address_type =   header_checksum_type::next_field\u003c32\u003e;\n    using dest_ip_address_type   = source_ip_address_type::next_field\u003c32\u003e;\n    using options_type           =   dest_ip_address_type::next_field\u003c32\u003e;\n    using container_type = options_type::container_type;\n    \n    container_type container;\n    \n    version_type            version;\n    ihl_type                ihl;\n    dscp_type               dscp;\n    ecn_type                ecn;\n    total_length_type       total_length;\n    identification_type     identification;\n    flags_type              flags;\n    fragment_offset_type    fragment_offset;\n    time_to_live_type       time_to_live;\n    protocol_type           protocol;\n    header_checksum_type    header_checksum;\n    source_ip_address_type  source_ip_address;\n    dest_ip_address_type    dest_ip_address;\n    options_type            options;\n};\n\nint main() {\n    // packet\n    ip_header packet{{{\n        0x45, 0x00, 0x00, 0x30, 0x26, 0xd6, 0x40, 0x00,  0x80, 0x06, 0x58, 0x86, 0xc0, 0xa8, 0x01, 0x8f,\n        0xd2, 0xe1, 0xe6, 0x52,\n    }}};\n    \n    //== Get field == \n    // IP version: 4\n    // total length: 48\n    std::cout \u003c\u003c \"IP version: \" \u003c\u003c packet.version \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"total length: \" \u003c\u003c packet.total_length \u003c\u003c std::endl;\n    \n    //== Set field ==\n    // TTL: 128\n    // TTL: 127\n    std::cout \u003c\u003c \"TTL: \" \u003c\u003c packet.time_to_live \u003c\u003c std::endl;\n    packet.time_to_live = packet.time_to_live - 1; // decrement TTL\n    std::cout \u003c\u003c \"TTL: \" \u003c\u003c packet.time_to_live \u003c\u003c std::endl;\n    \n    return 0;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrk21%2Fbitfield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrk21%2Fbitfield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrk21%2Fbitfield/lists"}