{"id":21146371,"url":"https://github.com/bhallstein/luaobj","last_synced_at":"2025-03-14T13:44:22.474Z","repository":{"id":143863482,"uuid":"263393536","full_name":"bhallstein/LuaObj","owner":"bhallstein","description":"Read Lua tables and convert them into native C++ objects (legacy)","archived":false,"fork":false,"pushed_at":"2020-05-12T16:45:22.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T07:42:45.797Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bhallstein.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-05-12T16:37:36.000Z","updated_at":"2023-08-03T07:23:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"b8b062c8-3276-42d8-98d7-613808caadec","html_url":"https://github.com/bhallstein/LuaObj","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2FLuaObj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2FLuaObj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2FLuaObj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bhallstein%2FLuaObj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bhallstein","download_url":"https://codeload.github.com/bhallstein/LuaObj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243589287,"owners_count":20315467,"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":[],"created_at":"2024-11-20T08:53:12.679Z","updated_at":"2025-03-14T13:44:22.450Z","avatar_url":"https://github.com/bhallstein.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# About LuaObj\n\nLuaObj is a class which recursively converts Lua tables into nested C++ objects.\n\n## Creating\n\nThe constructor simply takes a filename and the name of the (global) object to load, returning a LuaObj representing that object:\n\n```cpp\nLuaObj myObj(\"file.lua\", \"a_table\");\n```\n\n- If the object is a table, the `descendants` map is populated recursively with the contents of the table.\n- If the object is a supported simple type, it is represented in the appropriate LuaObj property.\n\nAlternatively, you can construct a LuaObj from a Lua state that you manage yourself. You just need to push the table you want to load to position -1 on the stack:\n\n```cpp\nlua_State *L;\nif (!LuaObj::loadLuaFile(\"file.lua\", \u0026L))\n\t; // oh dear\n\nlua_getglobal(L, \"a_table\");\nLuaObj myObj(L);\nlua_pop(L, 1);\n\nlua_close(L);\n```\n\n## Types \u0026 Values\n\nA LuaObj may represent a table containing other values, or a number, string, bool, or nil. The type is stored in the object’s `type` property, and is one of the enum `LuaObj::Type::T` values, `Numeric`, `Bool`, `String`, `Table`, or `_Nil`.\n\nThe represented value itself is stored in another property – depending on type, `double number_value`, `bool bool_value`, or `std::string str_value`.\n\n```cpp\nif (myObj.type == LuaObj::Type::Table)\n    ; // iterate its descendants, perhaps\n    \nif (myObj.type == LuaObj::Type::Numeric)\n    double f = myObj.number_value;\n```\n\n\n## Accessing Descendants\n\nDescendants are accessed using the subscript operator:\n\n```cpp\nLuaObj a_descendant = myObj[\"descendant_name\"];\n```\n\nTable members of unsupported type are skipped, i.e. not added to the descendants map at all.\n\nOn descendant ordering:\n\n- When populating the descendants map, LuaObj turns all table keys into strings\n- The map is sorted using the Numericoid String Comparator, i.e. '10zxc' will come after '1zxc'.\n\n\n## Kthx\n\nSee the .h for further details.\n\nLuaObj is made available under the MIT licence.\n\n– Ben Hallstein, 2012\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhallstein%2Fluaobj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbhallstein%2Fluaobj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbhallstein%2Fluaobj/lists"}