1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_SUNVERSION_HXX
21 #define INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_SUNVERSION_HXX
23 #include <rtl/ustring.hxx>
25 namespace jfw_plugin
{
26 // Define OSL_DEBUG_LEVEL >= 2 to run a test when this lib is loaded
28 /* SunVersion is used to compare java versions based on a string, as taken
29 from the registry. The strings look like "1.3", "1.3.1", "1.3.1_02" etc.
30 Versions such as "1.4.1_01a" are allowed although this is not specified.
31 1.4.1_01 < 1.4.1_01a < 1.4.1_01b < 1.4.1_02
32 Pre - release versions, such as 1.4.1-ea, 1.4.1-beta, 1.4.1-rc are recognized,
33 but are treated as minor to release versions:
35 Pre releases relate this way
36 1.4.1-ea < 1.4.1-beta < 1.4.1-rc1
38 This class supports also a FreeBSD Java. This is currently necessary because
39 it also has the vendor string "Sun Microsystems Inc.".
41 An object acts as holder for the version string. That string may be present
42 even if the version could not be parsed. Then the version may not be compatible
43 to a SUN Java version.
45 An invalid object, that is, operator bool returns false, will always be
46 the lower version in a comparison. If two invalid objects are compared
47 then they are considered equal.
49 To test if the version is ok, that is this object can be compared to others,
50 use the bool conversion operator.
52 class SunVersion final
76 //contains major,minor,micro,update
77 int m_arVersionParts
[4];
78 // The update can be followed by a char, e.g. 1.4.1_01a
79 char m_nUpdateSpecial
;
81 PreRelease m_preRelease
;
83 explicit SunVersion(const char * szVer
);
84 explicit SunVersion(const OUString
& usVer
);
88 Pre-release versions are taken into account.
89 1.5.0-beta > 1.5.0-ea > 1.4.2
91 bool operator > (const SunVersion
& ver
) const;
92 bool operator < (const SunVersion
& ver
) const;
93 bool operator == (const SunVersion
& ver
) const;
95 /** Test if the version is compatible tu SUN's versioning scheme
97 operator bool () { return m_bValid
;}
99 /** Will always contain a value if the object has been constructed with
105 bool init(const char * szVer
);
109 /* Determines if a string constitutes a pre release. For example, if
110 "ea" is passed then Rel_EA is returned. If the string is no pre release
111 then Rel_NONE is returned.
113 static PreRelease
getPreRelease(const char *szRel
);
118 #endif // INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_SUNVERSION_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */