| Jason M. Bills | 70304cb | 2019-03-27 12:03:59 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | // Copyright (c) 2019 Intel 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 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | */ | 
|  | 16 | #pragma once | 
| Ed Tanous | c5ba4c2 | 2022-02-07 09:59:55 -0800 | [diff] [blame] | 17 |  | 
|  | 18 | #include <span> | 
|  | 19 | #include <string> | 
|  | 20 | #include <string_view> | 
|  | 21 |  | 
| Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 22 | namespace redfish::registries | 
| Jason M. Bills | 70304cb | 2019-03-27 12:03:59 -0700 | [diff] [blame] | 23 | { | 
| Jason M. Bills | 351d306 | 2019-03-27 12:58:21 -0700 | [diff] [blame] | 24 | struct Header | 
|  | 25 | { | 
|  | 26 | const char* copyright; | 
|  | 27 | const char* type; | 
|  | 28 | const char* id; | 
|  | 29 | const char* name; | 
|  | 30 | const char* language; | 
|  | 31 | const char* description; | 
|  | 32 | const char* registryPrefix; | 
|  | 33 | const char* registryVersion; | 
|  | 34 | const char* owningEntity; | 
|  | 35 | }; | 
| Jason M. Bills | 70304cb | 2019-03-27 12:03:59 -0700 | [diff] [blame] | 36 |  | 
|  | 37 | struct Message | 
|  | 38 | { | 
|  | 39 | const char* description; | 
|  | 40 | const char* message; | 
| Gunnar Mills | e7808c9 | 2020-07-08 21:17:44 -0500 | [diff] [blame] | 41 | const char* messageSeverity; | 
| Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 42 | const size_t numberOfArgs; | 
| Jason M. Bills | 70304cb | 2019-03-27 12:03:59 -0700 | [diff] [blame] | 43 | std::array<const char*, 5> paramTypes; | 
|  | 44 | const char* resolution; | 
|  | 45 | }; | 
|  | 46 | using MessageEntry = std::pair<const char*, const Message>; | 
| Ed Tanous | c5ba4c2 | 2022-02-07 09:59:55 -0800 | [diff] [blame] | 47 |  | 
|  | 48 | inline void fillMessageArgs(const std::span<const std::string_view> messageArgs, | 
|  | 49 | std::string& msg) | 
|  | 50 | { | 
|  | 51 | int i = 0; | 
|  | 52 | for (const std::string_view& messageArg : messageArgs) | 
|  | 53 | { | 
|  | 54 | std::string argStr = "%" + std::to_string(i + 1); | 
|  | 55 | size_t argPos = msg.find(argStr); | 
|  | 56 | if (argPos != std::string::npos) | 
|  | 57 | { | 
|  | 58 | msg.replace(argPos, argStr.length(), messageArg); | 
|  | 59 | } | 
|  | 60 | i++; | 
|  | 61 | } | 
|  | 62 | } | 
|  | 63 |  | 
| Ed Tanous | fffb8c1 | 2022-02-07 23:53:03 -0800 | [diff] [blame] | 64 | } // namespace redfish::registries |