{"id":23911891,"url":"https://github.com/imdanielsp/sow","last_synced_at":"2026-07-02T10:31:40.019Z","repository":{"id":270772200,"uuid":"911414128","full_name":"imdanielsp/sow","owner":"imdanielsp","description":"SOW: A Header-Only Utility Library for Save-on-Write Functionality","archived":false,"fork":false,"pushed_at":"2025-01-03T05:39:06.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"mainline","last_synced_at":"2025-11-10T12:11:13.494Z","etag":null,"topics":["cpp17","header-only","library","utility"],"latest_commit_sha":null,"homepage":"https://github.com/imdanielsp/sow","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/imdanielsp.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":"2025-01-03T00:53:47.000Z","updated_at":"2025-01-03T05:39:10.000Z","dependencies_parsed_at":"2025-01-10T04:42:32.790Z","dependency_job_id":null,"html_url":"https://github.com/imdanielsp/sow","commit_stats":null,"previous_names":["imdanielsp/sow"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/imdanielsp/sow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdanielsp%2Fsow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdanielsp%2Fsow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdanielsp%2Fsow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdanielsp%2Fsow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imdanielsp","download_url":"https://codeload.github.com/imdanielsp/sow/tar.gz/refs/heads/mainline","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdanielsp%2Fsow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35043933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"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":["cpp17","header-only","library","utility"],"created_at":"2025-01-05T08:32:15.605Z","updated_at":"2026-07-02T10:31:40.005Z","avatar_url":"https://github.com/imdanielsp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/imdanielsp/sow/actions/workflows/build.yml/badge.svg)\n\n# SOW – Save-On-Write\n\nThe SOW library is a header-only C++ library that provides a way to save data to disk only when it is modified. This is\nuseful when you have a data structure that is not modified frequently, but when it is, it is important to save it to\ndisk immediately.\n\n## Motivation\n\nThe SOW library was created to solve a problem I encountered while working on a project that required saving a data\nstructure immediately after it was modified. The data structure was not modified frequently, but when it was, it was\nimportant to save it to disk immediately.\n\nNormally, applications would mutate the data structure in memory and then save it to disk by explicitly invoking a save\nroutine.\n\n```cpp\nMyData data;\ndata.a = 42;\ndata.b = 43;\n\n// Save the data to disk\nsave_data_fn(data);\n```\n\nThis approach works well until someone forgets to save the data structure to disk after modifying it. This can\nlead to data loss if the application crashes before the data structure is saved, or worst, unexpected behavior if the\napplication continues to run with the old data.\n\nThe SOW library solves this problem by only allowing mutation via a proxy object (a `SowGuard`) that saves the data to\ndisk when it is destroyed.\n\n```cpp\nsow::Sow data { MyData{}, save_data_fn };\n\ndata.get_mut()-\u003ea = 42;\n```\n\nWhere the `save_data_fn` is a function that saves the data to disk.\n\n```cpp\nvoid save_data_fn(const MyData\u0026 data) {\n    // Save the data to disk\n}\n```\n\nBut what if the data structure is modified multiple times before it is saved to disk?\n\n```cpp\nsow::Sow data { MyData{}, save_data_fn };\n\n{\n    auto guard = data.get_mut();\n    guard-\u003ea = 42;\n    guard-\u003eb = 43;\n}\n```\n\nOr \"sow it\" (save-on-write it):\n\n```cpp\nsow::Sow data { MyData{}, save_data_fn };\n\nsow::it(data, [](auto\u0026 data) {\n    data.a = 42;\n    data.b = 43;\n});\n```\n\n# Installation\n\nThe SOW library is a header-only library. To use it, simply include the `sow.hpp` header file in your project or run the\nmake install command to install it on your system.\n\n```sh\ncmake -B build -S .\ncmake --install build # Needs sudo\n```\n\n# Testing\n\nThe SOW library comes with a test suite that can be run using the following commands:\n\n```sh\ncmake -B build -S .\ncmake --build build\ncd build\nctest\nTest project /Users/dsantos/Documents/projects/sow/build\n      Start  1: SowTest.SowConstGet\n 1/12 Test  #1: SowTest.SowConstGet .......................   Passed    0.01 sec\n      Start  2: SowTest.SowConstDeref\n 2/12 Test  #2: SowTest.SowConstDeref .....................   Passed    0.00 sec\n      Start  3: SowTest.SowConstArrow\n 3/12 Test  #3: SowTest.SowConstArrow .....................   Passed    0.00 sec\n      Start  4: SowTest.SowGuardOnce\n 4/12 Test  #4: SowTest.SowGuardOnce ......................   Passed    0.00 sec\n      Start  5: SowTest.SowGuardMultiple\n 5/12 Test  #5: SowTest.SowGuardMultiple ..................   Passed    0.00 sec\n      Start  6: SowTest.SowGuardMultipleWithFunc\n 6/12 Test  #6: SowTest.SowGuardMultipleWithFunc ..........   Passed    0.00 sec\n      Start  7: SowTest.SowWithDefaultConstructor\n 7/12 Test  #7: SowTest.SowWithDefaultConstructor .........   Passed    0.00 sec\n      Start  8: SowTest.SowWithDefaultConstructedWriter\n 8/12 Test  #8: SowTest.SowWithDefaultConstructedWriter ...   Passed    0.00 sec\n      Start  9: SowTest.SowWithLambdaWriter\n 9/12 Test  #9: SowTest.SowWithLambdaWriter ...............   Passed    0.00 sec\n      Start 10: SowTest.SowWithFreeFuncWriter\n10/12 Test #10: SowTest.SowWithFreeFuncWriter .............   Passed    0.00 sec\n      Start 11: SowTest.SowTrivialDataType\n11/12 Test #11: SowTest.SowTrivialDataType ................   Passed    0.00 sec\n      Start 12: SowTest.SowSTLType\n12/12 Test #12: SowTest.SowSTLType ........................   Passed    0.00 sec\n\n100% tests passed, 0 tests failed out of 12\n\nTotal Test time (real) =   0.05 sec\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimdanielsp%2Fsow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimdanielsp%2Fsow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimdanielsp%2Fsow/lists"}