xref: /openbmc/openpower-vpd-parser/vpd-tool/include/tool_types.hpp (revision a8bb16637a7dcd594296291b72c118e6786dd8b7)
1 #pragma once
2 
3 #include <sdbusplus/message/types.hpp>
4 
5 #include <cstdint>
6 #include <tuple>
7 #include <variant>
8 #include <vector>
9 
10 namespace vpd
11 {
12 namespace types
13 {
14 using BinaryVector = std::vector<uint8_t>;
15 
16 // This covers mostly all the data type supported over DBus for a property.
17 // clang-format off
18 using DbusVariantType = std::variant<
19     std::vector<std::tuple<std::string, std::string, std::string>>,
20     std::vector<std::string>,
21     std::vector<double>,
22     std::string,
23     int64_t,
24     uint64_t,
25     double,
26     int32_t,
27     uint32_t,
28     int16_t,
29     uint16_t,
30     uint8_t,
31     bool,
32     BinaryVector,
33     std::vector<uint32_t>,
34     std::vector<uint16_t>,
35     sdbusplus::message::object_path,
36     std::tuple<uint64_t, std::vector<std::tuple<std::string, std::string, double, uint64_t>>>,
37     std::vector<std::tuple<std::string, std::string>>,
38     std::vector<std::tuple<uint32_t, std::vector<uint32_t>>>,
39     std::vector<std::tuple<uint32_t, size_t>>,
40     std::vector<std::tuple<sdbusplus::message::object_path, std::string,
41                            std::string, std::string>>
42  >;
43 
44 //IpzType contains tuple of <Record, Keyword>
45 using IpzType = std::tuple<std::string, std::string>;
46 
47 //ReadVpdParams either of IPZ or keyword format
48 using ReadVpdParams = std::variant<IpzType, std::string>;
49 
50 //KwData contains tuple of <keywordName, KeywordValue>
51 using KwData = std::tuple<std::string, BinaryVector>;
52 
53 //IpzData contains tuple of <RecordName, KeywordName, KeywordValue>
54 using IpzData = std::tuple<std::string, std::string, BinaryVector>;
55 
56 //WriteVpdParams either of IPZ or keyword format
57 using WriteVpdParams = std::variant<IpzData, KwData>;
58 // Return type of ObjectMapper GetObject API
59 using MapperGetObject = std::map<std::string,std::vector<std::string>>;
60 
61 // Table row data
62 using TableRowData = std::vector<std::string>;
63 
64 // Type used to populate table data
65 using TableInputData = std::vector<TableRowData>;
66 
67 // A table column name-size pair
68 using TableColumnNameSizePair = std::pair<std::string, std::size_t>;
69 
70 /* Map<Property, Value>*/
71 using PropertyMap = std::map<std::string, DbusVariantType>;
72 
73 enum UserOption
74 {
75     Exit,
76     UseBackupDataForAll,
77     UseSystemBackplaneDataForAll,
78     MoreOptions,
79     UseBackupDataForCurrent,
80     UseSystemBackplaneDataForCurrent,
81     NewValueOnBoth,
82     SkipCurrent
83 };
84 
85 } // namespace types
86 } // namespace vpd
87