Value:as(ctype) method
Cast the Value to a new one, using the provided type.
Parameters
ctype
A string
representing the C type for the new Value, among any of the following strings :
ctype string | C type |
---|---|
"uchar" |
unsigned char |
"char" |
char |
"wchar_t" |
wchar_t |
"bool" |
boolean (C++)/int (C) |
"short" |
short |
"ushort" |
unsigned short |
"int" |
int |
"uint" |
unsigned int |
"long" |
long |
"long long" |
long long |
"ulong" |
unsigned long |
"ulonglong" |
unsigned long long |
"size_t" |
size_t |
"int16_t" |
int16_t |
"int32_t" |
int32_t |
"int64_t" |
int64_t |
"uint16_t" |
uint16_t |
"uint32_t" |
uint32_t |
"uint64_t" |
uint64_t |
"double" |
double |
"string" |
char * |
"wstring" |
wchar_t * |
"pointer" |
void * |
Return value
Returns the Value casted to the new C type.Example
local c = require "c"
-- Create a Value that contains an unsigned char (a byte) initialized with the number 72
local uchar = c.Value("uchar", 72)
-- Converts the uchar value as a char value
print(uchar:as("char"))