[olympic,nostalgia] Cleanup with StringParam
All checks were successful
Build / build (push) Successful in 2m33s

This commit is contained in:
2024-08-30 20:47:43 -05:00
parent f4a9872fe0
commit bd2e88cd88
16 changed files with 59 additions and 60 deletions

View File

@@ -123,7 +123,7 @@ class Editor: public studio::BaseEditor {
ox::String m_itemName;
public:
Editor(ox::StringView itemPath) noexcept;
Editor(ox::StringParam itemPath) noexcept;
[[nodiscard]]
ox::CStringView itemPath() const noexcept final;

View File

@@ -19,17 +19,17 @@ class ItemMaker {
ox::String const parentDir;
ox::String const fileExt;
constexpr explicit ItemMaker(
ox::StringView pName,
ox::StringView pParentDir,
ox::StringView pFileExt) noexcept:
typeName(pName),
parentDir(pParentDir),
fileExt(pFileExt) {
ox::StringParam pName,
ox::StringParam pParentDir,
ox::StringParam pFileExt) noexcept:
typeName{std::move(pName)},
parentDir{std::move(pParentDir)},
fileExt{std::move(pFileExt)} {
}
virtual ~ItemMaker() noexcept = default;
[[nodiscard]]
inline virtual ox::String itemPath(ox::StringView pName) const noexcept {
virtual ox::String itemPath(ox::StringView pName) const noexcept {
return ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
}
@@ -39,8 +39,7 @@ class ItemMaker {
* @param pName
* @return path of file or error in Result
*/
virtual ox::Result<ox::String> write(
studio::StudioContext &ctx, ox::CRStringView pName) const noexcept = 0;
virtual ox::Result<ox::String> write(StudioContext &ctx, ox::StringView pName) const noexcept = 0;
};
template<typename T>
@@ -50,36 +49,36 @@ class ItemMakerT: public ItemMaker {
ox::ClawFormat const m_fmt;
public:
constexpr ItemMakerT(
ox::StringView pDisplayName,
ox::StringView pParentDir,
ox::StringView fileExt,
ox::StringParam pDisplayName,
ox::StringParam pParentDir,
ox::StringParam fileExt,
ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept:
ItemMaker(pDisplayName, pParentDir, fileExt),
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
m_fmt(pFmt) {
}
constexpr ItemMakerT(
ox::StringView pDisplayName,
ox::StringView pParentDir,
ox::StringView fileExt,
ox::StringParam pDisplayName,
ox::StringParam pParentDir,
ox::StringParam fileExt,
T pItem,
ox::ClawFormat pFmt) noexcept:
ItemMaker(pDisplayName, pParentDir, fileExt),
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
m_item(std::move(pItem)),
m_fmt(pFmt) {
}
constexpr ItemMakerT(
ox::StringView pDisplayName,
ox::StringView pParentDir,
ox::StringView fileExt,
ox::StringParam pDisplayName,
ox::StringParam pParentDir,
ox::StringParam fileExt,
T &&pItem,
ox::ClawFormat pFmt) noexcept:
ItemMaker(pDisplayName, pParentDir, fileExt),
m_item(std::move(pItem)),
m_fmt(pFmt) {
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
m_item(std::move(pItem)),
m_fmt(pFmt) {
}
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::CRStringView pName) const noexcept override {
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::StringView const pName) const noexcept override {
auto const path = itemPath(pName);
keel::createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
return path;
}

View File

@@ -35,9 +35,9 @@ class Module {
template<typename Editor>
[[nodiscard]]
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::CRStringView ext) noexcept {
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::StringParam ext) noexcept {
return {
{ox::String(ext)},
{std::move(ext)},
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
return ox::makeCatch<Editor>(ctx, path);
}

View File

@@ -39,7 +39,7 @@ class Popup {
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
}
constexpr void setTitle(ox::String title) noexcept {
constexpr void setTitle(ox::StringParam title) noexcept {
m_title = std::move(title);
}