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 <sal/config.h>
25 #include <string_view>
29 /* SunVersion is used to compare java versions based on a string, as taken
30 from the registry. The strings look like "1.3", "1.3.1", "1.3.1_02" etc.
31 Versions such as "1.4.1_01a" are allowed although this is not specified.
32 1.4.1_01 < 1.4.1_01a < 1.4.1_01b < 1.4.1_02
33 Pre - release versions, such as 1.4.1-ea, 1.4.1-beta, 1.4.1-rc are recognized,
34 but are treated as minor to release versions:
36 Pre releases relate this way
37 1.4.1-ea < 1.4.1-beta < 1.4.1-rc1
39 This class supports also a FreeBSD Java. This is currently necessary because
40 it also has the vendor string "Sun Microsystems Inc.".
42 An object acts as holder for the version string. That string may be present
43 even if the version could not be parsed. Then the version may not be compatible
44 to a SUN Java version.
46 An invalid object, that is, operator bool returns false, will always be
47 the lower version in a comparison. If two invalid objects are compared
48 then they are considered equal.
50 To test if the version is ok, that is this object can be compared to others,
51 use the bool conversion operator.
53 class SunVersion final
77 //contains major,minor,micro,update
78 int m_arVersionParts
[4] = {};
79 // The update can be followed by a char, e.g. 1.4.1_01a
80 char m_nUpdateSpecial
;
82 PreRelease m_preRelease
;
85 explicit SunVersion(const char* szVer
);
86 explicit SunVersion(std::u16string_view usVer
);
89 Pre-release versions are taken into account.
90 1.5.0-beta > 1.5.0-ea > 1.4.2
92 bool operator>(const SunVersion
& ver
) const;
93 bool operator<(const SunVersion
& ver
) const;
94 bool operator==(const SunVersion
& ver
) const;
96 /** Test if the version is compatible tu SUN's versioning scheme
98 operator bool() { return m_bValid
; }
101 bool init(const char* szVer
);
105 /* Determines if a string constitutes a pre release. For example, if
106 "ea" is passed then Rel_EA is returned. If the string is no pre release
107 then Rel_NONE is returned.
109 static PreRelease
getPreRelease(const char* szRel
);
113 #endif // INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_SUNVERSION_HXX
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */