00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Base Library 00005 * Module : VersionInfo 00006 * Package : Zeus.ZeusBase.System 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef VersionInfoH 00033 #define VersionInfoH 00034 00035 #include <zeusbase/System/ZObject.h> 00036 00037 BEGIN_NAMESPACE_Zeus 00038 00039 /****************************************************************************/ 00042 /****************************************************************************/ 00043 zeusbase_class TVersionInfo : public TZObject 00044 { 00045 public: 00046 TVersionInfo(); 00047 TVersionInfo(Uint uiMajorVersion, Uint uiSubVersion); 00048 TVersionInfo(Uint uiMajorVersion, Uint uiSubVersion, Uint uiRelease, Uint uiBuild); 00049 TVersionInfo(const IString& rVersion); 00050 TVersionInfo(const TVersionInfo& rVersion); 00051 virtual ~TVersionInfo(); 00052 00053 bool assign(const IString& rVersion); 00054 bool assign(const TVersionInfo& rVersion); 00055 inline bool assign(const wchar_t* pVersion) { return assign(TString(pVersion)); } 00056 00057 bool equals(const IString& rVersion) const; 00058 bool equals(const TVersionInfo& rVersion) const; 00059 inline bool equals(const wchar_t* pVersion) const { return equals(TString(pVersion)); } 00060 00062 inline Uint getMajorVersion() const { return m_uiMajorVersion; } 00064 inline Uint getSubVersion() const { return m_uiSubVersion; } 00066 inline Uint getRelease() const { return m_uiRelease; } 00068 inline Uint getBuild() const { return m_uiBuild; } 00069 00071 inline void setMajorVersion(Uint uiValue) { m_uiMajorVersion = uiValue; } 00073 inline void setSubVersion(Uint uiValue) { m_uiSubVersion = uiValue; } 00075 inline void setRelease(Uint uiValue) { m_uiRelease = uiValue; } 00077 inline void setBuild(Uint uiValue) { m_uiBuild = uiValue; } 00078 00079 00080 //Operators 00081 inline TVersionInfo& operator=(const TVersionInfo& rVersion) { this->assign(rVersion); return *this; } 00082 inline TVersionInfo& operator=(const IString& rVersion) { this->assign(rVersion); return *this; } 00083 inline TVersionInfo& operator=(const wchar_t* pVersion) { this->assign(pVersion); return *this; } 00084 00085 inline bool operator==(const TVersionInfo& rVersion) const { return this->equals(rVersion); } 00086 inline bool operator==(const IString& rVersion) const { return this->equals(rVersion); } 00087 inline bool operator==(const wchar_t* pVersion) const { return this->equals(pVersion); } 00088 00089 TString toString() const; 00090 TString convertToString(bool bIncludeRelease= false, bool bIncludeBuild = false) const; 00091 00092 static TVersionInfo getFileVersion(const IString& rFileName); 00093 00094 protected: 00096 Uint m_uiMajorVersion; 00098 Uint m_uiSubVersion; 00100 Uint m_uiRelease; 00102 Uint m_uiBuild; 00103 00104 private: 00105 00106 }; 00107 00108 //INLINE METHODS 00109 /****************************************************************************/ 00113 /****************************************************************************/ 00114 inline bool TVersionInfo::equals(const TVersionInfo& rVersion) const 00115 { 00116 return (m_uiMajorVersion == rVersion.m_uiMajorVersion && 00117 m_uiSubVersion == rVersion.m_uiSubVersion && 00118 m_uiRelease == rVersion.m_uiRelease && 00119 m_uiBuild == rVersion.m_uiBuild); 00120 } 00121 00122 /****************************************************************************/ 00126 /****************************************************************************/ 00127 inline bool TVersionInfo::equals(const IString& rVersion) const 00128 { 00129 return equals(TVersionInfo(rVersion)); 00130 } 00131 00132 /****************************************************************************/ 00135 /****************************************************************************/ 00136 inline TString TVersionInfo::toString() const 00137 { 00138 return convertToString(true, true); 00139 } 00140 00141 END_NAMESPACE_Zeus 00142 #endif