File: version.cpp

package info (click to toggle)
korelib 0.0.1-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,788 kB
  • ctags: 1,918
  • sloc: sh: 8,555; cpp: 3,989; makefile: 633; ansic: 65
file content (117 lines) | stat: -rw-r--r-- 2,547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

#include <string.h>
#include <kore/version.h>

using namespace kore;

Version::Version()
{
    setVersion();
}
Version::Version(const int major,const int minor,const int revision,const char* version)
{
    setVersion(major, minor, revision, version);
}

//Version::Version(Version& other)
//{
//    _major = other._major;
//    _minor = other._minor;
//    _revision = other._revision;
//    _version = other._version;
//}

Version::~Version()
{
    // let the user deal with allocated memory
//    delete _version;
}

const int Version::major() const
{
    return _major;
}
const int Version::minor() const
{
    return _minor;
}
const int Version::revision() const
{
    return _revision;
}
const char* Version::string() const
{
    return _version;
}
Version::operator const char*() const
{
    return _version;
}
const bool Version::operator ==(const Version& other) const
{
    return (this == &other) || ((_major == other._major) && (_minor == other._minor) && (_revision == other._revision));
}
const bool Version::operator !=(const Version& other) const
{
    return !(*this == other);
}
const bool Version::operator <(const Version& other) const
{
    return (this != &other) && ((_major < other._major) ||
        (( _major == other._major) && (_minor < other._minor)) ||
        (( _major == other._major) && (_minor == other._minor) && (_revision < other._revision)));
}
const bool Version::operator <=(const Version& other) const
{
    return (*this == other) || (*this < other);
}
const bool Version::operator >(const Version& other) const
{
    return !(*this <= other);
}
const bool Version::operator >=(const Version& other) const
{
    return !(*this < other);
}
const bool Version::operator &(const Version& other) const
{
    return true;
}
const bool Version::operator &&(const Version& other) const
{
    return true;
}

void Version::setMajor(const int major)
{
    _major = major;
}
void Version::setMinor(const int minor)
{
    _minor = minor;
}
void Version::setRevision(const int revision)
{
    _revision = revision;
}
void Version::setString(const char* version)
{
    // let the user deal with allocated memory
/*    delete _version;
    _version = 0;
    if( version )
    {
        size_t len = strlen(version);
        _version = new char[len+1];
        strcpy( _version, version );
    }
*/
    _version = version;
}
void Version::setVersion(const int major,const int minor,const int revision,const char* version)
{
    setMajor(major);
    setMinor(minor);
    setRevision(revision);
    setString(version);
}