ScummVM API documentation
script_value.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * This file is based on WME Lite.
24 * http://dead-code.org/redir.php?target=wmelite
25 * Copyright (c) 2011 Jan Nedoma
26 */
27
28#ifndef WINTERMUTE_SCVALUE_H
29#define WINTERMUTE_SCVALUE_H
30
31
32#include "engines/wintermute/base/base.h"
33#include "engines/wintermute/persistent.h"
34#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView
35#include "common/str.h"
36
37namespace Wintermute {
38
39class ScScript;
40class BaseScriptable;
41
42class ScValue : public BaseClass {
43public:
44 static int compare(ScValue *val1, ScValue *val2, bool enableFloatCompareWA);
45 static int compareStrict(ScValue *val1, ScValue *val2, bool enableFloatCompareWA);
46 TValType getTypeTolerant();
47 void cleanup(bool ignoreNatives = false);
48 DECLARE_PERSISTENT(ScValue, BaseClass)
49
50 bool _isConstVar;
51 bool saveAsText(BaseDynamicBuffer *buffer, int indent) override;
52 void setValue(ScValue *val);
53 bool _persistent;
54 bool propExists(const char *name);
55 void copy(ScValue *orig, bool copyWhole = false);
56 void setStringVal(const char *val);
57 TValType getType();
58 bool getBool(bool defaultVal = false);
59 int getInt(int defaultVal = 0);
60 double getFloat(double defaultVal = 0.0f);
61 const char *getString();
62 void *getMemBuffer();
63 BaseScriptable *getNative();
64 bool deleteProp(const char *name);
65 void deleteProps();
66 void cleanProps(bool includingNatives);
67 void setBool(bool val);
68 void setInt(int val);
69 void setFloat(double val);
70 void setString(const char *val);
71 void setString(const Common::String &val);
72 void setNULL();
73 void setNative(BaseScriptable *val, bool persistent = false);
74 void setObject();
75 void setReference(ScValue *val);
76 bool isNULL();
77 bool isNative();
78 bool isString();
79 bool isBool();
80 bool isFloat();
81 bool isInt();
82 bool isObject();
83 bool setProp(const char *name, ScValue *val, bool copyWhole = false, bool setAsConst = false);
84 ScValue *getProp(const char *name);
85 BaseScriptable *_valNative;
86 ScValue *_valRef;
87 bool _valBool;
88 int32 _valInt;
89 double _valFloat;
90 char *_valString;
91 TValType _type;
92 ScValue(BaseGame *inGame);
93 ScValue(BaseGame *inGame, bool val);
94 ScValue(BaseGame *inGame, int32 val);
95 ScValue(BaseGame *inGame, double val);
96 ScValue(BaseGame *inGame, const char *val);
97 ~ScValue() override;
99 Common::HashMap<Common::String, ScValue *>::iterator _valIter;
100
101 bool setProperty(const char *propName, int32 value);
102 bool setProperty(const char *propName, const char *value);
103 bool setProperty(const char *propName, double value);
104 bool setProperty(const char *propName, bool value);
105 bool setProperty(const char *propName);
106};
107
108} // End of namespace Wintermute
109
110#endif
Definition: hashmap.h:85
Definition: str.h:59
Definition: base.h:43
Definition: base_dynamic_buffer.h:35
Definition: base_game.h:79
Definition: base_scriptable.h:41
Definition: script_value.h:42