{"id":16209173,"url":"https://github.com/gilzoide/sqlite-vfs-cpp","last_synced_at":"2026-04-30T19:31:56.232Z","repository":{"id":233661221,"uuid":"787637903","full_name":"gilzoide/sqlite-vfs-cpp","owner":"gilzoide","description":"Single header with classes for easily implementing SQLite VFS shims in C++","archived":false,"fork":false,"pushed_at":"2024-11-04T21:42:28.000Z","size":2895,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-03T21:59:14.683Z","etag":null,"topics":["sqlite","sqlite-vfs","sqlite3","template","vfs","virtual-class"],"latest_commit_sha":null,"homepage":"https://gilzoide.github.io/sqlite-vfs-cpp/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilzoide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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":{"github":["gilzoide"],"patreon":null,"open_collective":null,"ko_fi":"gilzoide","tidelift":null,"community_bridge":null,"liberapay":"gilzoide","issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2024-04-16T22:40:21.000Z","updated_at":"2024-11-04T21:42:32.000Z","dependencies_parsed_at":"2024-04-17T02:50:50.329Z","dependency_job_id":"c4a3734a-c3b3-46d5-aefe-872fc2c4056f","html_url":"https://github.com/gilzoide/sqlite-vfs-cpp","commit_stats":null,"previous_names":["gilzoide/sqlite-vfs-cpp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gilzoide/sqlite-vfs-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fsqlite-vfs-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fsqlite-vfs-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fsqlite-vfs-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fsqlite-vfs-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilzoide","download_url":"https://codeload.github.com/gilzoide/sqlite-vfs-cpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2Fsqlite-vfs-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32475191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["sqlite","sqlite-vfs","sqlite3","template","vfs","virtual-class"],"created_at":"2024-10-10T10:28:20.490Z","updated_at":"2026-04-30T19:31:56.200Z","avatar_url":"https://github.com/gilzoide.png","language":"C++","funding_links":["https://github.com/sponsors/gilzoide","https://ko-fi.com/gilzoide","https://liberapay.com/gilzoide"],"categories":[],"sub_categories":[],"readme":"# SQLiteVfs.hpp\nSingle header with classes for easily implementing [SQLite](https://sqlite.org/) [VFS](https://www.sqlite.org/vfs.html) shims in C++11.\n\n\n## Features\n- Single header: copy [SQLiteVfs.hpp](SQLiteVfs.hpp) to your project, `#include \u003cSQLiteVfs.hpp\u003e` and that's it\n- Supports C++11 and above\n- Subclass `sqlite3vfs::SQLiteVfsImpl\u003c\u003e` to override any [VFS methods](https://www.sqlite.org/c3ref/vfs.html)\n  + Default implementations forward execution to the default VFS.\n    This makes it easy to implement VFS shims.\n- Subclass `sqlite3vfs::SQLiteFileImpl` to override any [File methods](https://www.sqlite.org/c3ref/io_methods.html)\n  + Default implementations forward execution to the File opened by `SQLiteVfsImpl::xOpen`.\n    This makes it easy to implement File shims.\n\n\n## Usage example\nThis sample code shows how to create a SQLite extension DLL that registers a simple VFS shim + File shim that logs read/write operations:\n\n```cpp\n// 1. Include \u003cSQLiteVfs.hpp\u003e header\n// If you are building an extension DLL, make sure to include\n// \u003csqlite3ext.h\u003e and call SQLITE_EXTENSION_INIT1 first.\n#include \u003csqlite3ext.h\u003e\nSQLITE_EXTENSION_INIT1\n#include \u003cSQLiteVfs.hpp\u003e\n\n#include \u003ciostream\u003e\n\nusing namespace sqlitevfs;\nusing namespace std;\n\n// 2. Implement your own `SQLiteFileImpl` subclass.\n// Override any IO methods necessary. Reference: https://www.sqlite.org/c3ref/io_methods.html\n// Default implementation will forward execution to the `original_file` opened by `SQLiteVfsImpl::xOpen`.\n// Default constructor will be called before `SQLiteVfsImpl::xOpen`.\n// Destructor will be called right after `xClose`, or after a failed `SQLiteVfsImpl::xOpen`.\nstruct LogIOFileShim : public SQLiteFileImpl {\n\tLogIOFileShim() {\n\t\tcout \u003c\u003c \"\u003e Constructing file!\" \u003c\u003c endl;\n\t}\n\tint xRead(void *p, int iAmt, sqlite3_int64 iOfst) override {\n\t\tcout \u003c\u003c \"\u003e READ \" \u003c\u003c iAmt \u003c\u003c \" bytes starting at \" \u003c\u003c iOfst \u003c\u003c endl;\n\t\treturn SQLiteFileImpl::xRead(p, iAmt, iOfst);\n\t}\n\tint xWrite(const void *p, int iAmt, sqlite3_int64 iOfst) override {\n\t\tcout \u003c\u003c \"\u003e WRITE \" \u003c\u003c iAmt \u003c\u003c \" bytes starting at \" \u003c\u003c iOfst \u003c\u003c endl;\n\t\treturn SQLiteFileImpl::xWrite(p, iAmt, iOfst);\n\t}\n\tint xClose() override {\n\t\tcout \u003c\u003c \"\u003e CLOSE\" \u003c\u003c endl;\n\t\treturn SQLiteFileImpl::xClose();\n\t}\n\t~LogIOFileShim() {\n\t\tcout \u003c\u003c \"\u003e Destroying file!\" \u003c\u003c endl;\n\t}\n};\n\n// 3. Implement your own `SQLiteVfsImpl\u003c\u003e` subclass.\n// Pass your SQLiteFileImpl subclass as template parameter.\n// Override any methods necessary. Reference: https://www.sqlite.org/c3ref/vfs.html\n// Default implementation will forward execution to the `original_vfs` passed in `SQLiteVfs` construtor.\n// Notice that `xOpen` receives a `SQLiteFile\u003cLogIOFileImpl\u003e *` instead of `sqlite3_file`.\n// `file` is guaranteed to be fully constructed before this method is called.\nstruct LogIOVfsShim : public SQLiteVfsImpl\u003cLogIOFileShim\u003e {\n\tint xOpen(sqlite3_filename zName, SQLiteFile\u003cLogIOFileShim\u003e *file, int flags, int *pOutFlags) override {\n\t\tint result = SQLiteVfsImpl::xOpen(zName, file, flags, pOutFlags);\n\t\tif (result == SQLITE_OK) {\n\t\t\tcout \u003c\u003c \"\u003e OPENED '\" \u003c\u003c zName \u003c\u003c \"'\" \u003c\u003c endl;\n\t\t}\n\t\telse {\n\t\t\tcout \u003c\u003c \"\u003e ERROR OPENING '\" \u003c\u003c zName \u003c\u003c \"': \" \u003c\u003c sqlite3_errstr(result) \u003c\u003c endl;\n\t\t}\n\t\treturn result;\n\t}\n};\n\n// If implementing an extension DLL, export the function as SQLite expects\nextern \"C\" int sqlite3_logiovfs_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) {\n\tSQLITE_EXTENSION_INIT2(pApi);\n\n\t// 4. Create a `SQLiteVfs\u003c\u003e`.\n\t// Pass your `SQLiteVfsImpl\u003c\u003e` subclass as template parameter.\n\tstatic SQLiteVfs\u003cLogIOVfsShim\u003e logiovfs(\"logiovfs\");\n\t\n\t// 5. Register your newly created VFS.\n\t// Optionally make it the default VFS.\n\tint rc = logiovfs.register_vfs(false);\n\tif (rc == SQLITE_OK) {\n\t\trc = SQLITE_OK_LOAD_PERMANENTLY;\n\t}\n\treturn rc;\n}\n\n// 6. (optional) Unregister your VFS using `my_vfs.unregister_vfs()`\n```\n\n\n## Samples\n- [logiovfs](samples/logiovfs.cpp): shows how to create a SQLite extension DLL that registers a simple VFS shim + File shim that logs read/write operations\n\nBuilding and running samples:\n```sh\n# build\nmkdir build\ncd build\ncmake ..\nmake\n\n# run from build folder\nsamples/logiovfs-sample\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fsqlite-vfs-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilzoide%2Fsqlite-vfs-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Fsqlite-vfs-cpp/lists"}