Version.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 "Version.h"
00025 
00026 using Utils::Version;
00027 
00028 Version::Version (quint16 major_, quint16 minor_, quint16 revision_, quint16 build_)
00029  :  p()
00030 {
00031     p.major_ = major_;
00032     p.minor_ = minor_;
00033     p.revision_ = revision_;
00034     p.build_ = build_;
00035 }
00036 
00037 Version::Version (const QString &stringVersion)
00038  : p ()
00039 {
00040     p.major_ = 0;
00041     p.minor_ = 0;
00042     p.revision_ = 0;
00043     p.build_ = 0;
00044 
00045     QStringList versions = stringVersion.split (".");
00046     if (versions.size() > 0)
00047         p.major_ = versions [0].toUShort();
00048     if (versions.size() > 1)
00049         p.minor_ = versions [1].toUShort();
00050     if (versions.size() > 2)
00051         p.revision_ = versions [2].toUShort();
00052     if (versions.size() > 3)
00053         p.build_ = versions [3].toUShort();
00054 }
00055 
00056 Version::~Version()
00057 {
00058 }
00059 
00060 QDataStream & Utils::operator<< (QDataStream &stream, const Version &version)
00061 {
00062     stream << version.p.major_;
00063     stream << version.p.minor_;
00064     stream << version.p.revision_;
00065     stream << version.p.build_;
00066 
00067     return stream;
00068 }
00069 
00070 QDataStream & Utils::operator>> (QDataStream &stream, Version &version)
00071 {
00072     stream >> version.p.major_;
00073     stream >> version.p.minor_;
00074     stream >> version.p.revision_;
00075     stream >> version.p.build_;
00076 
00077     return stream;
00078 }