[deploy] update string functions

This commit is contained in:
Nomango 2020-04-14 12:28:29 +08:00
parent 530fca11cc
commit 8037ff96cf
8 changed files with 13 additions and 12 deletions

View File

@ -74,7 +74,7 @@ HRESULT Transcoder::LoadMediaFile(const String& file_path)
{
HRESULT hr = S_OK;
WideString path = strings::ToWide(file_path);
WideString path = strings::NarrowToWide(file_path);
ComPtr<IMFSourceReader> reader;
hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromURL(path.c_str(), nullptr, &reader);

View File

@ -67,7 +67,7 @@ WideString Format(const wchar_t* format, ...)
return result;
}
String ToNarrow(const WideString& str)
String WideToNarrow(const WideString& str)
{
if (str.empty())
return String();
@ -84,7 +84,7 @@ String ToNarrow(const WideString& str)
return String();
}
WideString ToWide(const String& str)
WideString NarrowToWide(const String& str)
{
if (str.empty())
return WideString();

View File

@ -45,11 +45,11 @@ WideString Format(const wchar_t* format, ...);
/// \~chinese
/// @brief ¿í×Ö·û´®×ªÕ­×Ö·û´®
String ToNarrow(const WideString& str);
String WideToNarrow(const WideString& str);
/// \~chinese
/// @brief Õ­×Ö·û´®×ª¿í×Ö·û´®
WideString ToWide(const String& str);
WideString NarrowToWide(const String& str);
}

View File

@ -23,6 +23,7 @@
namespace kiwano
{
/**
* \~chinese
* @brief

View File

@ -624,7 +624,7 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA
{
KGE_SYS_LOG("Window title changed");
this->title_ = strings::ToNarrow(reinterpret_cast<LPCWSTR>(lparam));
this->title_ = strings::WideToNarrow(reinterpret_cast<LPCWSTR>(lparam));
WindowTitleChangedEventPtr evt = new WindowTitleChangedEvent;
evt->title = this->title_;

View File

@ -306,7 +306,7 @@ HRESULT STDMETHODCALLTYPE FontFileEnumerator::MoveNext(_Out_ BOOL* hasCurrentFil
if (nextIndex_ < filePaths_.size())
{
WideString file_name = strings::ToWide(filePaths_[nextIndex_]);
WideString file_name = strings::NarrowToWide(filePaths_[nextIndex_]);
hr = pFactory_->CreateFontFileReference(file_name.c_str(), NULL, &currentFile_);

View File

@ -168,7 +168,7 @@ void RendererImpl::CreateTexture(Texture& texture, const String& file_path)
if (SUCCEEDED(hr))
{
WideString full_path = strings::ToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
WideString full_path = strings::NarrowToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
ComPtr<IWICBitmapDecoder> decoder;
hr = d2d_res_->CreateBitmapDecoderFromFile(decoder, full_path.c_str());
@ -279,7 +279,7 @@ void RendererImpl::CreateGifImage(GifImage& gif, const String& file_path)
if (SUCCEEDED(hr))
{
WideString full_path = strings::ToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
WideString full_path = strings::NarrowToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
ComPtr<IWICBitmapDecoder> decoder;
hr = d2d_res_->CreateBitmapDecoderFromFile(decoder, full_path.c_str());
@ -581,7 +581,7 @@ void RendererImpl::CreateTextLayout(TextLayout& layout, const String& content, c
if (SUCCEEDED(hr))
{
WideString font_family = style.font_family.empty() ? L"" : strings::ToWide(style.font_family);
WideString font_family = style.font_family.empty() ? L"" : strings::NarrowToWide(style.font_family);
DWRITE_FONT_WEIGHT font_weight = DWRITE_FONT_WEIGHT(style.font_weight);
DWRITE_FONT_STYLE font_style = style.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL;
auto collection = NativePtr::Get<IDWriteFontCollection>(style.font);
@ -592,7 +592,7 @@ void RendererImpl::CreateTextLayout(TextLayout& layout, const String& content, c
if (SUCCEEDED(hr))
{
WideString wide = strings::ToWide(content);
WideString wide = strings::NarrowToWide(content);
ComPtr<IDWriteTextLayout> output;
hr = d2d_res_->CreateTextLayout(output, wide.c_str(), wide.length(), format);

View File

@ -127,7 +127,7 @@ void TextLayout::SetFontFamily(const String& family, TextRange range)
if (native)
{
WideString font_family = family.empty() ? L"" : strings::ToWide(family);
WideString font_family = family.empty() ? L"" : strings::NarrowToWide(family);
HRESULT hr = native->SetFontFamilyName(font_family.c_str(), { range.start, range.length });
KGE_THROW_IF_FAILED(hr, "IDWriteTextLayout::SetFontFamilyName failed");