2014-02-19 06:08:37 -05:00
|
|
|
#ifndef RS_TLV_GENERIC_MAP_H
|
|
|
|
#define RS_TLV_GENERIC_MAP_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* libretroshare/src/serialiser: rstlvgenericmap.h
|
|
|
|
*
|
|
|
|
* RetroShare Serialiser.
|
|
|
|
*
|
|
|
|
* Copyright 2014 by Robert Fernie
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-03-29 11:34:37 -04:00
|
|
|
#include "serialiser/rstlvitem.h"
|
|
|
|
#include "serialiser/rstlvgenericparam.h"
|
|
|
|
|
|
|
|
#if 0
|
2014-02-19 06:08:37 -05:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2014-03-29 11:34:37 -04:00
|
|
|
#endif
|
2014-02-19 06:08:37 -05:00
|
|
|
|
|
|
|
/*********************************** RsTlvGenericPairRef ***********************************/
|
|
|
|
|
|
|
|
template<class K, class V>
|
|
|
|
class RsTlvGenericPairRef: public RsTlvItem
|
|
|
|
{
|
|
|
|
public:
|
2014-03-04 05:06:16 -05:00
|
|
|
RsTlvGenericPairRef(uint16_t pair_type,
|
|
|
|
uint16_t key_type, uint16_t value_type, K &k, V &v)
|
|
|
|
:mPairType(pair_type), mKeyType(key_type),
|
|
|
|
mValueType(value_type), mKey(k), mValue(v) { return; }
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
virtual ~RsTlvGenericPairRef() { return; }
|
2014-03-29 11:34:37 -04:00
|
|
|
virtual uint32_t TlvSize() const;
|
2014-02-19 06:08:37 -05:00
|
|
|
virtual void TlvClear();
|
2014-03-29 11:34:37 -04:00
|
|
|
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset) const;
|
|
|
|
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset);
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent) const;
|
2014-02-19 06:08:37 -05:00
|
|
|
|
|
|
|
uint16_t mPairType;
|
2014-03-04 05:06:16 -05:00
|
|
|
uint16_t mKeyType;
|
|
|
|
uint16_t mValueType;
|
2014-02-19 06:08:37 -05:00
|
|
|
K &mKey;
|
|
|
|
V &mValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/************************************ RsTlvGenericMapRef ***********************************/
|
|
|
|
|
|
|
|
template<class K, class V>
|
|
|
|
class RsTlvGenericMapRef: public RsTlvItem
|
|
|
|
{
|
|
|
|
public:
|
2014-03-04 05:06:16 -05:00
|
|
|
RsTlvGenericMapRef(uint16_t map_type, uint16_t pair_type,
|
|
|
|
uint16_t key_type, uint16_t value_type, std::map<K, V> &refmap)
|
|
|
|
:mMapType(map_type), mPairType(pair_type),
|
|
|
|
mKeyType(key_type), mValueType(value_type), mRefMap(refmap) { return; }
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
virtual ~RsTlvGenericMapRef() { return; }
|
2014-03-29 11:34:37 -04:00
|
|
|
virtual uint32_t TlvSize() const;
|
2014-02-19 06:08:37 -05:00
|
|
|
virtual void TlvClear();
|
2014-03-29 11:34:37 -04:00
|
|
|
virtual bool SetTlv(void *data, uint32_t size, uint32_t *offset) const;
|
|
|
|
virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset);
|
|
|
|
virtual std::ostream &print(std::ostream &out, uint16_t indent) const;
|
2014-02-19 06:08:37 -05:00
|
|
|
|
|
|
|
uint16_t mMapType;
|
|
|
|
uint16_t mPairType;
|
2014-03-04 05:06:16 -05:00
|
|
|
uint16_t mKeyType;
|
|
|
|
uint16_t mValueType;
|
2014-02-19 06:08:37 -05:00
|
|
|
std::map<K, V> &mRefMap;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-03-21 23:53:44 -04:00
|
|
|
#include "rstlvgenericmap.inl"
|
|
|
|
|
2014-02-19 06:08:37 -05:00
|
|
|
#endif
|
|
|
|
|