OOLua  2.0.1
C++ and Lua binding
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
String Configuration

Enables a string type to be treated as an integral. More...

Namespaces

 OOLUA::STRING
 Defines which type of string classes can be pulled and pushed from the stack with the public API and the DSL.
 

Classes

struct  OOLUA::STRING::only_std_string_conforming_with_c_str_method
 Defines the structure which checks for the method "c_str" which conforms to the std::string signature. More...
 
struct  OOLUA::STRING::is_integral_string_class
 Preforms the check on the type without including the string header. More...
 

Macros

#define OOLUA_STD_STRING_IS_INTEGRAL
 Default: Enabled More...
 
#define OOLUA_CLASS_OR_BASE_CONTAINS_METHOD(StructName, MethodSignature, MethodName)
 Creates a structure that enables checking a class type for a specific function signature that has a specific name. More...
 

Functions

template<typename StringType >
bool OOLUA::STRING::push (lua_State *const vm, StringType const &value)
 Function to which public API calls resolve to.
 
template<typename StringType >
bool OOLUA::STRING::pull (lua_State *const vm, StringType &value)
 Function to which public API calls resolve to.
 
template<typename StringType >
void OOLUA::STRING::get (lua_State *const vm, int idx, StringType &value)
 Internal function used by the DSL to retrieve a string from the stack. More...
 

Detailed Description

Enables a string type to be treated as an integral.

String configuration enables a type to be treated as an alias and integral type for a Lua string, LUA_TSTRING. When a type is considered an integral it means that a heap allocation, for the object itself, does not occur and the instance is a value rather than a reference. The alternative to this, is for the string type to be proxied using the library's DSL.

Identification of the type is tested using the compile time value contained in is_integral_string_class. A provided macro, OOLUA_CLASS_OR_BASE_CONTAINS_METHOD, helps to create a structure that identifies the type and can be used in is_integral_string_class. The library file oolua_string.h contains examples of using this macro to identify a number of string types; such as std::string, C++03 and C++11 strings(std::string, std::wstring, std::u16string and std::u32string), wxString and QString.

Once a type can be identified in is_integral_string_class as an integral string alias, then a user should provide implementations for the three specific templated functions, (OOLUA::STRING::push, OOLUA::STRING::pull and OOLUA::STRING::get) in oolua_string.cpp.

Macro Definition Documentation

#define OOLUA_CLASS_OR_BASE_CONTAINS_METHOD (   StructName,
  MethodSignature,
  MethodName 
)

Creates a structure that enables checking a class type for a specific function signature that has a specific name.

Parameters
StructNameThe name of the structure this macro will create.
MethodSignatureThe signature the checker will look for.
MethodNameThe function's name which has the MethodSignature
#define OOLUA_STD_STRING_IS_INTEGRAL

Default: Enabled

Allows std::string to be a parameter or a return type for a function.

Note
This is always by value
Parameters
0Disabled
1Enabled

Function Documentation

template<typename StringType >
void OOLUA::STRING::get ( lua_State *const  vm,
int  idx,
StringType &  value 
)

Internal function used by the DSL to retrieve a string from the stack.

The are a couple of differences between this function and pull. Firstly, pull retrieves the stack's top entry and pops it where as this function uses a stack index to identify the stack slot and the function does not pop the entry. Secondly, there is a difference in how errors are reported. Pull will either store and error or throw an exception, where as this function will eventually call lua_error.