1
/***************************************************************************
2
copyright : (C) 2002-2005 by Stefano Barbato
3
email : stefano@codesink.org
5
$Id: version.cxx,v 1.2 2005/02/23 10:26:14 tat Exp $
6
***************************************************************************/
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
17
#include <mimetic/version.h>
18
#include <mimetic/utils.h>
19
#include <mimetic/tokenizer.h>
25
const Version version(VERSION);
29
: m_maj(0), m_min(0), m_build(0)
33
Version::Version(const string& s)
34
: m_maj(0), m_min(0), m_build(0)
39
Version::Version(ver_type maj, ver_type min, ver_type build)
40
: m_maj(maj), m_min(min), m_build(build)
44
Version::ver_type Version::maj() const
49
Version::ver_type Version::min() const
54
Version::ver_type Version::build() const
59
void Version::maj(Version::ver_type maj)
64
void Version::min(Version::ver_type min)
69
void Version::build(Version::ver_type build)
74
void Version::set(ver_type maj, ver_type min, ver_type build)
81
string Version::str() const
83
return utils::int2str(m_maj) + "." + utils::int2str(m_min) +
84
(m_build > 0 ? "." + utils::int2str(m_build) : "");
87
void Version::set(const string& s)
89
StringTokenizer stok(&s, ".");
92
m_maj = utils::str2int(tok);
94
m_min = utils::str2int(tok);
96
m_build = utils::str2int(tok);
99
bool Version::operator==(const Version& r) const
101
return m_maj == r.m_maj && m_min == r.m_min && m_build == r.m_build;
105
bool Version::operator!=(const Version& r) const
107
return m_maj != r.m_maj || m_min != r.m_min || m_build != r.m_build;
110
bool Version::operator<(const Version& r) const
112
return m_maj < r.m_maj || m_min < r.m_min || m_build < r.m_build;
115
bool Version::operator>(const Version& r) const
117
return m_maj > r.m_maj || m_min > r.m_min || m_build > r.m_build;
120
bool Version::operator<=(const Version& r) const
122
return m_maj <= r.m_maj || m_min <= r.m_min || m_build <= r.m_build;
125
bool Version::operator>=(const Version& r) const
127
return m_maj >= r.m_maj || m_min >= r.m_min || m_build >= r.m_build;
130
ostream& operator<<(ostream& os, const Version& v)
132
return os << v.str();