/******************************************************************************* * libretroshare/src/serialiser: rstlvgenericparam.cc * * * * libretroshare: retroshare core library * * * * Copyright 2014 by Robert Fernie * * * * This program 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 3 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 Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public License * * along with this program. If not, see . * * * *******************************************************************************/ #include "serialiser/rstlvgenericparam.h" #include "serialiser/rstlvbase.h" #include // #define TLV_DEBUG 1 /* generic print */ template std::ostream & RsTlvParamRef::print(std::ostream &out, uint16_t indent) const { printIndent(out, indent); out << "Type: " << mParamType << " Param: " << mParam; return out; } /***** uint16_t ****/ template<> uint32_t RsTlvParamRef::TlvSize() const { return GetTlvUInt16Size(); } template<> void RsTlvParamRef::TlvClear() { mParam = 0; } template<> bool RsTlvParamRef::SetTlv(void *data, uint32_t size, uint32_t *offset) const { return SetTlvUInt16(data, size, offset, mParamType, mParam); } template<> bool RsTlvParamRef::GetTlv(void *data, uint32_t size, uint32_t *offset) { uint16_t param; bool retval = GetTlvUInt16(data, size, offset, mParamType, ¶m); mParam = param; return retval; } template<> std::ostream & RsTlvParamRef::print(std::ostream &out, uint16_t indent) const { printIndent(out, indent); out << "Type: " << mParamType << "Param: " << mParam; return out; } /***** const uint16_t ****/ template<> uint32_t RsTlvParamRef::TlvSize() const { return GetTlvUInt16Size(); } template<> void RsTlvParamRef::TlvClear() { //mParam = 0; } template<> bool RsTlvParamRef::SetTlv(void *data, uint32_t size, uint32_t *offset) const { return SetTlvUInt16(data, size, offset, mParamType, mParam); } template<> bool RsTlvParamRef::GetTlv(void */*data*/, uint32_t /*size*/, uint32_t */*offset*/) { return false; //GetTlvUInt16(data, size, offset, mParamType, &mParam); } template<> std::ostream & RsTlvParamRef::print(std::ostream &out, uint16_t indent) const { printIndent(out, indent); out << "Type: " << mParamType << "Param: " << mParam; return out; } /***** uint32_t ****/ template<> uint32_t RsTlvParamRef::TlvSize() const { return GetTlvUInt32Size(); } template<> void RsTlvParamRef::TlvClear() { mParam = 0; } template<> bool RsTlvParamRef::SetTlv(void *data, uint32_t size, uint32_t *offset) const { return SetTlvUInt32(data, size, offset, mParamType, mParam); } template<> bool RsTlvParamRef::GetTlv(void *data, uint32_t size, uint32_t *offset) { return GetTlvUInt32(data, size, offset, mParamType, &mParam); } template<> std::ostream & RsTlvParamRef::print(std::ostream &out, uint16_t indent) const { printIndent(out, indent); out << "Type: " << mParamType << "Param: " << mParam; return out; } /***** const uint32_t ****/ template<> uint32_t RsTlvParamRef::TlvSize() const { return GetTlvUInt32Size(); } template<> void RsTlvParamRef::TlvClear() { //mParam = 0; } template<> bool RsTlvParamRef::SetTlv(void *data, uint32_t size, uint32_t *offset) const { return SetTlvUInt32(data, size, offset, mParamType, mParam); } template<> bool RsTlvParamRef::GetTlv(void */*data*/, uint32_t /*size*/, uint32_t */*offset*/) { return false; //GetTlvUInt32(data, size, offset, mParamType, &mParam); } template<> std::ostream & RsTlvParamRef::print(std::ostream &out, uint16_t indent) const { printIndent(out, indent); out << "Type: " << mParamType << "Param: " << mParam; return out; } /***** std::string ****/ template<> uint32_t RsTlvParamRef::TlvSize() const { return GetTlvStringSize(mParam); } template<> void RsTlvParamRef::TlvClear() { mParam.clear(); } template<> bool RsTlvParamRef::SetTlv(void *data, uint32_t size, uint32_t *offset) const { return SetTlvString(data, size, offset, mParamType, mParam); } template<> bool RsTlvParamRef::GetTlv(void *data, uint32_t size, uint32_t *offset) { return GetTlvString(data, size, offset, mParamType, mParam); } template<> std::ostream & RsTlvParamRef::print(std::ostream &out, uint16_t indent) const { printIndent(out, indent); out << "Type: " << mParamType << "Param: " << mParam; return out; } // declare likely combinations. //template class RsTlvParamRef; //template class RsTlvParamRef; //template class RsTlvParamRef; //template class RsTlvParamRef; //template class RsTlvParamRef; //template class RsTlvParamRef;