aboutsummaryrefslogtreecommitdiff
path: root/app/source/Cplt/Utils/IO/UuidIntegration.hpp
blob: 49afd1906eb33c42bdaf9c4a598f9eb6de56aaa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include <Cplt/Utils/IO/DataStream.hpp>
#include <Cplt/Utils/UUID.hpp>

#include <cstddef>
#include <cstdint>
#include <iterator>

namespace DataStreamAdapters {
struct Uuid {
	static void ReadFromDataStream(InputDataStream& stream, uuids::uuid& uuid) {
		uint8_t buffer[16];
		stream.ReadBytes(16, buffer);

		uuid = uuids::uuid(gsl::span<uint8_t, 16>{ buffer });
	}

	static void WriteToDataStream(OutputDataStream& stream, const uuids::uuid& uuid) {
		auto gslSpan = uuid.as_bytes();
		stream.WriteBytes(gslSpan.size(), gslSpan.data());
	}
};
} // namespace DataStreamAdapters