Torrent.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2006-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 "Torrent.h"
00025 #include "Imports.cpp"
00026 
00028 
00031 Torrent::FileInfo::FileInfo()
00032     : filePath(), fileLength (0), fileChecksum()
00033 {
00034 }
00035 
00037 
00040 Torrent::FileInfo::~FileInfo()
00041 {
00042 }
00043 
00045 
00050 Torrent::FileInfo::FileInfo (const Torrent::FileInfo &other)
00051     : filePath (other.filePath),
00052       fileLength (other.fileLength),
00053       fileChecksum (other.fileChecksum)
00054 {
00055 }
00056 
00058 
00062 Torrent::FileInfo & Torrent::FileInfo::operator= (
00063                                                 const Torrent::FileInfo &other)
00064 {
00065     Torrent::FileInfo temp (other);
00066     swap (temp);
00067     return *this;
00068 }
00069 
00071 
00074 bool Torrent::FileInfo::operator== (const FileInfo &other) const
00075 {
00076     return (filePath == other.filePath) &&
00077            (fileLength == other.fileLength) &&
00078            (fileChecksum == other.fileChecksum);
00079 }
00080 
00082 
00085 bool Torrent::FileInfo::operator!= (const FileInfo &other) const
00086 {
00087     return !(*this == other);
00088 }
00089 
00091 
00096 void Torrent::FileInfo::swap (FileInfo &other)
00097 {
00098     qSwap (filePath, other.filePath);
00099     qSwap (fileLength, other.fileLength);
00100     qSwap (fileChecksum, other.fileChecksum);
00101 }
00102 
00104 
00107 Torrent::Torrent()
00108     : d (new PrivateData())
00109 {
00110     d->pieceLength = 0;
00111     d->isPrivate = false;
00112 }
00113 
00115 
00118 Torrent::~Torrent()
00119 {
00120 }
00121 
00123 
00126 Torrent::Torrent (const Torrent &other)
00127     : d (other.d)
00128 {
00129 }
00130 
00132 
00136 Torrent & Torrent::operator= (const Torrent &other)
00137 {
00138     d = other.d;
00139     return *this;
00140 }
00141 
00143 
00146 bool Torrent::operator== (const Torrent &other) const
00147 {
00148     return (d->announce == other.d->announce) &&
00149            (d->announceList == other.d->announceList) &&
00150            (d->createdBy == other.d->createdBy) &&
00151            (d->comment == other.d->comment) &&
00152            (d->creationDate == other.d->creationDate) &&
00153            (d->pieceLength == other.d->pieceLength) &&
00154            (d->pieces == other.d->pieces) &&
00155            (d->isPrivate == other.d->isPrivate) &&
00156            (d->files == other.d->files) &&
00157            (d->infoHash == other.d->infoHash);
00158 }
00159 
00161 
00164 bool Torrent::operator!= (const Torrent &other) const
00165 {
00166     return !(*this == other);
00167 }