[ox] Add StringView, Writer system, Preloader system
This commit is contained in:
13
deps/ox/src/ox/claw/write.hpp
vendored
13
deps/ox/src/ox/claw/write.hpp
vendored
@ -24,10 +24,12 @@ namespace detail {
|
||||
struct TypeInfoCatcher {
|
||||
|
||||
const char *name = nullptr;
|
||||
int version = 0;
|
||||
|
||||
template<typename T = void>
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int = T::TypeVersion) noexcept {
|
||||
constexpr void setTypeInfo(const char *name = T::TypeName, int v = T::TypeVersion, const Vector<String>& = {}, int = 0) noexcept {
|
||||
this->name = name;
|
||||
this->version = v;
|
||||
}
|
||||
|
||||
constexpr Error field(...) noexcept {
|
||||
@ -57,6 +59,13 @@ constexpr const char *getTypeName(T *t) noexcept {
|
||||
return tnc.name;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr int getTypeVersion(T *t) noexcept {
|
||||
TypeInfoCatcher tnc;
|
||||
oxIgnoreError(model(&tnc, t));
|
||||
return tnc.version;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Result<String> writeClawHeader(T *t, ClawFormat fmt) noexcept {
|
||||
String out;
|
||||
@ -72,7 +81,7 @@ Result<String> writeClawHeader(T *t, ClawFormat fmt) noexcept {
|
||||
}
|
||||
out += detail::getTypeName(t);
|
||||
out += ";";
|
||||
const auto tn = detail::type_version<T>::value;
|
||||
const auto tn = detail::getTypeVersion(t);
|
||||
if (tn > -1) {
|
||||
out += tn;
|
||||
}
|
||||
|
Reference in New Issue
Block a user