Skip to content

Commit

Permalink
Merge pull request #1855 from mwestphal/utils_cxx17
Browse files Browse the repository at this point in the history
utils/window: Update API for C++17
  • Loading branch information
mwestphal authored Jan 2, 2025
2 parents 3ccb558 + a402042 commit c2529be
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion library/private/window_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class window_impl : public window
window& setSize(int width, int height) override;
window& setPosition(int x, int y) override;
window& setIcon(const unsigned char* icon, size_t iconSize) override;
window& setWindowName(const std::string& windowName) override;
window& setWindowName(std::string_view windowName) override;
point3_t getWorldFromDisplay(const point3_t& displayPoint) const override;
point3_t getDisplayFromWorld(const point3_t& worldPoint) const override;
///@}
Expand Down
2 changes: 1 addition & 1 deletion library/public/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class F3D_EXPORT utils
* Compute the Levenshtein distance between two strings.
* Can be useful for spell checking and typo detection.
*/
[[nodiscard]] static unsigned int textDistance(const std::string& strA, const std::string& strB);
[[nodiscard]] static unsigned int textDistance(std::string_view strA, std::string_view strB);

// clang-format off
/**
Expand Down
2 changes: 1 addition & 1 deletion library/public/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class F3D_EXPORT window
/**
* Set the window name to be shown by a window manager.
*/
virtual window& setWindowName(const std::string& windowName) = 0;
virtual window& setWindowName(std::string_view windowName) = 0;

/**
* Convert a point in display coordinate to world coordinate.
Expand Down
2 changes: 1 addition & 1 deletion library/src/utils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace f3d
{
//----------------------------------------------------------------------------
unsigned int utils::textDistance(const std::string& strA, const std::string& strB)
unsigned int utils::textDistance(std::string_view strA, std::string_view strB)
{
return static_cast<unsigned int>(detail::levenshtein(strA, strB));
}
Expand Down
4 changes: 2 additions & 2 deletions library/src/window_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ window& window_impl::setIcon(const unsigned char* icon, size_t iconSize)
}

//----------------------------------------------------------------------------
window& window_impl::setWindowName(const std::string& windowName)
window& window_impl::setWindowName(std::string_view windowName)
{
this->Internals->RenWin->SetWindowName(windowName.c_str());
this->Internals->RenWin->SetWindowName(windowName.data());
return *this;
}

Expand Down

0 comments on commit c2529be

Please sign in to comment.