{"id":13342974,"url":"https://github.com/demidko/utility","last_synced_at":"2026-03-04T07:12:45.416Z","repository":{"id":132797062,"uuid":"435789097","full_name":"demidko/utility","owner":"demidko","description":" Modern C++ command line tool template ","archived":false,"fork":false,"pushed_at":"2024-09-05T13:54:56.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-24T13:59:00.408Z","etag":null,"topics":["cpp","cpp20","crossplatform","xmake"],"latest_commit_sha":null,"homepage":"","language":"Lua","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/demidko.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}},"created_at":"2021-12-07T07:48:40.000Z","updated_at":"2024-09-05T13:54:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5bf2b40-d1bf-4e57-9aa8-a339b41cf42a","html_url":"https://github.com/demidko/utility","commit_stats":null,"previous_names":["demidko/utility"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demidko%2Futility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demidko%2Futility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demidko%2Futility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demidko%2Futility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demidko","download_url":"https://codeload.github.com/demidko/utility/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243150714,"owners_count":20244447,"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","cpp20","crossplatform","xmake"],"created_at":"2024-07-29T19:30:09.060Z","updated_at":"2026-03-04T07:12:45.354Z","avatar_url":"https://github.com/demidko.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Native Utility\n\nThe cross-platform C++20 command line tool template.\n\n## Usage\n\nMake sure you are signed in to your GitHub account, then just\n[click here](https://github.com/demidko/native-utility/generate) to use template.\n\n## Download\n\nGitHub CI automatically generates versions of the application for different operating systems. See the Actions Tab.\n\n## Build\n\nWe need [GCC](https://gcc.gnu.org) or [LLVM](https://llvm.org) or [Visual Studio](https://visualstudio.microsoft.com/)\ntoolchain, and [xmake](https://xmake.io) build system.\n\n```shell\nxmake\n```\n\nAfter that, we can run the release app:\n\n```shell\n./build/main/app\n```\n\n## Containerization\n\nTo build the image, we need [Docker](https://www.docker.com/) installed:\n\n```shell\ndocker build . -t app\n```\n\nAfter that, we can run the app in the container (if needed):\n\n```shell\ndocker run -v `pwd`:`pwd` -w `pwd` -it --rm -p 80:80 app \n```\n\nTo clean up Docker use `docker system prune -fa`\n\n## Interop with Java\n\nSee [JNR project](https://github.com/jnr/jnr-ffi).\n\n## Development with IDE\n\nSome IDEs require a project configuration in a specific format. You can configure project with other build system:\n\n* CLion, VS Code:\n  ```shell\n  xmake project -k cmake\n  ```\n* Visual Studio\n  ```shell\n  xmake project -k vc\n  ```\n* Xcode:\n  ```shell\n  xmake project -k xcode\n  ```\n\n* For someone else see:\n  ```shell\n  xmake project -h\n  ```\n\n## Code style \u0026 Conventions\n\n* The entry point must be located in the `./src/main/cpp/Main.cpp` file for correct build script work.\n* Use functional style.\n  ```c++\n  auto x = User(\"John\"); // good, functional\n  auto x = User{\"John\"}; // bad, no need '{..}' with functional initialization.\n  User x = User(\"John\"); // bad, old style!\n\n  auto listUsers() -\u003e vector\u003cUser\u003e {} // good, clean code\n  void listUsers(vector\u003cUser\u003e to\u0026) {} // bad, C++03 old style\n  ```\n* Always use const lvalue (const T \u0026)\n  or [TriviallyCopyable](https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable) for readonly parameters.\n  ```c++\n  auto readFrom(const Book \u0026book) {} // good, no copy\n  auto readFrom(Book book) {} // bad, copying!\n  \n  auto print(string_view text) {} // good, no copy\n  auto print(string text) {} // bad, copying!\n  ```\n* To initialize resources, we're using [modern parameter passing by value](https://habr.com/ru/post/460955/), rather\n  than a constant link.\n  ```c++\n  class Example { \n    private: \n      data field;\n    public: \n      Example(data v): field(move(v)) {} // good, no copy\n      Example(const data \u0026v): field(v) {} // bad, copying!\n  };\n  ```\n* Do not use `return move(v)`! Use [NRVO](https://habr.com/ru/company/vk/blog/666330/) instead.\n* Use rvalue links (T \u0026\u0026) only in move constructors.\n  ```c++\n  class Example {\n      \u003c...\u003e\n    public: \n      Example(Example \u0026\u0026other): data(move(other.data)) {} // good, move resources.\n  \n      Example(AnotherType \u0026\u0026v): field(v) {} // very bad! Use passing-by-value-then-move instead.\n      Example(AntoherType v): field(move(v)) {} // good, no copy\n  };\n  \n  auto readSomeone(Book \u0026\u0026book) {} // bad, use const Book \u0026. No need moving there!\n  ```\n* Only the result of the compilation of `* .cpp` files in the` src/main` folder is included in the release assembly.\n* The `src/main` folder contains the` *.cpp` and `*.h` project files together.\n* The `src/test` folder contains the` *.cpp` and `*.h` project test files together.\n* Each `*.h` file must define only one entity in the global namespace, whose name must match the file name.\n* The contents of `*.cpp` files not declared in` *.h` file must be protected from `external linkage` from others\n  compilation units by adding them to the anonymous namespace or adding the keyword `static`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemidko%2Futility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemidko%2Futility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemidko%2Futility/lists"}