1
/******************************************************************************
2
* swversion.h - definition of class SWVersion used to compare version info
4
* $Id: swversion.h 1763 2005-04-03 23:57:03Z scribe $
6
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
7
* CrossWire Bible Society
11
* This program is free software; you can redistribute it and/or modify it
12
* under the terms of the GNU General Public License as published by the
13
* Free Software Foundation version 2.
15
* This program is distributed in the hope that it will be useful, but
16
* WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
* General Public License for more details.
28
/** A basic tool class to handle program version numbers.
30
class SWDLLEXPORT SWVersion {
32
/** The different version subnumbers.
34
int major, minor, minor2, minor3;
36
* @param version Version string to be parsed.
38
SWVersion(const char *version = "0.0");
39
/** Compare 2 Versions with each other.
40
* @param vi Version number to compare with.
41
* @return >0:this>vi; 0:this==vi; <0:this<vi
43
int compare(const SWVersion &vi) const;
44
/** @return The parsed version number text.
46
const char *getText() const;
47
/** @return The parsed version number text.
49
operator const char *() const { return getText(); }
50
bool operator>(const SWVersion &vi) const {return (compare(vi) > 0);}
51
bool operator<(const SWVersion &vi) const {return (compare(vi) < 0);}
52
bool operator>=(const SWVersion &vi) const {return (compare(vi) >= 0);}
53
bool operator<=(const SWVersion &vi) const {return (compare(vi) <= 0);}
54
bool operator==(const SWVersion &vi) const {return (compare(vi) == 0);}
56
/** Current sword library version.
57
* Use this to check (e.g. at compile time) if the
58
* version of the sword lib is recent enough for your program.
60
static SWVersion currentVersion;