blob: a995d765e59a593f52022f54e99c68d300169907 [file] [log] [blame]
Jason M. Bills70304cb2019-03-27 12:03:59 -07001/*
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 Tanousc5ba4c22022-02-07 09:59:55 -080017
Nan Zhoud5c80ad2022-07-11 01:16:31 +000018#include <array>
19#include <cstddef>
Ed Tanousc5ba4c22022-02-07 09:59:55 -080020#include <span>
21#include <string>
22#include <string_view>
Nan Zhoud5c80ad2022-07-11 01:16:31 +000023#include <utility>
24
25// IWYU pragma: no_include <stddef.h>
Ed Tanousc5ba4c22022-02-07 09:59:55 -080026
Ed Tanousfffb8c12022-02-07 23:53:03 -080027namespace redfish::registries
Jason M. Bills70304cb2019-03-27 12:03:59 -070028{
Jason M. Bills351d3062019-03-27 12:58:21 -070029struct Header
30{
31 const char* copyright;
32 const char* type;
33 const char* id;
34 const char* name;
35 const char* language;
36 const char* description;
37 const char* registryPrefix;
38 const char* registryVersion;
39 const char* owningEntity;
40};
Jason M. Bills70304cb2019-03-27 12:03:59 -070041
42struct Message
43{
44 const char* description;
45 const char* message;
Gunnar Millse7808c92020-07-08 21:17:44 -050046 const char* messageSeverity;
Ed Tanous271584a2019-07-09 16:24:22 -070047 const size_t numberOfArgs;
Jason M. Bills70304cb2019-03-27 12:03:59 -070048 std::array<const char*, 5> paramTypes;
49 const char* resolution;
50};
51using MessageEntry = std::pair<const char*, const Message>;
Ed Tanousc5ba4c22022-02-07 09:59:55 -080052
53inline void fillMessageArgs(const std::span<const std::string_view> messageArgs,
54 std::string& msg)
55{
56 int i = 0;
57 for (const std::string_view& messageArg : messageArgs)
58 {
59 std::string argStr = "%" + std::to_string(i + 1);
60 size_t argPos = msg.find(argStr);
61 if (argPos != std::string::npos)
62 {
63 msg.replace(argPos, argStr.length(), messageArg);
64 }
65 i++;
66 }
67}
68
Ed Tanousfffb8c12022-02-07 23:53:03 -080069} // namespace redfish::registries