blob: f85d2a58f7d81c9483125784d9fe7e2800670ff3 [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
18#include <span>
19#include <string>
20#include <string_view>
21
Jason M. Bills70304cb2019-03-27 12:03:59 -070022namespace redfish::message_registries
23{
Jason M. Bills351d3062019-03-27 12:58:21 -070024struct 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. Bills70304cb2019-03-27 12:03:59 -070036
37struct Message
38{
39 const char* description;
40 const char* message;
41 const char* severity;
Gunnar Millse7808c92020-07-08 21:17:44 -050042 const char* messageSeverity;
Ed Tanous271584a2019-07-09 16:24:22 -070043 const size_t numberOfArgs;
Jason M. Bills70304cb2019-03-27 12:03:59 -070044 std::array<const char*, 5> paramTypes;
45 const char* resolution;
46};
47using MessageEntry = std::pair<const char*, const Message>;
Ed Tanousc5ba4c22022-02-07 09:59:55 -080048
49inline void fillMessageArgs(const std::span<const std::string_view> messageArgs,
50 std::string& msg)
51{
52 int i = 0;
53 for (const std::string_view& messageArg : messageArgs)
54 {
55 std::string argStr = "%" + std::to_string(i + 1);
56 size_t argPos = msg.find(argStr);
57 if (argPos != std::string::npos)
58 {
59 msg.replace(argPos, argStr.length(), messageArg);
60 }
61 i++;
62 }
63}
64
Jason M. Bills70304cb2019-03-27 12:03:59 -070065} // namespace redfish::message_registries