1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_ModuleVersionInfo_h
8 #define mozilla_ModuleVersionInfo_h
15 // Obtains basic version info from a module image's version info resource.
16 class ModuleVersionInfo
{
18 // We favor English(US) for these fields, otherwise we take the first
19 // translation provided in the version resource.
20 nsString mCompanyName
;
21 nsString mProductName
;
22 nsString mLegalCopyright
;
23 nsString mFileDescription
;
25 // Represents an A.B.C.D style version number, internally stored as a uint64_t
27 uint64_t mVersion64
= 0;
30 VersionNumber() = default;
32 VersionNumber(DWORD aMostSig
, DWORD aLeastSig
)
33 : mVersion64((uint64_t)aMostSig
<< 32 | aLeastSig
) {}
36 return (uint16_t)((mVersion64
& 0xffff000000000000) >> 48);
40 return (uint16_t)((mVersion64
& 0x0000ffff00000000) >> 32);
44 return (uint16_t)((mVersion64
& 0x00000000ffff0000) >> 16);
47 uint16_t D() const { return (uint16_t)(mVersion64
& 0x000000000000ffff); }
49 uint64_t Version64() const { return mVersion64
; }
51 bool operator==(const VersionNumber
& aOther
) const {
52 return mVersion64
== aOther
.mVersion64
;
55 nsCString
ToString() const {
57 ret
.AppendPrintf("%d.%d.%d.%d", (int)A(), (int)B(), (int)C(), (int)D());
62 VersionNumber mFileVersion
;
63 VersionNumber mProductVersion
;
65 // Returns false if it has no version resource or has no fixed version info.
66 bool GetFromImage(const nsAString
& aPath
);
69 } // namespace mozilla
71 #endif // mozilla_ModuleVersionInfo_h