Sha256: 0127f26ca9b0ac31e6b62ffc75f264c8e1916c793c2fbd0f07719e9b0716afbb

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 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 "avl_array.h"
#include "system.h"
#include "snapshot_impl.h"

namespace ink::runtime::internal
{
	// hash tree sorted by string pointers
	class string_table final : public snapshot_interface
	{
	public:
		virtual ~string_table();

		// Create a dynmaic string of a particular length
		char* create(size_t length);
		char* duplicate(const char* str);

		// zeroes all usage values
		void clear_usage();

		// mark a string as used
		void mark_used(const char* string);


		// snapshot interface implementation
		size_t snap(unsigned char* data, const snapper&) const;
		const unsigned char* snap_load(const unsigned char* data, const loader&);

		// get position of string when iterate through data
		// used to enable storing a string table references
		size_t get_id(const char* string) const;

		// deletes all unused strings
		void gc();

	private:
		avl_array<const char*, bool, ink::size_t, 100> _table;
	  static constexpr const char*                   EMPTY_STRING = "\x03";
  };
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
inkcpp_rb-0.1.3 ext/inkcpp_rb/inkcpp/inkcpp/string_table.h
inkcpp_rb-0.1.2 ext/inkcpp_rb/inkcpp/inkcpp/string_table.h
inkcpp_rb-0.1.1 ext/inkcpp_rb/inkcpp/inkcpp/string_table.h
inkcpp_rb-0.1.0 ext/inkcpp_rb/inkcpp/inkcpp/string_table.h