aboutsummaryrefslogtreecommitdiff
path: root/app/source/Cplt/Utils/IO/UuidIntegration.hpp
blob: 20c1e7e54a02e43392591235d7ab36f40303bf0a (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
25
26
27
#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