#include <swversion.h>

Public Member Functions | |
| int | compare (const SWVersion &vi) const |
| const char * | getText () const |
| operator const char * () const | |
| bool | operator< (const SWVersion &vi) const |
| bool | operator<= (const SWVersion &vi) const |
| bool | operator== (const SWVersion &vi) const |
| bool | operator> (const SWVersion &vi) const |
| bool | operator>= (const SWVersion &vi) const |
| SWVersion (const char *version="0.0") | |
Public Attributes | |
| int | major |
| int | minor |
| int | minor2 |
| int | minor3 |
Static Public Attributes | |
| static SWVersion | currentVersion |
A basic tool class to handle program version numbers.
Definition at line 30 of file swversion.h.
| SWVersion::SWVersion | ( | const char * | version = "0.0" |
) |
The constructor.
| version | Version string to be parsed. |
Definition at line 35 of file swversion.cpp.
00035 { 00036 char *buf = new char[ strlen(version) + 1 ]; 00037 char *tok; 00038 major = minor = minor2 = minor3 = -1; 00039 00040 strcpy(buf, version); 00041 tok = strtok(buf, "."); 00042 if (tok) 00043 major = atoi(tok); 00044 tok = strtok(0, "."); 00045 if (tok) 00046 minor = atoi(tok); 00047 tok = strtok(0, "."); 00048 if (tok) 00049 minor2 = atoi(tok); 00050 tok = strtok(0, "."); 00051 if (tok) 00052 minor3 = atoi(tok); 00053 delete [] buf; 00054 }
| int SWVersion::compare | ( | const SWVersion & | vi | ) | const |
Compare 2 Versions with each other.
| vi | Version number to compare with. |
Definition at line 67 of file swversion.cpp.
| const char * SWVersion::getText | ( | ) | const |
Definition at line 80 of file swversion.cpp.
00080 { 00081 00082 // 255 is safe because there is no way 4 integers (plus 3 '.'s) can have 00083 // a string representation that will overrun this buffer 00084 static char buf[255]; 00085 00086 if (minor > -1) { 00087 if (minor2 > -1) { 00088 if (minor3 > -1) { 00089 sprintf(buf, "%d.%d.%d.%d", major, minor, minor2, minor3); 00090 } 00091 else sprintf(buf, "%d.%d.%d", major, minor, minor2); 00092 } 00093 else sprintf(buf, "%d.%d", major, minor); 00094 } 00095 else sprintf(buf, "%d", major); 00096 00097 return buf; 00098 }
| SWVersion::operator const char * | ( | ) | const [inline] |
Definition at line 49 of file swversion.h.
00049 { return getText(); }
| bool SWVersion::operator< | ( | const SWVersion & | vi | ) | const [inline] |
Definition at line 51 of file swversion.h.
00051 {return (compare(vi) < 0);}
| bool SWVersion::operator<= | ( | const SWVersion & | vi | ) | const [inline] |
Definition at line 53 of file swversion.h.
00053 {return (compare(vi) <= 0);}
| bool SWVersion::operator== | ( | const SWVersion & | vi | ) | const [inline] |
Definition at line 54 of file swversion.h.
00054 {return (compare(vi) == 0);}
| bool SWVersion::operator> | ( | const SWVersion & | vi | ) | const [inline] |
Definition at line 50 of file swversion.h.
00050 {return (compare(vi) > 0);}
| bool SWVersion::operator>= | ( | const SWVersion & | vi | ) | const [inline] |
Definition at line 52 of file swversion.h.
00052 {return (compare(vi) >= 0);}
SWORD_NAMESPACE_START SWVersion SWVersion::currentVersion [static] |
Current sword library version. Use this to check (e.g. at compile time) if the version of the sword lib is recent enough for your program.
Definition at line 60 of file swversion.h.
| int SWVersion::major |
The different version subnumbers.
Definition at line 34 of file swversion.h.
| int SWVersion::minor |
Definition at line 34 of file swversion.h.
Definition at line 34 of file swversion.h.
Definition at line 34 of file swversion.h.
1.6.1