Sha256: 3ef3b39da6fd38c2c9df0c1400274c1412f11ec451525271365ca4950550d9b7

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

/* Copyright (c) 2024 Julian Benda
 *
 * This file is part of inkCPP which is released under MIT license.
 * See file LICENSE.txt or go to
 * https://github.com/JBenda/inkcpp for full license details.
 */
#pragma once

#include "system.h"

namespace ink::internal {

		struct header {
			static header parse_header(const char* data);

			template<typename T>
			static T swap_bytes(const T& value) {
				char data[sizeof(T)];
				for (int i = 0; i < sizeof(T); ++i) {
					data[i] = reinterpret_cast<const char*>(&value)[sizeof(T)-1-i];
				}
				return *reinterpret_cast<const T*>(data);
			}
			list_flag read_list_flag(const char*& ptr) const {
				list_flag result = *reinterpret_cast<const list_flag*>(ptr);
				ptr += sizeof(list_flag);
				if (endien == ink::internal::header::endian_types::differ) {
					result.flag = swap_bytes(result.flag);
					result.list_id = swap_bytes(result.list_id);
				}
				return result;
			}

			enum class  endian_types: uint16_t {
				none = 0,
				same = 0x0001,
				differ = 0x0100
			} endien = endian_types::none;
			uint32_t ink_version_number = 0;
			uint32_t ink_bin_version_number = 0;
			static constexpr size_t Size = ///< actual data size of Header,
										   ///   because padding of struct may
										   ///   differ between platforms
				sizeof(uint16_t) + 2 * sizeof(uint32_t);
		};
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
inkcpp_rb-0.1.3 ext/inkcpp_rb/inkcpp/shared/private/header.h
inkcpp_rb-0.1.2 ext/inkcpp_rb/inkcpp/shared/private/header.h
inkcpp_rb-0.1.1 ext/inkcpp_rb/inkcpp/shared/private/header.h
inkcpp_rb-0.1.0 ext/inkcpp_rb/inkcpp/shared/private/header.h