From 8037ff96cf94c9e21b68c8597df6d7ba3440aead Mon Sep 17 00:00:00 2001 From: Nomango Date: Tue, 14 Apr 2020 12:28:29 +0800 Subject: [PATCH] [deploy] update string functions --- src/kiwano-audio/Transcoder.cpp | 2 +- src/kiwano/core/String.cpp | 4 ++-- src/kiwano/core/String.h | 4 ++-- src/kiwano/core/Time.h | 1 + src/kiwano/platform/win32/WindowImpl.cpp | 2 +- src/kiwano/render/DirectX/FontCollectionLoader.cpp | 2 +- src/kiwano/render/DirectX/RendererImpl.cpp | 8 ++++---- src/kiwano/render/TextLayout.cpp | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/kiwano-audio/Transcoder.cpp b/src/kiwano-audio/Transcoder.cpp index 6cf4e254..29c256a5 100644 --- a/src/kiwano-audio/Transcoder.cpp +++ b/src/kiwano-audio/Transcoder.cpp @@ -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 reader; hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromURL(path.c_str(), nullptr, &reader); diff --git a/src/kiwano/core/String.cpp b/src/kiwano/core/String.cpp index c81c6a51..aaeef7f6 100644 --- a/src/kiwano/core/String.cpp +++ b/src/kiwano/core/String.cpp @@ -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(); diff --git a/src/kiwano/core/String.h b/src/kiwano/core/String.h index 38902a91..cdb45b54 100644 --- a/src/kiwano/core/String.h +++ b/src/kiwano/core/String.h @@ -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); } diff --git a/src/kiwano/core/Time.h b/src/kiwano/core/Time.h index 34d40373..e563c440 100644 --- a/src/kiwano/core/Time.h +++ b/src/kiwano/core/Time.h @@ -23,6 +23,7 @@ namespace kiwano { + /** * \~chinese * @brief ʱ¼ä¶Î diff --git a/src/kiwano/platform/win32/WindowImpl.cpp b/src/kiwano/platform/win32/WindowImpl.cpp index c3ac3700..2499945b 100644 --- a/src/kiwano/platform/win32/WindowImpl.cpp +++ b/src/kiwano/platform/win32/WindowImpl.cpp @@ -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(lparam)); + this->title_ = strings::WideToNarrow(reinterpret_cast(lparam)); WindowTitleChangedEventPtr evt = new WindowTitleChangedEvent; evt->title = this->title_; diff --git a/src/kiwano/render/DirectX/FontCollectionLoader.cpp b/src/kiwano/render/DirectX/FontCollectionLoader.cpp index 7dd1a870..4b4b7727 100644 --- a/src/kiwano/render/DirectX/FontCollectionLoader.cpp +++ b/src/kiwano/render/DirectX/FontCollectionLoader.cpp @@ -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, ¤tFile_); diff --git a/src/kiwano/render/DirectX/RendererImpl.cpp b/src/kiwano/render/DirectX/RendererImpl.cpp index 596f3598..927820e9 100644 --- a/src/kiwano/render/DirectX/RendererImpl.cpp +++ b/src/kiwano/render/DirectX/RendererImpl.cpp @@ -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 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 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(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 output; hr = d2d_res_->CreateTextLayout(output, wide.c_str(), wide.length(), format); diff --git a/src/kiwano/render/TextLayout.cpp b/src/kiwano/render/TextLayout.cpp index 210e1d2a..2cf95b8a 100644 --- a/src/kiwano/render/TextLayout.cpp +++ b/src/kiwano/render/TextLayout.cpp @@ -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");