summaryrefslogtreecommitdiff
path: root/tools/pe_bliss/version_info_viewer.h
blob: bc2f6f2ba7ae3db07bbe10218a460b0ebafc51e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*************************************************************************/
/* Copyright (c) 2015 dx, http://kaimi.ru                                */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person           */
/* obtaining a copy of this software and associated documentation        */
/* files (the "Software"), to deal in the Software without               */
/* restriction, including without limitation the rights to use,          */
/* copy, modify, merge, publish, distribute, sublicense, and/or          */
/* sell copies of the Software, and to permit persons to whom the        */
/* Software is furnished to do so, subject to the following conditions:  */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/
#pragma once
#include <map>
#include <vector>
#include <string>
#include "pe_resource_viewer.h"
#include "pe_structures.h"
#include "version_info_types.h"

namespace pe_bliss
{
//Helper class to read version information
//lang_string_values_map: map of version info strings with encodings
//translation_values_map: map of translations
class version_info_viewer
{
public:
	//Useful typedefs
	typedef std::pair<uint16_t, uint16_t> translation_pair;
	typedef std::vector<std::wstring> translation_list;

public:
	//Default constructor
	//strings - version info strings with charsets
	//translations - version info translations map
	version_info_viewer(const lang_string_values_map& strings, const translation_values_map& translations);

	//Below functions have parameter translation
	//If it's empty, the default language translation will be taken
	//If there's no default language translation, the first one will be taken

	//Returns company name
	const std::wstring get_company_name(const std::wstring& translation = std::wstring()) const;
	//Returns file description
	const std::wstring get_file_description(const std::wstring& translation = std::wstring()) const;
	//Returns file version
	const std::wstring get_file_version(const std::wstring& translation = std::wstring()) const;
	//Returns internal file name
	const std::wstring get_internal_name(const std::wstring& translation = std::wstring()) const;
	//Returns legal copyright
	const std::wstring get_legal_copyright(const std::wstring& translation = std::wstring()) const;
	//Returns original file name
	const std::wstring get_original_filename(const std::wstring& translation = std::wstring()) const;
	//Returns product name
	const std::wstring get_product_name(const std::wstring& translation = std::wstring()) const;
	//Returns product version
	const std::wstring get_product_version(const std::wstring& translation = std::wstring()) const;

	//Returns list of translations in string representation
	const translation_list get_translation_list() const;

	//Returns version info property value
	//property_name - required property name
	//If throw_if_absent = true, will throw exception if property does not exist
	//If throw_if_absent = false, will return empty string if property does not exist
	const std::wstring get_property(const std::wstring& property_name, const std::wstring& translation = std::wstring(), bool throw_if_absent = false) const;

	//Converts translation HEX-string to pair of language ID and codepage ID
	static const translation_pair translation_from_string(const std::wstring& translation);

public:
	//Default process language, UNICODE
	static const std::wstring default_language_translation;

private:
	const lang_string_values_map& strings_;
	const translation_values_map& translations_;
};
}