[nostalgia,keel] Move core::TypeStore to Keel
This commit is contained in:
@ -6,6 +6,7 @@ add_library(
|
||||
module.cpp
|
||||
pack.cpp
|
||||
typeconv.cpp
|
||||
typestore.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
@ -28,6 +29,7 @@ install(
|
||||
module.hpp
|
||||
pack.hpp
|
||||
typeconv.hpp
|
||||
typestore.hpp
|
||||
DESTINATION
|
||||
include/keel
|
||||
)
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "media.hpp"
|
||||
#include "module.hpp"
|
||||
#include "pack.hpp"
|
||||
#include "typestore.hpp"
|
||||
|
||||
namespace keel {
|
||||
|
||||
|
17
src/keel/typestore.cpp
Normal file
17
src/keel/typestore.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include "typestore.hpp"
|
||||
|
||||
namespace keel {
|
||||
|
||||
ox::Result<ox::UniquePtr<ox::DescriptorType>> TypeStore::loadDescriptor(ox::CRStringView typeId) noexcept {
|
||||
auto path = ox::sfmt("{}/{}", m_descPath, typeId);
|
||||
oxRequire(buff, m_fs->read(path));
|
||||
auto dt = ox::make_unique<ox::DescriptorType>();
|
||||
oxReturnError(ox::readClaw<ox::DescriptorType>(buff, dt.get()));
|
||||
return dt;
|
||||
}
|
||||
|
||||
}
|
28
src/keel/typestore.hpp
Normal file
28
src/keel/typestore.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/claw/claw.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/model/typestore.hpp>
|
||||
|
||||
namespace keel {
|
||||
|
||||
class TypeStore: public ox::TypeStore {
|
||||
private:
|
||||
ox::FileSystem *m_fs = nullptr;
|
||||
ox::String m_descPath;
|
||||
|
||||
public:
|
||||
constexpr explicit TypeStore(ox::FileSystem *fs, ox::String descPath = "/.keel/type_descriptors") noexcept:
|
||||
m_fs(fs),
|
||||
m_descPath(std::move(descPath)) {
|
||||
}
|
||||
|
||||
protected:
|
||||
ox::Result<ox::UniquePtr<ox::DescriptorType>> loadDescriptor(ox::CRStringView typeId) noexcept override;
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user