1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 17:45:34 +00:00
openmw/components/lua_ui/content.hpp

42 lines
1.1 KiB
C++
Raw Normal View History

2021-11-18 15:19:54 +00:00
#ifndef COMPONENTS_LUAUI_CONTENT
#define COMPONENTS_LUAUI_CONTENT
#include <map>
#include <string>
#include <sol/sol.hpp>
namespace LuaUi
{
class Content
{
2022-09-22 18:26:05 +00:00
public:
using iterator = std::vector<sol::table>::iterator;
2021-11-18 15:19:54 +00:00
2022-09-22 18:26:05 +00:00
Content() {}
2021-11-18 15:19:54 +00:00
2022-09-22 18:26:05 +00:00
// expects a Lua array - a table with keys from 1 to n without any nil values in between
// any other keys are ignored
explicit Content(const sol::table&);
2021-11-18 15:19:54 +00:00
2022-09-22 18:26:05 +00:00
size_t size() const { return mOrdered.size(); }
2021-11-18 15:19:54 +00:00
2022-09-22 18:26:05 +00:00
void assign(std::string_view name, const sol::table& table);
void assign(size_t index, const sol::table& table);
void insert(size_t index, const sol::table& table);
2021-11-18 15:19:54 +00:00
2022-09-22 18:26:05 +00:00
sol::table at(size_t index) const;
sol::table at(std::string_view name) const;
size_t remove(size_t index);
size_t remove(std::string_view name);
size_t indexOf(const sol::table& table);
2021-11-18 15:19:54 +00:00
2022-09-22 18:26:05 +00:00
private:
std::map<std::string, size_t, std::less<>> mNamed;
std::vector<sol::table> mOrdered;
2021-11-18 15:19:54 +00:00
};
}
#endif // COMPONENTS_LUAUI_CONTENT