{"id":23165166,"url":"https://github.com/funkwerk/accessors","last_synced_at":"2026-02-09T02:03:09.773Z","repository":{"id":94506673,"uuid":"75882273","full_name":"funkwerk/accessors","owner":"funkwerk","description":"Generate D getters and setters automatically","archived":false,"fork":false,"pushed_at":"2018-05-25T17:05:15.000Z","size":38,"stargazers_count":20,"open_issues_count":3,"forks_count":4,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-08-03T13:35:23.732Z","etag":null,"topics":["accessor","d","dlang","getters","setters"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funkwerk.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":"2016-12-07T22:50:19.000Z","updated_at":"2024-12-15T21:19:30.000Z","dependencies_parsed_at":"2023-07-28T06:01:16.309Z","dependency_job_id":null,"html_url":"https://github.com/funkwerk/accessors","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/funkwerk/accessors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkwerk%2Faccessors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkwerk%2Faccessors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkwerk%2Faccessors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkwerk%2Faccessors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funkwerk","download_url":"https://codeload.github.com/funkwerk/accessors/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funkwerk%2Faccessors/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29254303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T01:52:29.835Z","status":"online","status_checked_at":"2026-02-09T02:00:09.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["accessor","d","dlang","getters","setters"],"created_at":"2024-12-18T01:15:19.991Z","updated_at":"2026-02-09T02:03:09.768Z","avatar_url":"https://github.com/funkwerk.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# accessors\n\n[![Build Status](https://travis-ci.org/funkwerk/accessors.svg?branch=master)](https://travis-ci.org/funkwerk/accessors)\n[![License](https://img.shields.io/badge/license-BSL_1.0-blue.svg)](https://raw.githubusercontent.com/funkwerk/accessors/master/LICENSE)\n[![Dub Version](https://img.shields.io/dub/v/accessors.svg)](https://code.dlang.org/packages/accessors)\n[![codecov](https://codecov.io/gh/funkwerk/accessors/branch/master/graph/badge.svg)](https://codecov.io/gh/funkwerk/accessors)\n\n`accessors` module allows to generate getters and setters automatically.\n\n**Deprecation warning:** `accessors` has been succeeded by [boilerplate](https://github.com/funkwerk/boilerplate).\n\n## Usage\n\n```d\nimport accessors;\n\nclass WithAccessors\n{\n    @Read @Write\n    private int num_;\n\n    mixin(GenerateFieldAccessors);\n}\n```\n\n`@Read` and `@Write` generate the following two methods:\n\n```d\npublic final @property auto num() inout @nogc nothrow pure @safe\n{\n    return this.num_;\n}\n\npublic final @property void num(int num) @nogc nothrow pure @safe\n{\n    this.num_ = num;\n}\n```\n\nThe accessors names are derived from the appropriate member variables by\nremoving an underscore from the beginning or the end of the variable name.\n\n### Available user defined attributes\n\n* `@Read`\n* `@ConstRead`\n* `@Write`\n\nAs you can see there are multiple attributes that can be used to generate\ngetters and only one for the setters. The getters differ by the return\ntype. `@Read` returns an `inout` value, `@ConstRead` - a `const` value.\n\n### Accessor visibility\n\nVisibility of the generated accessors is by default `public`, but it can be\nchanged. In order to achieve this, you have to pass `public`, `protected`,\n`private` or `package` as argument to the attribute:\n\n```d\nimport accessors;\n\nclass WithAccessors\n{\n    @Read(\"public\") @Write(\"protected\")\n    private int num_;\n\n    mixin(GenerateFieldAccessors);\n}\n```\n\n## Example\n\n```d\nimport accessors;\nimport std.stdio;\n\nclass Person\n{\n    @Read @Write\n    private uint age_;\n\n    @ConstRead\n    private string name_;\n\n    this(in string name, in uint age = 0)\n    {\n        this.name_ = name;\n        this.age_ = age;\n    }\n\n    mixin(GenerateFieldAccessors);\n}\n\nvoid main()\n{\n    auto person = new Person(\"Saul Kripke\");\n\n    person.age = 57;\n\n    writeln(person.name, \": \", person.age);\n}\n```\n\n## Bugs\n\nIf you experience compile-time problems, open an\n[issue](https://github.com/funkwerk/accessors/issues) with the\ninformation about the type of the member variable fails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunkwerk%2Faccessors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunkwerk%2Faccessors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunkwerk%2Faccessors/lists"}