engine: reject mbf21 and shit24 wads. there is no way to know if it is safe to ignore...
[k8vavoom.git] / source / language.h
blobd587d30a6cb16310d8b1e221c6337d2267376aa9
1 //**************************************************************************
2 //**
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
9 //**
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
12 //**
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
16 //**
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
21 //**
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //**
25 //**************************************************************************
26 #ifndef VAVOOM_LANGUAGE_HEADER
27 #define VAVOOM_LANGUAGE_HEADER
30 class VLanguage {
31 private:
32 struct VLangEntry {
33 vint32 PassNum;
34 VStr Value;
37 TMap<VName, VLangEntry> table;
39 void FreeNonDehackedStrings ();
40 void ParseLanguageScript (vint32 Lump, const char *InCode, bool ExactMatch, vint32 PassNum);
41 VStr HandleEscapes (VStr Src);
43 public:
44 VLanguage () noexcept;
45 ~VLanguage () noexcept;
47 void LoadStrings (const char *LangId);
49 VStr Find (VName Key, bool *found=nullptr) const;
50 VStr Find (const char *s, bool *found=nullptr) const;
52 VStr operator [] (VName Key) const;
53 VStr operator [] (const char *s) const;
54 VStr operator [] (const VStr &s) const;
56 // WITH '$'!
57 VStr Translate (const VStr &s) const;
59 bool HasTranslation (VName s) const;
60 bool HasTranslation (const char *s) const;
62 VName GetStringId (VStr Str);
63 VName GetStringIdCI (VStr Str);
64 void ReplaceString (VName, VStr);
68 extern VLanguage GLanguage;
71 #endif