xoreos  0.0.5
txitypes.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/stringmap.h"
26 #include "src/common/ustring.h"
27 
29 
30 static const char * const kTXICommands[] = {
31  "alphamean",
32  "arturoheight",
33  "arturowidth",
34  "baselineheight",
35  "blending",
36  "bumpmapscaling",
37  "bumpmaptexture",
38  "bumpyshinytexture",
39  "candownsample",
40  "caretindent",
41  "channelscale",
42  "channeltranslate",
43  "clamp",
44  "codepage",
45  "cols",
46  "compresstexture",
47  "controllerscript",
48  "cube",
49  "dbmapping",
50  "decal",
51  "defaultbpp",
52  "defaultheight",
53  "defaultwidth",
54  "distort",
55  "distortangle",
56  "distortionamplitude",
57  "downsamplefactor",
58  "downsamplemax",
59  "downsamplemin",
60  "envmaptexture",
61  "filerange",
62  "filter",
63  "fontheight",
64  "fontwidth",
65  "fps",
66  "isbumpmap",
67  "isdoublebyte",
68  "islightmap",
69  "lowerrightcoords",
70  "maxSizeHQ",
71  "maxSizeLQ",
72  "minSizeHQ",
73  "minSizeLQ",
74  "mipmap",
75  "numchars",
76  "numcharspersheet",
77  "numx",
78  "numy",
79  "ondemand",
80  "priority",
81  "proceduretype",
82  "rows",
83  "spacingB",
84  "spacingR",
85  "speed",
86  "temporary",
87  "texturewidth",
88  "unique",
89  "upperleftcoords",
90  "waterheight",
91  "waterwidth",
92  "xbox_downsample"
93 };
94 
96 
97 namespace Graphics {
98 
100  const char *s = str.c_str();
101 
102  size_t commandIndex = kTXICommandMap.find(s, &s);
103  TXICommand command = (TXICommand) MIN<size_t>(commandIndex, TXICommandMAX);
104 
105  args = Common::UString(s);
106 
107  return command;
108 }
109 
110 } // End of namespace Graphics
A class holding an UTF-8 string.
Definition: ustring.h:48
static const char *const kTXICommands[]
Definition: txitypes.cpp:30
A map to quickly match strings from a list.
Definition: stringmap.h:43
#define ARRAYSIZE(x)
Macro which determines the number of entries in a fixed size array.
Definition: util.h:131
TXICommand
All supported commands in a TXI.
Definition: txitypes.h:37
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
Texture information types.
static Common::StringListMap kTXICommandMap(kTXICommands, ARRAYSIZE(kTXICommands), true)
size_t find(const char *str, const char **match) const
Match a string against the map.
Definition: stringmap.cpp:37
Unicode string handling.
A map to quickly match strings from a list.
TXICommand parseTXICommand(const Common::UString &str, Common::UString &args)
Parse a TXI command from a string.
Definition: txitypes.cpp:99