UFO: Alien Invasion
keyvaluepair.h
Go to the documentation of this file.
1
6/*
7All original material Copyright (C) 2002-2022 UFO: Alien Invasion.
8
9Copyright (C) 1997-2001 Id Software, Inc.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, 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
39private:
40 const char* _keyStr;
41 const char* _valStr;
42public:
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)
69 }
70};
A pair of strings representing a key and a value The value string can be trimmed and rendered in the ...
Definition: keyvaluepair.h:38
void asVec3(vec3_t vec) const
Definition: keyvaluepair.h:66
KeyValuePair(const char *keyStr, const char *valStr)
Definition: keyvaluepair.h:43
float asFloat() const
Definition: keyvaluepair.h:54
void set(const char *keyStr, const char *valStr)
Definition: keyvaluepair.h:47
int asInt() const
Definition: keyvaluepair.h:57
bool asBool() const
Definition: keyvaluepair.h:60
const char * _keyStr
Definition: keyvaluepair.h:40
bool isKey(const char *name) const
Definition: keyvaluepair.h:51
const char * _valStr
Definition: keyvaluepair.h:41
const char * asString() const
Definition: keyvaluepair.h:63
const vec3_t vec3_origin
Definition: mathlib.cpp:35
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
vec_t vec3_t[3]
Definition: ufotypes.h:39
#define VectorCopy(src, dest)
Definition: vector.h:51