policy_find.cpp (c57aa4b9310eed09a0ad3abd1232386c15d71064) | policy_find.cpp (54ea3ad8db163d57261344167571eadfd8db94e1) |
---|---|
1/** 2 * Copyright © 2018 IBM Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 13 unchanged lines hidden (view full) --- 22{ 23namespace logging 24{ 25namespace policy 26{ 27 28static constexpr auto HOST_EVENT = "org.open_power.Host.Error.Event"; 29 | 1/** 2 * Copyright © 2018 IBM Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 13 unchanged lines hidden (view full) --- 22{ 23namespace logging 24{ 25namespace policy 26{ 27 28static constexpr auto HOST_EVENT = "org.open_power.Host.Error.Event"; 29 |
30namespace optional_ns = std::experimental; 31 | |
32/** 33 * Returns a property value from a map of properties. 34 * 35 * @tparam - T the property data type 36 * @param[in] properties - the property map 37 * @param[in] name - the property name 38 * 39 * @return optional<T> - the property value 40 */ 41template <typename T> | 30/** 31 * Returns a property value from a map of properties. 32 * 33 * @tparam - T the property data type 34 * @param[in] properties - the property map 35 * @param[in] name - the property name 36 * 37 * @return optional<T> - the property value 38 */ 39template <typename T> |
42optional_ns::optional<T> getProperty(const DbusPropertyMap& properties, 43 const std::string& name) | 40std::optional<T> getProperty(const DbusPropertyMap& properties, 41 const std::string& name) |
44{ 45 auto prop = properties.find(name); 46 47 if (prop != properties.end()) 48 { 49 return prop->second.template get<T>(); 50 } 51 --- 6 unchanged lines hidden (view full) --- 58 * 59 * NAME=VALUE 60 * 61 * @param[in] additionalData - the AdditionalData property contents 62 * @param[in] name - the name of the value to find 63 * 64 * @return optional<std::string> - the data value. Will not be empty if found. 65 */ | 42{ 43 auto prop = properties.find(name); 44 45 if (prop != properties.end()) 46 { 47 return prop->second.template get<T>(); 48 } 49 --- 6 unchanged lines hidden (view full) --- 56 * 57 * NAME=VALUE 58 * 59 * @param[in] additionalData - the AdditionalData property contents 60 * @param[in] name - the name of the value to find 61 * 62 * @return optional<std::string> - the data value. Will not be empty if found. 63 */ |
66optional_ns::optional<std::string> | 64std::optional<std::string> |
67 getAdditionalDataItem(const std::vector<std::string>& additionalData, 68 const std::string& name) 69{ 70 std::string value; 71 72 for (const auto& item : additionalData) 73 { 74 if (item.find(name + "=") != std::string::npos) --- 24 unchanged lines hidden (view full) --- 99 * 1 Recovered Informational 100 * 2 Predictive Warning 101 * everything else na Critical 102 * 103 * @param[in] data - the PEL string in the form of "00 11 22 33 4e ff" 104 * 105 * @return optional<std::string> - the severity string as listed above 106 */ | 65 getAdditionalDataItem(const std::vector<std::string>& additionalData, 66 const std::string& name) 67{ 68 std::string value; 69 70 for (const auto& item : additionalData) 71 { 72 if (item.find(name + "=") != std::string::npos) --- 24 unchanged lines hidden (view full) --- 97 * 1 Recovered Informational 98 * 2 Predictive Warning 99 * everything else na Critical 100 * 101 * @param[in] data - the PEL string in the form of "00 11 22 33 4e ff" 102 * 103 * @return optional<std::string> - the severity string as listed above 104 */ |
107optional_ns::optional<std::string> getESELSeverity(const std::string& data) | 105std::optional<std::string> getESELSeverity(const std::string& data) |
108{ 109 // The User Header section starts at byte 48, and take into account 110 // the input data is a space separated string representation of HEX data. 111 static constexpr auto UH_OFFSET = 48 * 4; 112 113 // The eye catcher is "UH" 114 static constexpr auto UH_EYECATCHER = "55 48"; 115 --- 119 unchanged lines hidden (view full) --- 235 { 236 return std::string{}; 237 } 238 239 // AdditionalData fields where the value is the modifier 240 static const std::vector<std::string> ADFields{"CALLOUT_INVENTORY_PATH", 241 "RAIL_NAME", "INPUT_NAME"}; 242 | 106{ 107 // The User Header section starts at byte 48, and take into account 108 // the input data is a space separated string representation of HEX data. 109 static constexpr auto UH_OFFSET = 48 * 4; 110 111 // The eye catcher is "UH" 112 static constexpr auto UH_EYECATCHER = "55 48"; 113 --- 119 unchanged lines hidden (view full) --- 233 { 234 return std::string{}; 235 } 236 237 // AdditionalData fields where the value is the modifier 238 static const std::vector<std::string> ADFields{"CALLOUT_INVENTORY_PATH", 239 "RAIL_NAME", "INPUT_NAME"}; 240 |
243 optional_ns::optional<std::string> mod; | 241 std::optional<std::string> mod; |
244 for (const auto& field : ADFields) 245 { 246 mod = getAdditionalDataItem(*data, field); 247 if (mod) 248 { 249 return *mod; 250 } 251 } --- 90 unchanged lines hidden --- | 242 for (const auto& field : ADFields) 243 { 244 mod = getAdditionalDataItem(*data, field); 245 if (mod) 246 { 247 return *mod; 248 } 249 } --- 90 unchanged lines hidden --- |