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 
37 namespace Wintermute {
38 
39 class ScScript;
40 class BaseScriptable;
41 
42 class ScValue : public BaseClass {
43 public:
44  static int compare(ScValue *val1, ScValue *val2);
45  static int compareStrict(ScValue *val1, ScValue *val2);
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 private:
88  bool _valBool;
89  int32 _valInt;
90  double _valFloat;
91  char *_valString;
92 public:
93  TValType _type;
94  ScValue(BaseGame *inGame);
95  ScValue(BaseGame *inGame, bool Val);
96  ScValue(BaseGame *inGame, int32 Val);
97  ScValue(BaseGame *inGame, double Val);
98  ScValue(BaseGame *inGame, const char *Val);
99  ~ScValue() override;
101  Common::HashMap<Common::String, ScValue *>::iterator _valIter;
102 
103  bool setProperty(const char *propName, int32 value);
104  bool setProperty(const char *propName, const char *value);
105  bool setProperty(const char *propName, double value);
106  bool setProperty(const char *propName, bool value);
107  bool setProperty(const char *propName);
108 };
109 
110 } // End of namespace Wintermute
111 
112 #endif
Definition: base_game.h:76
Definition: script_value.h:42
Definition: str.h:59
Definition: base_dynamic_buffer.h:35
Definition: base_scriptable.h:41
Definition: hashmap.h:85
Definition: base.h:43
Definition: achievements_tables.h:27