aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/gats-qt/dictionary.h
blob: 6b13868af16bdd5a76be2521544676cd12efcc7d (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright (C) 2007-2013 Xagasoft, All rights reserved.
 *
 * This file is part of the libgats library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#ifndef GATS_DICTIONARY_H
#define GATS_DICTIONARY_H

#include "gats-qt/object.h"
#include "gats-qt/string.h"
#include <QHash>
#include <stdint.h>

namespace Gats
{
    class List;

    class Dictionary : public Gats::Object,
        public QHash<QByteArray, Gats::Object *>
    {
        Q_OBJECT;
    public:
        Dictionary();
        virtual ~Dictionary();

        virtual Object *clone() const;

        virtual Type getType() const { return typeDictionary; }
        virtual void write( QIODevice &rOut ) const;
        virtual void read( QIODevice &rIn, char cType );
        
        virtual QString toString( int iIndent=0 ) const;

        void insert( const QByteArray &sKey, const char *s );
        void insert( const QByteArray &sKey, const QByteArray &s );
        void insert( const QByteArray &sKey, char i );
        void insert( const QByteArray &sKey, unsigned char i );
        void insert( const QByteArray &sKey, signed char i );
        void insert( const QByteArray &sKey, unsigned short i );
        void insert( const QByteArray &sKey, signed short i );
        void insert( const QByteArray &sKey, unsigned int i );
        void insert( const QByteArray &sKey, signed int i );
        void insert( const QByteArray &sKey, unsigned long i );
        void insert( const QByteArray &sKey, signed long i );
        void insert( const QByteArray &sKey, unsigned long long i );
        void insert( const QByteArray &sKey, signed long long i );
        //void insert( const QByteArray &sKey, bool b );
        void insert( const QByteArray &sKey, float d );
        void insert( const QByteArray &sKey, double d );
        void insert( const QByteArray &sKey, Gats::Object *pObj );
        //using QHash<QByteArray, Gats::Object *>::insert;
        void insertBool( const QByteArray &sKey, bool b );
        void insertInt( const QByteArray &sKey, int64_t i );
        void insertFloat( const QByteArray &sKey, double d );
        void insertStr( const QByteArray &sKey, const QByteArray &s );
        void insertList( const QByteArray &sKey, Gats::List *pL );
        void insertDict( const QByteArray &sKey, Gats::Dictionary *pD );
        Gats::List *insertList( const QByteArray &sKey );
        Gats::Dictionary *insertDict( const QByteArray &sKey );

        bool valueBool( const QByteArray &sKey );
        int64_t valueInt( const QByteArray &sKey );
        double valueFloat( const QByteArray &sKey );
        QByteArray valueStr( const QByteArray &sKey );
        Gats::List *valueList( const QByteArray &sKey );
        Gats::Dictionary *valueDict( const QByteArray &sKey );
        
        bool valueBool( const QByteArray &sKey ) const;
        int64_t valueInt( const QByteArray &sKey ) const;
        double valueFloat( const QByteArray &sKey ) const;
        QByteArray valueStr( const QByteArray &sKey ) const;
        Gats::List *valueList( const QByteArray &sKey ) const;
        Gats::Dictionary *valueDict( const QByteArray &sKey ) const;
    };
};

//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d );

#endif