Show EntDict.h syntax highlighted
/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG *
*Copyright (C) 2006, Tony Sparks *
* *
*This library is free software; you can redistribute it and/or *
*modify it under the terms of the GNU Lesser General Public *
*License as published by the Free Software Foundation; either *
*version 2.1 of the License, or (at your option) any later version. *
* *
*This library 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 *
*Lesser General Public License for more details. *
* *
*You should have received a copy of the GNU Lesser General Public *
*License along with this library; if not, write to the Free Software *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
**************************************************************************************
*/
#pragma once
#include "vector.h"
#include <string>
#include <map>
/**
=================================================
Dictionary Entry
=================================================
*/
class DictEntry
{
public:
DictEntry();
/** Clear values */
void Clear();
/** Destroy */
~DictEntry() { Clear(); };
public:
bool b_value;
int i_value;
float f_value;
std::string s_value;
Vector2f v_value;
std::string m_name;
};
/**
=================================================
Entity Dictionary -
Holds properties of an entity
=================================================
*/
class EntDict
{
public:
EntDict(void);
/** Put a property into the dictionary */
void Put( const std::string &prop, const std::string &value );
void Put( const std::string &prop, int value );
void Put( const std::string &prop, float value );
void Put( const std::string &prop, bool value );
void Put( const std::string &prop, float v1, float v2 );
/** Get a property */
int GetInt( const std::string &prop );
float GetFloat( const std::string &prop );
Vector2f GetVector2f( const std::string &prop );
std::string GetStr( const std::string &prop );
/** Set a property */
void SetStr( const std::string &prop, const std::string &value );
void SetInt( const std::string &prop, int value );
void SetFloat( const std::string &prop, float value );
void SetBool( const std::string &prop, bool value );
void SetVector( const std::string &prop, Vector2f value );
/** Clear all entries */
void Clear();
/** Test for property */
bool Has( const std::string &prop );
private:
std::map< const std::string, DictEntry > m_vocab;
public:
virtual ~EntDict(void);
};
See more files for this project here