QueryRouting.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2005-2007 by Peter Dimov.
00004 
00005 This file is part of Calitko (http://www.calitko.org).
00006 
00007 Calitko is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 Calitko is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Calitko; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #include "Qt.h"
00024 #include "QueryRouting.h"
00025 
00026 using namespace Gnutella::Packets;
00027 
00029 
00031 QDataStream & operator>> (QDataStream &in, QueryRouting::Variant &variant)
00032 {
00033     uchar tmp;
00034     in >> tmp;
00035     variant = static_cast <QueryRouting::Variant> (tmp);
00036     return in;
00037 }
00038 
00040 
00042 QDataStream & operator<< (QDataStream &out, const QueryRouting::Variant &variant)
00043 {
00044     return out << static_cast <uchar> (variant);
00045 }
00046 
00052 QueryRouting::QueryRouting (const QByteArray &rawHeader, const QByteArray &rawPayload)
00053     : Packet (rawHeader, rawPayload)
00054 {
00055 }
00056 
00057 QueryRouting::QueryRouting (Variant variant)
00058     : Packet (QueryRoutingDescriptor)
00059 {
00060     p.variant = variant;
00061 }
00062 
00063 QueryRouting::~QueryRouting()
00064 {
00065 }
00066 
00067 /* Pure virtual function. Giving it a body is not required, although permitted!
00068     We do no general processing in the base, so we don't need a body.
00069 bool QueryRouting::prepareReadPayload (const QByteArray &rawPayload)
00070 {
00071     // <pd_todo> check the structure of the fields.
00072     return true;
00073 }
00074 */
00075 
00076 void QueryRouting::readPayload (QDataStream &stream)
00077 {
00078     stream >> p.variant;
00079 }
00080 
00081 void QueryRouting::writePayload (QDataStream &stream) const
00082 {
00083     stream << p.variant;
00084 }