aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/zvision/module.mk1
-rw-r--r--engines/zvision/utility/single_value_container.cpp344
-rw-r--r--engines/zvision/utility/single_value_container.h183
3 files changed, 0 insertions, 528 deletions
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index f2455a5d9c..140074c326 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -47,7 +47,6 @@ MODULE_OBJS := \
text/text.o \
utility/clock.o \
utility/lzss_read_stream.o \
- utility/single_value_container.o \
utility/utility.o \
utility/win_keys.o \
video/video.o \
diff --git a/engines/zvision/utility/single_value_container.cpp b/engines/zvision/utility/single_value_container.cpp
deleted file mode 100644
index 774f4b72ee..0000000000
--- a/engines/zvision/utility/single_value_container.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/scummsys.h"
-#include "common/textconsole.h"
-#include "common/str.h"
-
-#include "zvision/utility/single_value_container.h"
-
-namespace ZVision {
-
-SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { }
-
-SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) {
- _value.boolVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) {
- _value.byteVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) {
- _value.int16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) {
- _value.uint16Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) {
- _value.int32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) {
- _value.uint32Val = value;
-}
-
-SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) {
- _value.floatVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) {
- _value.doubleVal = value;
-}
-
-SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) {
- _value.stringVal = new char[value.size() + 1];
- memcpy(_value.stringVal, value.c_str(), value.size() + 1);
-}
-
-SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) {
- _objectType = other._objectType;
-
- switch (_objectType) {
- case BOOL:
- _value.boolVal = other._value.boolVal;
- break;
- case BYTE:
- _value.byteVal = other._value.byteVal;
- break;
- case INT16:
- _value.int16Val = other._value.int16Val;
- break;
- case UINT16:
- _value.uint16Val = other._value.uint16Val;
- break;
- case INT32:
- _value.int32Val = other._value.int32Val;
- break;
- case UINT32:
- _value.uint32Val = other._value.uint32Val;
- break;
- case FLOAT:
- _value.floatVal = other._value.floatVal;
- break;
- case DOUBLE:
- _value.doubleVal = other._value.doubleVal;
- break;
- case STRING:
- uint32 length = strlen(other._value.stringVal);
- _value.stringVal = new char[length + 1];
- memcpy(_value.stringVal, other._value.stringVal, length + 1);
- break;
- }
-}
-
-SingleValueContainer::~SingleValueContainer() {
- deleteCharPointer();
-}
-
-void SingleValueContainer::deleteCharPointer() {
- if (_objectType == STRING)
- delete[] _value.stringVal;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) {
- if (_objectType == BOOL) {
- _value.boolVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = BOOL;
- _value.boolVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) {
- if (_objectType == BYTE) {
- _value.byteVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = BYTE;
- _value.byteVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) {
- if (_objectType == INT16) {
- _value.int16Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = INT16;
- _value.int16Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) {
- if (_objectType == UINT16) {
- _value.uint16Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = UINT16;
- _value.uint16Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) {
- if (_objectType == INT32) {
- _value.int32Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = INT32;
- _value.int32Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) {
- if (_objectType == UINT32) {
- _value.uint32Val = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = UINT32;
- _value.uint32Val = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const float &rhs) {
- if (_objectType == FLOAT) {
- _value.floatVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = FLOAT;
- _value.floatVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const double &rhs) {
- if (_objectType == DOUBLE) {
- _value.doubleVal = rhs;
- return *this;
- }
-
- deleteCharPointer();
- _objectType = DOUBLE;
- _value.doubleVal = rhs;
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) {
- if (_objectType != STRING) {
- _objectType = STRING;
- _value.stringVal = new char[rhs.size() + 1];
- memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
-
- return *this;
- }
-
- uint32 length = strlen(_value.stringVal);
- if (length <= rhs.size() + 1) {
- memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
- } else {
- delete[] _value.stringVal;
- _value.stringVal = new char[rhs.size() + 1];
- memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1);
- }
-
- return *this;
-}
-
-SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) {
- switch (_objectType) {
- case BOOL:
- return operator=(rhs._value.boolVal);
- case BYTE:
- return operator=(rhs._value.byteVal);
- case INT16:
- return operator=(rhs._value.int16Val);
- case UINT16:
- return operator=(rhs._value.uint16Val);
- case INT32:
- return operator=(rhs._value.int32Val);
- case UINT32:
- return operator=(rhs._value.uint32Val);
- case FLOAT:
- return operator=(rhs._value.floatVal);
- case DOUBLE:
- return operator=(rhs._value.doubleVal);
- case STRING:
- uint32 length = strlen(rhs._value.stringVal);
-
- _value.stringVal = new char[length + 1];
- memcpy(_value.stringVal, rhs._value.stringVal, length + 1);
-
- return *this;
- }
-
- return *this;
-}
-
-bool SingleValueContainer::getBoolValue(bool *returnValue) const {
- if (_objectType != BOOL) {
- warning("'Object' is not storing a bool.");
- return false;
- }
-
- *returnValue = _value.boolVal;
- return true;
-}
-
-bool SingleValueContainer::getByteValue(byte *returnValue) const {
- if (_objectType != BYTE)
- warning("'Object' is not storing a byte.");
-
- *returnValue = _value.byteVal;
- return true;
-}
-
-bool SingleValueContainer::getInt16Value(int16 *returnValue) const {
- if (_objectType != INT16)
- warning("'Object' is not storing an int16.");
-
- *returnValue = _value.int16Val;
- return true;
-}
-
-bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const {
- if (_objectType != UINT16)
- warning("'Object' is not storing a uint16.");
-
- *returnValue = _value.uint16Val;
- return true;
-}
-
-bool SingleValueContainer::getInt32Value(int32 *returnValue) const {
- if (_objectType != INT32)
- warning("'Object' is not storing an int32.");
-
- *returnValue = _value.int32Val;
- return true;
-}
-
-bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const {
- if (_objectType != UINT32)
- warning("'Object' is not storing a uint32.");
-
- *returnValue = _value.uint32Val;
- return true;
-}
-
-bool SingleValueContainer::getFloatValue(float *returnValue) const {
- if (_objectType != FLOAT)
- warning("'Object' is not storing a float.");
-
- *returnValue = _value.floatVal;
- return true;
-}
-
-bool SingleValueContainer::getDoubleValue(double *returnValue) const {
- if (_objectType != DOUBLE)
- warning("'Object' is not storing a double.");
-
- *returnValue = _value.doubleVal;
- return true;
-}
-
-bool SingleValueContainer::getStringValue(Common::String *returnValue) const {
- if (_objectType != STRING)
- warning("'Object' is not storing a Common::String.");
-
- *returnValue = _value.stringVal;
- return true;
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/utility/single_value_container.h b/engines/zvision/utility/single_value_container.h
deleted file mode 100644
index ac6e99039a..0000000000
--- a/engines/zvision/utility/single_value_container.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ZVISION_SINGLE_VALUE_CONTAINER_H
-#define ZVISION_SINGLE_VALUE_CONTAINER_H
-
-namespace Common {
-class String;
-}
-
-namespace ZVision {
-
-/**
- * A generic single value storage class. It is useful for storing different
- * value types in a single List, Hashmap, etc.
- */
-class SingleValueContainer {
-public:
- enum ValueType {
- BOOL,
- BYTE,
- INT16,
- UINT16,
- INT32,
- UINT32,
- FLOAT,
- DOUBLE,
- STRING
- };
-
- // Constructors
- explicit SingleValueContainer(ValueType type);
- explicit SingleValueContainer(bool value);
- explicit SingleValueContainer(byte value);
- explicit SingleValueContainer(int16 value);
- explicit SingleValueContainer(uint16 value);
- explicit SingleValueContainer(int32 value);
- explicit SingleValueContainer(uint32 value);
- explicit SingleValueContainer(float value);
- explicit SingleValueContainer(double value);
- explicit SingleValueContainer(Common::String value);
-
- // Copy constructor
- explicit SingleValueContainer(const SingleValueContainer &other);
-
- // Destructor
- ~SingleValueContainer();
-
-private:
- ValueType _objectType;
-
- union {
- bool boolVal;
- byte byteVal;
- int16 int16Val;
- uint16 uint16Val;
- int32 int32Val;
- uint32 uint32Val;
- float floatVal;
- double doubleVal;
- char *stringVal;
- } _value;
-
-public:
- SingleValueContainer &operator=(const bool &rhs);
- SingleValueContainer &operator=(const byte &rhs);
- SingleValueContainer &operator=(const int16 &rhs);
- SingleValueContainer &operator=(const uint16 &rhs);
- SingleValueContainer &operator=(const int32 &rhs);
- SingleValueContainer &operator=(const uint32 &rhs);
- SingleValueContainer &operator=(const float &rhs);
- SingleValueContainer &operator=(const double &rhs);
- SingleValueContainer &operator=(const Common::String &rhs);
-
- SingleValueContainer &operator=(const SingleValueContainer &rhs);
-
- /**
- * Retrieve a bool from the container. If the container is not storing a
- * bool, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getBoolValue(bool *returnValue) const;
- /**
- * Retrieve a byte from the container. If the container is not storing a
- * byte, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getByteValue(byte *returnValue) const;
- /**
- * Retrieve an int16 from the container. If the container is not storing an
- * int16, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getInt16Value(int16 *returnValue) const;
- /**
- * Retrieve a uint16 from the container. If the container is not storing a
- * uint16, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getUInt16Value(uint16 *returnValue) const;
- /**
- * Retrieve an int32 from the container. If the container is not storing an
- * int32, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getInt32Value(int32 *returnValue) const;
- /**
- * Retrieve a uint32 from the container. If the container is not storing a
- * uint32, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getUInt32Value(uint32 *returnValue) const;
- /**
- * Retrieve a float from the container. If the container is not storing a
- * float, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getFloatValue(float *returnValue) const;
- /**
- * Retrieve a double from the container. If the container is not storing a
- * double, this will return false and display a warning().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getDoubleValue(double *returnValue) const;
- /**
- * Retrieve a String from the container. If the container is not storing a
- * string, this will return false and display a warning().
- *
- * Caution: Strings are internally stored as char[]. getStringValue uses
- * Common::String::operator=(char *) to do the assigment, which uses both
- * strlen() AND memmove().
- *
- * @param returnValue Pointer to where you want the value stored
- * @return Value indicating whether the value assignment was successful
- */
- bool getStringValue(Common::String *returnValue) const;
-
-private:
- /**
- * Helper method for destruction and assignment. It checks to see
- * if the char pointer is being used, and if so calls delete on it
- */
- void deleteCharPointer();
-};
-
-} // End of namespace ZVision
-
-#endif