mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Add an easier std::string Variant constructor.
This commit is contained in:
@@ -58,21 +58,26 @@ Variant::Variant(double number)
|
||||
data.number = number;
|
||||
}
|
||||
|
||||
Variant::Variant(const char *string, size_t len)
|
||||
Variant::Variant(const char *str, size_t len)
|
||||
{
|
||||
if (len <= MAX_SMALL_STRING_LENGTH)
|
||||
{
|
||||
type = SMALLSTRING;
|
||||
memcpy(data.smallstring.str, string, len);
|
||||
memcpy(data.smallstring.str, str, len);
|
||||
data.smallstring.len = (uint8) len;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = STRING;
|
||||
data.string = new SharedString(string, len);
|
||||
data.string = new SharedString(str, len);
|
||||
}
|
||||
}
|
||||
|
||||
Variant::Variant(const std::string &str)
|
||||
: Variant(str.c_str(), str.length())
|
||||
{
|
||||
}
|
||||
|
||||
Variant::Variant(void *lightuserdata)
|
||||
: type(LUSERDATA)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user