basic_string supported

This commit is contained in:
Nomango 2019-08-02 13:57:17 +08:00 committed by Nomango
parent 4b1a2921e4
commit ea6ce3d545
7 changed files with 564 additions and 391 deletions

View File

@ -30,7 +30,7 @@ namespace kiwano
{
DebugNode::DebugNode()
{
debug_text_ = new Text();
debug_text_ = new Text;
debug_text_->SetPosition(20, 20);
this->AddChild(debug_text_);

View File

@ -90,7 +90,7 @@ namespace kiwano
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\" }",
name.c_str(), GetObjectID(), GetRefCount(), GetName().c_str());
}

View File

@ -32,6 +32,7 @@ namespace kiwano
//-------------------------------------------------------
Time::Time()
: dur_(0)
{
}
@ -161,21 +162,21 @@ namespace kiwano
if (hour)
{
result.append(kiwano::to_wstring(hour)).append(L"h");
result.append(kiwano::to_wstring(min)).append(L"m");
result.append(String::parse(hour)).append(L"h");
result.append(String::parse(min)).append(L"m");
}
else if(min)
{
result.append(kiwano::to_wstring(min)).append(L"m");
result.append(String::parse(min)).append(L"m");
}
if (ms != 0)
{
auto float_to_str = [](float val) -> std::wstring
auto float_to_str = [](float val) -> String
{
wchar_t buf[10] = {};
::swprintf_s(buf, L"%.2f", val);
return std::wstring(buf);
::swprintf_s(buf, L"%g", val);
return String(buf);
};
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)
{
result.append(kiwano::to_wstring(sec)).append(L"s");
result.append(String::parse(sec)).append(L"s");
}
return result;
}

View File

@ -274,7 +274,7 @@ namespace kiwano
}
}
json_value(json_value&& other)
json_value(json_value&& other) noexcept
{
type = other.type;
data = other.data;
@ -340,7 +340,7 @@ namespace kiwano
return (*this);
}
inline json_value& operator=(json_value && other)
inline json_value& operator=(json_value && other) noexcept
{
clear();
type = other.type;
@ -1849,7 +1849,7 @@ namespace kiwano
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
other.value_.type = JsonType::Null;
@ -2354,7 +2354,7 @@ namespace kiwano
return (*this);
}
inline basic_json& operator=(basic_json&& other)
inline basic_json& operator=(basic_json&& other) noexcept
{
value_ = std::move(other.value_);
return (*this);

File diff suppressed because it is too large Load Diff

View File

@ -120,7 +120,7 @@ namespace kiwano
float DataUtil::GetFloat(String const & key, float default_value) const
{
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());
return std::stof(temp);
}
@ -128,7 +128,7 @@ namespace kiwano
double DataUtil::GetDouble(String const & key, double default_value) const
{
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());
return std::stod(temp);
}

View File

@ -129,14 +129,12 @@ namespace kiwano
}
catch (std::wifstream::failure& e)
{
String msg(e.what());
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot open file. (%s)", msg.c_str());
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot open file. (%s)", string_to_wide(e.what()).c_str());
return false;
}
catch (json_exception& e)
{
String msg(e.what());
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot parse to JSON. (%s)", msg.c_str());
KGE_WARNING_LOG(L"ResLoader::LoadFromJsonFile failed: Cannot parse to JSON. (%s)", string_to_wide(e.what()).c_str());
return false;
}
return LoadFromJson(json_data);
@ -158,8 +156,7 @@ namespace kiwano
}
catch (std::exception& e)
{
String msg(e.what());
KGE_WARNING_LOG(L"ResLoader::LoadFromJson failed: JSON data is invalid. (%s)", msg.c_str());
KGE_WARNING_LOG(L"ResLoader::LoadFromJson failed: JSON data is invalid. (%s)", string_to_wide(e.what()).c_str());
return false;
}
return true;