VR-Engage  2.2
Loading...
Searching...
No Matches
luaEncoderDecoder.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file luaEncoderDecoder.h
7//! \ingroup vreUtil
8//! \brief Provides type conversion between C++ and Lua
9//!
10//! This file defines the base encoder and decoder classes for converting between
11//! C++ data types and Lua values. It forms the foundation for type-safe data
12//! exchange between C++ and Lua within the VREngage system.
13
14#pragma once
15
16#include "vreUtil/export.h"
17
18struct lua_State;
19
20namespace makVre
21{
22class DtLuaObject;
23class DtLuaFunction;
24
25
26//! \brief Base class for all Lua to C++ decoders
27//!
28//! This abstract base class defines the interface for all type-specific decoders
29//! that convert Lua values to C++ values.
31 public:
32 //! \brief Default constructor
34
35 //! \brief Virtual destructor
36 virtual ~DtBaseDecoder(){}
37};
38
39//! \brief Type-specific decoder for converting Lua values to C++ values
40//! \tparam T The C++ type to convert to
41//!
42//! This template class defines the interface for type-specific decoders.
43//! Specializations of this template implement the actual conversion for each supported type.
44template <typename T>
46{
47public:
48 //! \brief Converts a Lua value to a C++ value
49 //! \param state Pointer to the Lua state
50 //! \param index Index of the value on the Lua stack
51 //! \return The value converted to the specified C++ type
52 virtual T get(lua_State* state, int index);
53};
54
55//! \brief Base class for all C++ to Lua encoders
56//!
57//! This abstract base class defines the interface for all type-specific encoders
58//! that convert C++ values to Lua values.
60 public:
61 //! \brief Default constructor
63
64 //! \brief Virtual destructor
65 virtual ~DtBaseEncoder(){}
66};
67
68//! \brief Type-specific encoder for converting C++ values to Lua values
69//! \tparam T The C++ type to convert from
70//!
71//! This template class defines the interface for type-specific encoders.
72//! Specializations of this template implement the actual conversion for each supported type.
73//! The implementation for all these classes is defined in the source file.
74template <typename T>
76{
77public:
78 //! \brief Pushes a C++ value onto the Lua stack
79 //! \param state Pointer to the Lua state
80 //! \param data The C++ value to push onto the Lua stack
81 virtual void push(lua_State* state, const T& data);
82};
83
84#pragma endregion
85} // namespace makVre
DtBaseDecoder()
Default constructor.
Definition luaEncoderDecoder.h:33
virtual ~DtBaseDecoder()
Virtual destructor.
Definition luaEncoderDecoder.h:36
DtBaseEncoder()
Default constructor.
Definition luaEncoderDecoder.h:62
virtual ~DtBaseEncoder()
Virtual destructor.
Definition luaEncoderDecoder.h:65
C++ wrapper for Lua functions.
Definition luaFunction.h:32
Represents a Lua object (typically a table) in C++.
Definition luaObject.h:37
Type-specific decoder for converting Lua values to C++ values.
Definition luaEncoderDecoder.h:46
virtual T get(lua_State *state, int index)
Converts a Lua value to a C++ value.
Type-specific encoder for converting C++ values to Lua values.
Definition luaEncoderDecoder.h:76
virtual void push(lua_State *state, const T &data)
Pushes a C++ value onto the Lua stack.
Defines export macros for the VREngage Utility library.
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Include export definitions for this library.
Definition glsVreMessageUtil.h:49