/***************************************************************************
*   Copyright (C) 2004 by Denis A. Birukov aka Messenger of death         *
*   riper@fromru.com                                                      *
*                                                                         *
*   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.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/
#include <me_c_storageentry.h>
#include <me_c_storage.h>

namespace ME_n_Storage
{
	ME_c_Storage_Entry::ME_c_Storage_Entry( Sint16 type, void* data ) : _type_( type )
	{
		switch ( _type_ )
		{
			case ME_STORAGE_UINT32 : _ui32_value_ = *( Uint32* ) data;
			break;
			case ME_STORAGE_SINT32 : _si32_value_ = *( Sint32* ) data;
			break;
			case ME_STORAGE_UINT16 : _ui16_value_ = *( Uint16* ) data;
			break;
			case ME_STORAGE_SINT16 : _si16_value_ = *( Sint16* ) data;
			break;
			case ME_STORAGE_UINT8 : _ui8_value_ = *( Uint8* ) data;
			break;
			case ME_STORAGE_SINT8 : _si8_value_ = *( Sint8* ) data;
			break;
			case ME_STORAGE_STRING : _s_value_ = *( std::string* ) data;
			break;
			case ME_STORAGE_DOUBLE : _d_value_ = *( double* ) data;
			break;
		}
	}
	void* ME_c_Storage_Entry::_get_value( void )
	{
		switch ( _type_ )
		{
			case ME_STORAGE_UINT32 : return ( void* ) &_ui32_value_;
			case ME_STORAGE_SINT32 : return ( void* ) &_si32_value_;
			case ME_STORAGE_UINT16 : return ( void* ) &_ui16_value_;
			case ME_STORAGE_SINT16 : return ( void* ) &_si16_value_;
			case ME_STORAGE_UINT8 : return ( void* ) &_ui8_value_;
			case ME_STORAGE_SINT8 : return ( void* ) &_si8_value_;
			case ME_STORAGE_STRING : return ( void* ) &_s_value_;
			case ME_STORAGE_DOUBLE : return ( void* ) &_d_value_;
		}
		return 0;
	}
	Sint16 ME_c_Storage_Entry::_get_type( void )
	{
		return _type_;
	}

	ME_c_Storage_Entry::~ME_c_Storage_Entry( )
{}}

