UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
keyvaluepair.h
Go to the documentation of this file.
1
5
6
/*
7
All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9
Copyright (C) 1997-2001 Id Software, Inc.
10
11
This program is free software; you can redistribute it and/or
12
modify it under the terms of the GNU General Public License
13
as published by the Free Software Foundation; either version 2
14
of the License, or (at your option) any later version.
15
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20
See the 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, write to the Free Software
24
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26
*/
27
28
#pragma once
29
30
#include "
mathlib.h
"
31
#include <stdio.h>
32
38
class
KeyValuePair
{
39
private
:
40
const
char
*
_keyStr
;
41
const
char
*
_valStr
;
42
public
:
43
KeyValuePair
(
const
char
* keyStr,
const
char
* valStr) {
44
_keyStr
= keyStr;
45
_valStr
= valStr;
46
}
47
inline
void
set
(
const
char
* keyStr,
const
char
* valStr) {
48
_keyStr
= keyStr;
49
_valStr
= valStr;
50
}
51
inline
bool
isKey
(
const
char
*
name
)
const
{
52
return
!strcmp(
_keyStr
,
name
);
53
}
54
inline
float
asFloat
()
const
{
55
return
atof(
_valStr
);
56
}
57
inline
int
asInt
()
const
{
58
return
atoi(
_valStr
);
59
}
60
inline
bool
asBool
()
const
{
61
return
asInt
() != 0 ? true :
false
;
62
}
63
inline
const
char
*
asString
()
const
{
64
return
_valStr
;
65
}
66
void
asVec3
(
vec3_t
vec)
const
{
67
if
(sscanf(
_valStr
,
"%f %f %f"
, &vec[0], &vec[1], &vec[2]) != 3)
68
VectorCopy
(
vec3_origin
, vec);
69
}
70
};
KeyValuePair::asVec3
void asVec3(vec3_t vec) const
Definition
keyvaluepair.h:66
KeyValuePair::KeyValuePair
KeyValuePair(const char *keyStr, const char *valStr)
Definition
keyvaluepair.h:43
KeyValuePair::asFloat
float asFloat() const
Definition
keyvaluepair.h:54
KeyValuePair::set
void set(const char *keyStr, const char *valStr)
Definition
keyvaluepair.h:47
KeyValuePair::asInt
int asInt() const
Definition
keyvaluepair.h:57
KeyValuePair::asBool
bool asBool() const
Definition
keyvaluepair.h:60
KeyValuePair::_keyStr
const char * _keyStr
Definition
keyvaluepair.h:40
KeyValuePair::isKey
bool isKey(const char *name) const
Definition
keyvaluepair.h:51
KeyValuePair::_valStr
const char * _valStr
Definition
keyvaluepair.h:41
KeyValuePair::asString
const char * asString() const
Definition
keyvaluepair.h:63
vec3_origin
const vec3_t vec3_origin
Definition
mathlib.cpp:35
mathlib.h
name
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition
r_gl.h:110
vec3_t
vec_t vec3_t[3]
Definition
ufotypes.h:39
VectorCopy
#define VectorCopy(src, dest)
Definition
vector.h:51
src
shared
keyvaluepair.h
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0