mxoemu/Reality/Source/Database/Field.h

53 lines
2.1 KiB
C++

// ***************************************************************************
//
// Reality - The Matrix Online Server Emulator
// Copyright (C) 2006-2010 Rajko Stojadinovic
// http://mxoemu.info
//
// ---------------------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ---------------------------------------------------------------------------
//
// ***************************************************************************
#ifndef MXOSIM_FIELD_H
#define MXOSIM_FIELD_H
#include <cstdlib>
class Field
{
public:
inline void SetValue(char* value) { mValue = value; }
inline const char *GetString() { return mValue; }
inline float GetFloat() { return mValue ? static_cast<float>(atof(mValue)) : 0; }
inline double GetDouble() { return atof(mValue); }
inline bool GetBool() { return mValue ? atoi(mValue) > 0 : false; }
inline uint8 GetUInt8() { return mValue ? static_cast<uint8>(atol(mValue)) : 0; }
inline int8 GetInt8() { return mValue ? static_cast<int8>(atol(mValue)) : 0; }
inline uint16 GetUInt16() { return mValue ? static_cast<uint16>(atol(mValue)) : 0; }
inline uint32 GetUInt32() { return mValue ? static_cast<uint32>(atol(mValue)) : 0; }
inline int32 GetInt32() { return mValue ? static_cast<int32>(atol(mValue)) : 0; }
inline int64 GetInt64() { return mValue ? lexical_cast<int64>(mValue) : 0; }
inline uint64 GetUInt64() { return mValue ? lexical_cast<uint64>(mValue) : 0; }
private:
char *mValue;
};
#endif