{"id":15047655,"url":"https://github.com/igood/igranges","last_synced_at":"2025-04-10T01:05:59.641Z","repository":{"id":255315013,"uuid":"849194071","full_name":"IGood/IGRanges","owner":"IGood","description":"C++ Ranges for Unreal","archived":false,"fork":false,"pushed_at":"2024-10-14T07:43:41.000Z","size":175,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T01:05:54.641Z","etag":null,"topics":["cpp20","linq","ranges","ue5-plugin","unreal-engine-plugin"],"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/IGood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"custom":["paypal.me/IanGoodies"]}},"created_at":"2024-08-29T06:34:44.000Z","updated_at":"2025-04-09T14:07:07.000Z","dependencies_parsed_at":"2025-02-16T06:32:24.237Z","dependency_job_id":"4cdb7704-1113-418c-831a-297c23c12e75","html_url":"https://github.com/IGood/IGRanges","commit_stats":null,"previous_names":["igood/igranges"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGood%2FIGRanges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGood%2FIGRanges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGood%2FIGRanges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IGood%2FIGRanges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IGood","download_url":"https://codeload.github.com/IGood/IGRanges/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137888,"owners_count":21053775,"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":["cpp20","linq","ranges","ue5-plugin","unreal-engine-plugin"],"created_at":"2024-09-24T21:02:38.174Z","updated_at":"2025-04-10T01:05:59.599Z","avatar_url":"https://github.com/IGood.png","language":"C++","funding_links":["paypal.me/IanGoodies"],"categories":[],"sub_categories":[],"readme":"# ![Logo](Resources/Icon128.png) \u003csup\u003efor Unreal\u003c/sup\u003e\n \n[![MIT License](https://img.shields.io/badge/license-MIT-green.svg?style=flat-square)](/LICENSE)\n\n**IGRanges** is an Unreal Engine 5 plugin that leverages the [Ranges library (C++20)](https://en.cppreference.com/w/cpp/ranges) to provide [LINQ (C#)](https://learn.microsoft.com/en-us/dotnet/csharp/linq/) style code patterns.\n\nUnreal's container types (e.g. `TArray\u003cT\u003e`) do not support Ranges out of the box (yet?), so this plugin first adds the necessary customization point objects to make them compatible.\\\nBeyond that, a handful of common mapping \u0026 filtering operations have been implemented in ways that are familiar to programmers acquainted with UE \u0026 LINQ.\n\n----\n\n## C++20 Ranges, But Think LINQ\n\nA quick primer for Ranges from [cppreference.com](https://en.cppreference.com/w/cpp/ranges):\n\u003e The ranges library is an extension and generalization of the algorithms and iterator libraries that makes them more powerful by making them composable and less error-prone.\\\nThe library creates and manipulates range views, lightweight objects that indirectly represent iterable sequences (ranges).\n\n### 👩‍💻 Example A:\nThe following example \"pipes\" an array of integers through views to generate a sequence that is a modified subset of the original values.\n\n#### 👩‍💻 Example A.1:\n```cpp\nint myInts[] = { 0, 1, 2, 3, 4, 5 };\nauto even = [](int i) { return i % 2 == 0; };\nauto square = [](int i) { return i * i; };\n// the \"pipe\" syntax of composing the views:\nfor (int i : myInts | std::views::filter(even) | std::views::transform(square))\n    std::cout \u003c\u003c i \u003c\u003c ' ';\n// Output: 0 4 16\n```\n\nThis example is very *C++*-looking. It's not very *UE*-looking \u0026 it doesn't read quite as clearly as LINQ.\\\nIf we were to rewrite it in a UE style with IGRanges, then it might look something like this:\n\n#### 👩‍💻 Example A.2:\n```cpp\nTArray\u003cint32\u003e MyInts = { 0, 1, 2, 3, 4, 5 };\nauto IsEven = [](int i) { return i % 2 == 0; };\nauto Square = [](int i) { return i * i; };\nFString Result;\nfor (int32 i : MyInts | Where(IsEven) | Select(Square))\n{\n    Result.AppendInt(i);\n    Result += TEXT(\", \");\n}\nUE_LOG(LogTemp, Log, TEXT(\"Result{%s}\"), *Result);\n// Output: Result{0, 4, 16,}\n```\n\nOr, depending on style preferences, it might look something like this:\n\n#### 👩‍💻 Example A.3:\n```cpp\nTArray\u003cint32\u003e MyInts = { 0, 1, 2, 3, 4, 5 };\nauto Sqevens = MyInts\n    | Where([](int i) { return i % 2 == 0; })\n    | Select([](int i) { return i * i; }); \nFString Result;\nfor (int32 i : Sqevens)\n{\n    Result.AppendInt(i);\n    Result += TEXT(\", \");\n}\n```\n\n### 👩‍💻 Example B:\n\nA better demonstration of IGRanges is shown in the following example.\\\nThe declarative syntax can make it easier to understand the intent of the code.\\\nIn this case, we have a collection of pointers to Actors (some of which might be null) \u0026 we want to get the World from one of them.\n\n\u003ctable\u003e\n\u003ctr\u003e\u003cth\u003eImperative\u003c/th\u003e\u003cth\u003eDeclarative\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```cpp\nTArray\u003cAActor*\u003e MaybeActors = ...;\nUWorld* World = nullptr;\nfor (const AActor* Actor : MaybeActors)\n{\n    if (Actor != nullptr)\n    {\n        World = Actor-\u003eGetWorld();\n        break;\n    }\n}\nif (World != nullptr) ...\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```cpp\nTArray\u003cAActor*\u003e MaybeActors = ...;\nUWorld* World = MaybeActors\n    | NonNull()\n    | Select(\u0026AActor::GetWorld)\n    | FirstOrDefault();\nif (World != nullptr) ...\n\n\n\n\n\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### 👩‍💻 Example C:\n\nFiltering \u0026 collecting elements also becomes very easy with IGRanges.\n\n\u003ctable\u003e\n\u003ctr\u003e\u003cth\u003eImperative\u003c/th\u003e\u003cth\u003eDeclarative\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```cpp\nTArray\u003cUObject*\u003e SomeObjects = ...;\nTArray\u003cUFoo*\u003e Foos;\nfor (UObject* Obj : SomeObjects)\n{\n    if (UFoo* Foo = Cast\u003cFoo\u003e(Obj))\n    {\n        Foos.Add(Foo);\n    }\n}\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```cpp\nTArray\u003cUObject*\u003e SomeObjects = ...;\nTArray\u003cUFoo*\u003e Foos = SomeObjects | OfType\u003cFoo\u003e() | ToArray();\n\n\n\n\n\n\n\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n----\n\n### ✨ Features\n\n- `Where`, `WhereNot`, `SafeWhere`, `SafeWhereNot`\n- `NonNull`, `NonNullRef`\n- `Select`, `SelectNonNull`\n- `Cast\u003cT\u003e`, `CastExact\u003cT\u003e`, `CastChecked\u003cT\u003e`, `CastCheckedRef\u003cT\u003e`\n- `OfType\u003cT\u003e`, `OfTypeRef\u003cT\u003e`, `OfTypeExact\u003cT\u003e`, `OfTypeExactRef\u003cT\u003e`, `OfType`, `OfTypeRef`\n- `FirstOrDefault`\n- `Count`\n- `Sum`\n- `Accumulate`\n- `ToArray`\n- `ToSet`\n- `All`, `Any`, `None`\n- `Selectors::CDO`\n- `Filters::IsChildOf\u003cT\u003e`, `Filters::IsChildOf`\n\n----\n\n### 🔗 Related Links\n\n- [Ranges library (C++20)](https://en.cppreference.com/w/cpp/ranges)\n- [\\\u003cranges\\\u003e | Microsoft Learn](https://learn.microsoft.com/en-us/cpp/standard-library/ranges)\n- [Language Integrated Query (LINQ) - C# | Microsoft Learn](https://learn.microsoft.com/en-us/dotnet/csharp/linq/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figood%2Figranges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figood%2Figranges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figood%2Figranges/lists"}