basic_string supported
This commit is contained in:
parent
4b1a2921e4
commit
ea6ce3d545
|
|
@ -30,7 +30,7 @@ namespace kiwano
|
||||||
{
|
{
|
||||||
DebugNode::DebugNode()
|
DebugNode::DebugNode()
|
||||||
{
|
{
|
||||||
debug_text_ = new Text();
|
debug_text_ = new Text;
|
||||||
debug_text_->SetPosition(20, 20);
|
debug_text_->SetPosition(20, 20);
|
||||||
this->AddChild(debug_text_);
|
this->AddChild(debug_text_);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ namespace kiwano
|
||||||
|
|
||||||
String Object::DumpObject()
|
String Object::DumpObject()
|
||||||
{
|
{
|
||||||
String name = typeid(*this).name();
|
String name = kiwano::string_to_wide(typeid(*this).name());
|
||||||
return String::format(L"{ class=\"%s\" id=%d refcount=%d name=\"%s\" }",
|
return String::format(L"{ class=\"%s\" id=%d refcount=%d name=\"%s\" }",
|
||||||
name.c_str(), GetObjectID(), GetRefCount(), GetName().c_str());
|
name.c_str(), GetObjectID(), GetRefCount(), GetName().c_str());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ namespace kiwano
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
|
|
||||||
Time::Time()
|
Time::Time()
|
||||||
|
: dur_(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,21 +162,21 @@ namespace kiwano
|
||||||
|
|
||||||
if (hour)
|
if (hour)
|
||||||
{
|
{
|
||||||
result.append(kiwano::to_wstring(hour)).append(L"h");
|
result.append(String::parse(hour)).append(L"h");
|
||||||
result.append(kiwano::to_wstring(min)).append(L"m");
|
result.append(String::parse(min)).append(L"m");
|
||||||
}
|
}
|
||||||
else if(min)
|
else if(min)
|
||||||
{
|
{
|
||||||
result.append(kiwano::to_wstring(min)).append(L"m");
|
result.append(String::parse(min)).append(L"m");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ms != 0)
|
if (ms != 0)
|
||||||
{
|
{
|
||||||
auto float_to_str = [](float val) -> std::wstring
|
auto float_to_str = [](float val) -> String
|
||||||
{
|
{
|
||||||
wchar_t buf[10] = {};
|
wchar_t buf[10] = {};
|
||||||
::swprintf_s(buf, L"%.2f", val);
|
::swprintf_s(buf, L"%g", val);
|
||||||
return std::wstring(buf);
|
return String(buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
result.append(float_to_str(static_cast<float>(sec) + static_cast<float>(ms) / 1000.f))
|
result.append(float_to_str(static_cast<float>(sec) + static_cast<float>(ms) / 1000.f))
|
||||||
|
|
@ -183,7 +184,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
else if (sec != 0)
|
else if (sec != 0)
|
||||||
{
|
{
|
||||||
result.append(kiwano::to_wstring(sec)).append(L"s");
|
result.append(String::parse(sec)).append(L"s");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,7 +274,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
json_value(json_value&& other)
|
json_value(json_value&& other) noexcept
|
||||||
{
|
{
|
||||||
type = other.type;
|
type = other.type;
|
||||||
data = other.data;
|
data = other.data;
|
||||||
|
|
@ -340,7 +340,7 @@ namespace kiwano
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline json_value& operator=(json_value && other)
|
inline json_value& operator=(json_value && other) noexcept
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type = other.type;
|
type = other.type;
|
||||||
|
|
@ -1849,7 +1849,7 @@ namespace kiwano
|
||||||
|
|
||||||
basic_json(basic_json const& other) : value_(other.value_) {}
|
basic_json(basic_json const& other) : value_(other.value_) {}
|
||||||
|
|
||||||
basic_json(basic_json&& other) : value_(std::move(other.value_))
|
basic_json(basic_json&& other) noexcept : value_(std::move(other.value_))
|
||||||
{
|
{
|
||||||
// invalidate payload
|
// invalidate payload
|
||||||
other.value_.type = JsonType::Null;
|
other.value_.type = JsonType::Null;
|
||||||
|
|
@ -2354,7 +2354,7 @@ namespace kiwano
|
||||||
return (*this);
|
return (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline basic_json& operator=(basic_json&& other)
|
inline basic_json& operator=(basic_json&& other) noexcept
|
||||||
{
|
{
|
||||||
value_ = std::move(other.value_);
|
value_ = std::move(other.value_);
|
||||||
return (*this);
|
return (*this);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -120,7 +120,7 @@ namespace kiwano
|
||||||
float DataUtil::GetFloat(String const & key, float default_value) const
|
float DataUtil::GetFloat(String const & key, float default_value) const
|
||||||
{
|
{
|
||||||
wchar_t temp[32] = { 0 };
|
wchar_t temp[32] = { 0 };
|
||||||
String default_str = to_wstring(default_value);
|
String default_str = String::parse(default_value);
|
||||||
::GetPrivateProfileStringW(field_name_.c_str(), key.c_str(), default_str.c_str(), temp, 31, file_path_.c_str());
|
::GetPrivateProfileStringW(field_name_.c_str(), key.c_str(), default_str.c_str(), temp, 31, file_path_.c_str());
|
||||||
return std::stof(temp);
|
return std::stof(temp);
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ namespace kiwano
|
||||||
double DataUtil::GetDouble(String const & key, double default_value) const
|
double DataUtil::GetDouble(String const & key, double default_value) const
|
||||||
{
|
{
|
||||||
wchar_t temp[32] = { 0 };
|
wchar_t temp[32] = { 0 };
|
||||||
String default_str = to_wstring(default_value);
|
String default_str = String::parse(default_value);
|
||||||
::GetPrivateProfileStringW(field_name_.c_str(), key.c_str(), default_str.c_str(), temp, 31, file_path_.c_str());
|
::GetPrivateProfileStringW(field_name_.c_str(), key.c_str(), default_str.c_str(), temp, 31, file_path_.c_str());
|
||||||
return std::stod(temp);
|
return std::stod(temp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,14 +129,12 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
catch (std::wifstream::failure& e)
|
catch (std::wifstream::failure& e)
|
||||||
{
|
{
|
||||||
String msg(e.what());
|
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot open file. (%s)", string_to_wide(e.what()).c_str());
|
||||||
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot open file. (%s)", msg.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (json_exception& e)
|
catch (json_exception& e)
|
||||||
{
|
{
|
||||||
String msg(e.what());
|
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot parse to JSON. (%s)", string_to_wide(e.what()).c_str());
|
||||||
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot parse to JSON. (%s)", msg.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return LoadFromJson(json_data);
|
return LoadFromJson(json_data);
|
||||||
|
|
@ -158,8 +156,7 @@ namespace kiwano
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
String msg(e.what());
|
KGE_WARNING_LOG(L"ResLoader::LoadFromJson failed: JSON data is invalid. (%s)", string_to_wide(e.what()).c_str());
|
||||||
KGE_WARNING_LOG(L"ResLoader::LoadFromJson failed: JSON data is invalid. (%s)", msg.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue