LCOV - code coverage report
Current view: top level - jvmfwk/plugins/sunmajor/pluginlib - sunversion.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_SUNVERSION_HXX
      21             : #define INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_SUNVERSION_HXX
      22             : 
      23             : #include "rtl/ustring.hxx"
      24             : 
      25             : namespace jfw_plugin {
      26             : // Define OSL_DEBUG_LEVEL >= 2 to run a test when this lib is loaded
      27             : 
      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:
      34             :    1.4.0 > 1.4.2-beta
      35             :    Pre releases relate this way
      36             :    1.4.1-ea < 1.4.1-beta < 1.4.1-rc1
      37             : 
      38             :    This class supports also a FreeBSD Java. This is currently necessary because
      39             :    it also has the vendor string "Sun Microsystems Inc.".
      40             : 
      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.
      44             : 
      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.
      48             : 
      49             :    To test if the version is ok, that is this object can be compared to others,
      50             :    use the bool conversion operator.
      51             :  */
      52             : class SunVersion
      53             : {
      54             : protected:
      55             : 
      56             :     enum PreRelease
      57             :     {
      58             :         Rel_NONE,
      59             :         Rel_INTERNAL,
      60             :         Rel_EA,
      61             :         Rel_EA1,
      62             :         Rel_EA2,
      63             :         Rel_EA3,
      64             :         Rel_BETA,
      65             :         Rel_BETA1,
      66             :         Rel_BETA2,
      67             :         Rel_BETA3,
      68             :         Rel_RC,
      69             :         Rel_RC1,
      70             :         Rel_RC2,
      71             :         Rel_RC3
      72             : #if defined(FREEBSD)
      73             :     ,
      74             :         Rel_FreeBSD
      75             : #endif
      76             :     };
      77             : 
      78             :     //contains major,minor,micro,update
      79             :     int m_arVersionParts[4];
      80             :     // The update can be followed by a char, e.g. 1.4.1_01a
      81             :     char m_nUpdateSpecial;
      82             : 
      83             :     PreRelease m_preRelease;
      84             : public:
      85             :     SunVersion(const char * szVer);
      86             :     SunVersion(const OUString& usVer);
      87             :     ~SunVersion();
      88             : 
      89             :     /**
      90             :        Pre-release versions are taken into account.
      91             :        1.5.0-beta > 1.5.0-ea > 1.4.2
      92             :      */
      93             :     bool operator > (const SunVersion& ver) const;
      94             :     bool operator < (const SunVersion& ver) const;
      95             :     bool operator == (const SunVersion& ver) const;
      96             : 
      97             :     /** Test if the version is compatible tu SUN's versioning scheme
      98             :      */
      99          77 :     operator bool () { return m_bValid;}
     100             : 
     101             :     /** Will always contain a value if the object has been constructed with
     102             :         a version string.
     103             :      */
     104             :     OUString usVersion;
     105             : 
     106             : protected:
     107             :     bool init(const char * szVer);
     108             : 
     109             :     bool m_bValid;
     110             : 
     111             :     /* Determines if a string constitutes a pre release. For example, if
     112             :        "ea" is passed then Rel_EA is returned. If the string is no pre release
     113             :        then Rel_NONE is returned.
     114             :     */
     115             :     static PreRelease getPreRelease(const char *szRel);
     116             : };
     117             : 
     118             : }
     119             : 
     120             : #endif // INCLUDED_JVMFWK_PLUGINS_SUNMAJOR_PLUGINLIB_SUNVERSION_HXX
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11