• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17 #pragma once
18 
19 #include <atlpath.h>                            // ATL CPath
20 
21 
22 // Transforms a Java major.minor number (e.g. "1.7") to internal int value (1007)
23 #define JAVA_VERS_TO_INT(major, minor)  ((major) * 1000 + (minor))
24 // Extracts the major part from the internal int major.minor number
25 #define JAVA_MAJOR(majorMinor)          ((majorMinor) / 1000)
26 // Extracts the minor part from the internal int major.minor number
27 #define JAVA_MINOR(majorMinor)          ((majorMinor) % 1000)
28 
29 
30 struct CJavaPath {
31     int mVersion;
32     CPath mPath;
33 
34     // Static empty path that can be returned as a reference.
35     static const CJavaPath sEmpty;
36 
CJavaPathCJavaPath37     CJavaPath() : mVersion(0) {}
38     CJavaPath(int version, CPath path);
39     void set(int version, CPath path);
40 
41     // Returns true if path/version is empty/0
42     bool isEmpty() const;
43 
44     // Clears path and version to 0
45     void clear();
46 
47     // Converts the internal path into a short DOS path.
48     // Returns true if this was possible and false if the conversion failed.
49     bool toShortPath();
50 
51     // Returns the version formatted as a string (e.g. "1.7" instead of 1007.)
52     CString getVersion() const;
53 
54     // Operators < and == for this to be suitable in an ordered std::set
55     bool operator<  (const CJavaPath& rhs) const;
56     bool operator== (const CJavaPath& rhs) const;
57 };
58