📄 version_info.hpp
字号:
private:
void const* m_p;
};
const_iterator begin() const;
const_iterator end() const;
private:
VarFileInfo_hdr const *m_p;
void const *m_vars;
};
/** \brief Represents a variable string part of a version information block
*
* \ingroup group__library__system
*/
class VsStringFileInfo
: public stlsoft_ns_qual(stl_collection_tag)
{
public:
typedef VsStringFileInfo class_type;
/// The value type
typedef VsStringTable value_type;
public:
/// Constructor
VsStringFileInfo(StringFileInfo_hdr const* p);
/// The key of the StringFileInfo block
wchar_t const* Key() const;
/// Non-mutating (const) iterator type for the StringFileInfo block
///
/// \note The value type is \c VsStringTable
class const_iterator
: public stlsoft_ns_qual(iterator_base)<winstl_ns_qual_std(forward_iterator_tag)
, value_type
, ws_ptrdiff_t
, void // By-Value Temporary reference
, value_type // By-Value Temporary reference
>
{
public:
/// The class type
typedef const_iterator class_type;
/// The value type
typedef VsStringTable value_type;
public:
/// Constructor
const_iterator(void const* p);
/// Pre-increment operator
class_type& operator ++();
/// Post-increment operator
class_type operator ++(int);
value_type operator *() const;
ws_bool_t operator ==(class_type const& rhs) const;
ws_bool_t operator !=(class_type const& rhs) const;
private:
void const* m_p;
};
const_iterator begin() const;
const_iterator end() const;
private:
StringFileInfo_hdr const *m_p;
void const *m_vars;
};
/** \brief Provides convenient access to aspects of a module's version information
*
* \ingroup group__library__system
*/
class version_info
{
private:
typedef processheap_allocator<ws_byte_t> allocator_type;
public:
typedef version_info class_type;
/// \name Construction
/// @{
public:
/// Creates an instance corresponding to the version information from the given module
///
/// \param moduleName The name of the module (.exe, .dll, etc.) to load
ss_explicit_k version_info(ws_char_a_t const* moduleName);
/// Creates an instance corresponding to the version information from the given module
///
/// \param moduleName The name of the module (.exe, .dll, etc.) to load
ss_explicit_k version_info(ws_char_w_t const* moduleName);
/// Releases any allocated resources
~version_info() stlsoft_throw_0();
/// @}
/// \name Properties
/// @{
public:
/// The length of the version information
ws_size_t Length() const;
/// The length of the value part of the version block
ws_size_t ValueLength() const;
/// The type field in the version block
ws_size_t Type() const;
/// The key of the version block
wchar_t const* Key() const;
/// The FixedFileInfo part of the block
fixed_file_info FixedFileInfo() const;
/// Indicates whether the module contains a VarFileInfo block
ws_bool_t HasVarFileInfo() const;
/// The VarFileInfo part of the block
VsVarFileInfo VarFileInfo() const;
/// Indicates whether the module contains a StringFileInfo block
ws_bool_t HasStringFileInfo() const;
/// The StringFileInfo part of the block
VsStringFileInfo StringFileInfo() const;
/// @}
private:
static VS_VERSIONINFO_hdr const* retrieve_module_info_block_(ws_char_a_t const* moduleName);
static VS_VERSIONINFO_hdr const* retrieve_module_info_block_(ws_char_w_t const* moduleName);
static wchar_t const* calc_key_(void const* pv);
static VS_FIXEDFILEINFO const* calc_ffi_(wchar_t const* key);
static WORD const* calc_children_(VS_FIXEDFILEINFO const* ffi);
private:
void init_();
private:
VS_VERSIONINFO_hdr const *const m_hdr;
wchar_t const *const m_key;
VS_FIXEDFILEINFO const *const m_ffi;
WORD const *const m_children;
StringFileInfo_hdr const *m_sfi;
VarFileInfo_hdr const *m_vfi;
// Not to be implemented
private:
version_info(class_type const& rhs);
class_type& operator =(class_type const& rhs);
};
////////////////////////////////////////////////////////////////////////////
// Unit-testing
#ifdef STLSOFT_UNITTEST
# include "./unittest/version_info_unittest_.h"
#endif /* STLSOFT_UNITTEST */
/* /////////////////////////////////////////////////////////////////////////
* Implementation
*/
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
inline /* static */ FILETIME fixed_file_info::calc_FileDateTime_(VS_FIXEDFILEINFO const* ffi)
{
FILETIME ft = { ffi->dwFileDateLS, ffi->dwFileDateMS };
return ft;
}
inline fixed_file_info::fixed_file_info(VS_FIXEDFILEINFO const* ffi)
: m_ffi(ffi)
, m_fileDateTime(calc_FileDateTime_(ffi))
{}
inline ws_uint16_t fixed_file_info::ApiVerHigh() const
{
return HIWORD(m_ffi->dwStrucVersion);
}
inline ws_uint16_t fixed_file_info::ApiVerLow() const
{
return LOWORD(m_ffi->dwStrucVersion);
}
inline ws_uint16_t fixed_file_info::FileVerMajor() const
{
return HIWORD(m_ffi->dwFileVersionMS);
}
inline ws_uint16_t fixed_file_info::FileVerMinor() const
{
return LOWORD(m_ffi->dwFileVersionMS);
}
inline ws_uint16_t fixed_file_info::FileVerRevision() const
{
return HIWORD(m_ffi->dwFileVersionLS);
}
inline ws_uint16_t fixed_file_info::FileVerBuild() const
{
return LOWORD(m_ffi->dwFileVersionLS);
}
inline ws_uint16_t fixed_file_info::ProductVerMajor() const
{
return HIWORD(m_ffi->dwProductVersionMS);
}
inline ws_uint16_t fixed_file_info::ProductVerMinor() const
{
return LOWORD(m_ffi->dwProductVersionMS);
}
inline ws_uint16_t fixed_file_info::ProductVerRevision() const
{
return HIWORD(m_ffi->dwProductVersionLS);
}
inline ws_uint16_t fixed_file_info::ProductVerBuild() const
{
return LOWORD(m_ffi->dwProductVersionLS);
}
inline ws_uint32_t fixed_file_info::FileFlagsMask() const
{
return m_ffi->dwFileFlagsMask;
}
inline ws_uint32_t fixed_file_info::FileFlags() const
{
return m_ffi->dwFileFlags;
}
inline ws_uint32_t fixed_file_info::FileOS() const
{
return m_ffi->dwFileOS;
}
inline ws_uint32_t fixed_file_info::FileType() const
{
return m_ffi->dwFileType;
}
inline ws_uint32_t fixed_file_info::FileSubtype() const
{
return m_ffi->dwFileSubtype;
}
inline FILETIME const& fixed_file_info::FileDateTime() const
{
return m_fileDateTime;
}
inline VsVar::VsVar(Var_hdr const* p)
: m_p(p)
{
WINSTL_ASSERT(0 == ::wcsncmp(p->szKey, L"Translation", 12));
m_values = sap_cast<LangCodePage const*>(rounded_ptr(&p->szKey[1 + ::wcslen(p->szKey)], 4));
}
inline ss_size_t VsVar::length() const
{
return m_p->wValueLength / sizeof(LangCodePage);
}
inline VsVar::LangCodePage const& VsVar::operator [](ss_size_t index) const
{
return m_values[index];
}
inline VsString::VsString(String_hdr const* p)
: m_name(p->szKey)
{
m_value = sap_cast<wchar_t const*>(rounded_ptr(&p->szKey[1 + ::wcslen(p->szKey)], 4));
}
inline wchar_t const* VsString::name() const
{
return m_name;
}
inline wchar_t const* VsString::value() const
{
return m_value;
}
inline VsStringTable::VsStringTable(StringTable_hdr const* p)
: m_p(p)
{
m_strings = rounded_ptr(&p->szKey[1 + ::wcslen(p->szKey)], 4);
}
inline wchar_t const* VsStringTable::Key() const
{
WINSTL_ASSERT(NULL != m_p);
return m_p->szKey;
}
inline VsStringTable::const_iterator::const_iterator(void const* p)
: m_p(p)
{}
inline VsStringTable::const_iterator::class_type &VsStringTable::const_iterator::operator ++()
{
String_hdr const* str = static_cast<String_hdr const*>(m_p);
m_p = rounded_ptr(m_p, str->wLength, 4);
return *this;
}
inline VsStringTable::const_iterator::class_type VsStringTable::const_iterator::operator ++(int)
{
const_iterator ret(*this);
operator ++();
return ret;
}
inline VsString VsStringTable::const_iterator::operator *() const
{
String_hdr const* str = static_cast<String_hdr const*>(m_p);
return VsString(str);
}
inline ws_bool_t VsStringTable::const_iterator::operator ==(VsStringTable::const_iterator::class_type const& rhs) const
{
return m_p == rhs.m_p;
}
inline ws_bool_t VsStringTable::const_iterator::operator !=(VsStringTable::const_iterator::class_type const& rhs) const
{
return !operator ==(rhs);
}
inline VsStringTable::const_iterator VsStringTable::begin() const
{
return const_iterator(m_strings);
}
inline VsStringTable::const_iterator VsStringTable::end() const
{
return const_iterator(rounded_ptr(m_p, m_p->wLength, 4));
}
inline VsVarFileInfo::VsVarFileInfo(VarFileInfo_hdr const* p)
: m_p(p)
{
WINSTL_ASSERT(0 == ::wcsncmp(p->szKey, L"VarFileInfo", 12));
m_vars = rounded_ptr(&p->szKey[1 + ::wcslen(p->szKey)], 4);
}
inline wchar_t const* VsVarFileInfo::Key() const
{
WINSTL_ASSERT(NULL != m_p);
return m_p->szKey;
}
inline VsVarFileInfo::const_iterator::const_iterator(void const* p)
: m_p(p)
{}
inline VsVarFileInfo::const_iterator::class_type &VsVarFileInfo::const_iterator::operator ++()
{
Var_hdr const* var = static_cast<Var_hdr const*>(m_p);
m_p = rounded_ptr(m_p, var->wLength, 4);
return *this;
}
inline VsVarFileInfo::const_iterator::class_type VsVarFileInfo::const_iterator::operator ++(int)
{
const_iterator ret(*this);
operator ++();
return ret;
}
inline VsVar VsVarFileInfo::const_iterator::operator *() const
{
Var_hdr const* var = static_cast<Var_hdr const*>(m_p);
return VsVar(var);
}
inline ws_bool_t VsVarFileInfo::const_iterator::operator ==(class_type const& rhs) const
{
return m_p == rhs.m_p;
}
inline ws_bool_t VsVarFileInfo::const_iterator::operator !=(class_type const& rhs) const
{
return !operator ==(rhs);
}
inline VsVarFileInfo::const_iterator VsVarFileInfo::begin() const
{
return const_iterator(m_vars);
}
inline VsVarFileInfo::const_iterator VsVarFileInfo::end() const
{
return const_iterator(rounded_ptr(m_p, m_p->wLength, 4));
}
inline VsStringFileInfo::VsStringFileInfo(StringFileInfo_hdr const* p)
: m_p(p)
{
WINSTL_ASSERT(0 == ::wcsncmp(p->szKey, L"StringFileInfo", 15));
m_vars = rounded_ptr(&p->szKey[1 + ::wcslen(p->szKey)], 4);
}
inline wchar_t const* VsStringFileInfo::Key() const
{
WINSTL_ASSERT(NULL != m_p);
return m_p->szKey;
}
inline VsStringFileInfo::const_iterator::const_iterator(void const* p)
: m_p(p)
{}
inline VsStringFileInfo::const_iterator::class_type &VsStringFileInfo::const_iterator::operator ++()
{
StringTable_hdr const* strtbl = static_cast<StringTable_hdr const*>(m_p);
m_p = rounded_ptr(m_p, strtbl->wLength, 4);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -