1/*
2 * LegacyClonk
3 *
4 * Copyright (c) RedWolf Design
5 * Copyright (c) 2017-2019, The LegacyClonk Team and contributors
6 *
7 * Distributed under the terms of the ISC license; see accompanying file
8 * "COPYING" for details.
9 *
10 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11 * See accompanying file "TRADEMARK" for details.
12 *
13 * To redistribute this file separately, substitute the full license texts
14 * for the above references.
15 */
16
17/* string table: holds all strings used by script engine */
18
19#pragma once
20
21#include "StdBuf.h"
22
23class C4StringTable;
24class C4Group;
25
26class C4String
27{
28public:
29 C4String(StdStrBuf &&strString, C4StringTable *pTable);
30 C4String(const char *strString, C4StringTable *pTable);
31 virtual ~C4String();
32
33 // increment/decrement reference count on this string
34 void IncRef();
35 void DecRef();
36
37 StdStrBuf Data; // string data
38 int iRefCnt; // reference count on string (by C4Value)
39 bool Hold; // string stays hold when RefCnt reaches 0 (for in-script strings)
40
41 int iEnumID;
42
43 C4String *Next, *Prev; // double-linked list
44
45 C4StringTable *pTable; // owning table
46
47 void Reg(C4StringTable *pTable);
48 void UnReg();
49};
50
51class C4StringTable
52{
53public:
54 C4StringTable();
55 virtual ~C4StringTable();
56
57 void Clear();
58
59 C4String *RegString(const char *strString);
60 C4String *FindString(const char *strString);
61 C4String *FindString(C4String *pString);
62 C4String *FindString(int iEnumID);
63 C4String *FindSaveString(C4String *pString);
64
65 int EnumStrings();
66
67 bool Load(C4Group &ParentGroup);
68 bool Save(C4Group &ParentGroup);
69
70 C4String *First, *Last; // string list
71};
72