aboutsummaryrefslogtreecommitdiff
path: root/src/dictionary.h
blob: 3bcaec6f88e43a1c4aba96a5797229f5142124e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef GATS_DICTIONARY_H
#define GATS_DICTIONARY_H

#include "gats/object.h"
#include "gats/string.h"
#include <bu/hash.h>

namespace Gats
{
	class List;

	class Dictionary : public Gats::Object,
		public Bu::Hash<Gats::String, Gats::Object *>
	{
	public:
		Dictionary();
		virtual ~Dictionary();

		virtual Type getType() const { return typeDictionary; }
		virtual void write( Bu::Stream &rOut ) const;
		virtual void read( Bu::Stream &rIn, char cType );
		
		void insert( const Bu::FString &sKey, int64_t i );
		void insert( const Bu::FString &sKey, bool b );
		void insert( const Bu::FString &sKey, double d );
		void insert( const Bu::FString &sKey, const Bu::FString &s );
		using Bu::Hash<Gats::String, Gats::Object *>::insert;

		bool getBool( const Bu::FString &sKey );
		int64_t getInt( const Bu::FString &sKey );
		double getFloat( const Bu::FString &sKey );
		Bu::FString getStr( const Bu::FString &sKey );
		Gats::List *getList( const Bu::FString &sKey );
		Gats::Dictionary *getDict( const Bu::FString &sKey );
	};
};

namespace Bu
{
template<>
uint32_t __calcHashCode<Gats::String>( const Gats::String &s );
};

#endif