[ox/preloader] Fix ox::String handling, add start and end alloc functions
This commit is contained in:
		
							
								
								
									
										18
									
								
								deps/ox/src/ox/preloader/preloader.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								deps/ox/src/ox/preloader/preloader.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -86,6 +86,10 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> { | ||||
| 		template<typename T> | ||||
| 		constexpr ox::Error field(CRStringView, const T **val, std::size_t cnt) noexcept; | ||||
|  | ||||
| 		constexpr ox::Error startAlloc(std::size_t sz) noexcept; | ||||
|  | ||||
| 		constexpr ox::Error endAlloc() noexcept; | ||||
|  | ||||
| 		constexpr ox::Error offsetPtrs(std::size_t offset) noexcept; | ||||
|  | ||||
| 		[[nodiscard]] | ||||
| @@ -220,11 +224,23 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const T **val, std: | ||||
| 	return {}; | ||||
| } | ||||
|  | ||||
| template<typename PlatSpec> | ||||
| constexpr ox::Error Preloader<PlatSpec>::startAlloc(std::size_t sz) noexcept { | ||||
| 	oxRequire(p, ox::allocate(&m_writer, sz)); | ||||
| 	return m_writer.seekp(p); | ||||
| } | ||||
|  | ||||
| template<typename PlatSpec> | ||||
| constexpr ox::Error Preloader<PlatSpec>::endAlloc() noexcept { | ||||
| 	return m_writer.seekp(0, ox::ios_base::end); | ||||
| } | ||||
|  | ||||
| template<typename PlatSpec> | ||||
| constexpr ox::Error Preloader<PlatSpec>::offsetPtrs(std::size_t offset) noexcept { | ||||
| 	for (const auto &p : m_ptrs) { | ||||
| 		oxReturnError(m_writer.seekp(p.loc)); | ||||
| 		oxReturnError(ox::serialize(&m_writer, PlatSpec::correctEndianness(p.value + offset))); | ||||
| 		const auto val = PlatSpec::template correctEndianness<typename PlatSpec::PtrType>(p.value + offset); | ||||
| 		oxReturnError(ox::serialize(&m_writer, val)); | ||||
| 	} | ||||
| 	oxReturnError(m_writer.seekp(0, ox::ios_base::end)); | ||||
| 	return {}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user