Loading...
Searching...
No Matches
diagnosticHelper.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_BASE_TF_DIAGNOSTIC_HELPER_H
25#define PXR_BASE_TF_DIAGNOSTIC_HELPER_H
26
27#include "pxr/pxr.h"
28#include "pxr/base/tf/api.h"
30#include "pxr/base/arch/defines.h"
31
32// XXX: This include is a hack to avoid build errors due to
33// incompatible macro definitions in pyport.h on macOS.
34#include <locale>
35
36#include <any>
37#include <string>
38
39// Follow up changes should more tightly scope these to just where it's needed
40// in pxr.
41#if defined(ARCH_OS_LINUX) || defined(ARCH_OS_DARWIN)
42// Include <unistd.h> to provide _exit for tf/debugger.cpp and dependencies
43// that were previously transitively getting this from boost
44#include <unistd.h>
45// Include <cstring> to provide memset, memcmp, and memcpy for dependencies
46// that were previously transitively getting them from boost
47#include <cstring>
48#endif
49
50PXR_NAMESPACE_OPEN_SCOPE
51
52typedef std::any TfDiagnosticInfo;
53class TfCallContext;
54enum TfDiagnosticType : int;
55class TfEnum;
56class TfError;
57
58TF_API void
59Tf_PostErrorHelper(
60 const TfCallContext &context,
61 const TfEnum &code,
62 const std::string &msg);
63
64TF_API void
65Tf_PostErrorHelper(
66 const TfCallContext &context,
68 const std::string &msg);
69
70TF_API void
71Tf_PostErrorHelper(
72 const TfCallContext &context,
73 const TfEnum &code,
74 const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
75
76TF_API void
77Tf_PostErrorHelper(
78 const TfCallContext &context,
80 const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
81
82TF_API void
83Tf_PostErrorHelper(
84 const TfCallContext &context,
85 const TfDiagnosticInfo &info,
86 const TfEnum &code,
87 const std::string &msg);
88
89TF_API void
90Tf_PostErrorHelper(
91 const TfCallContext &context,
92 const TfDiagnosticInfo &info,
93 const TfEnum &code,
94 const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
95
96TF_API void
97Tf_PostQuietlyErrorHelper(
98 const TfCallContext &context,
99 const TfEnum &code,
100 const TfDiagnosticInfo &info,
101 const std::string &msg);
102
103TF_API void
104Tf_PostQuietlyErrorHelper(
105 const TfCallContext &context,
106 const TfEnum &code,
107 const TfDiagnosticInfo &info,
108 const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
109
110TF_API void
111Tf_PostQuietlyErrorHelper(
112 const TfCallContext &context,
113 const TfEnum &code,
114 const std::string &msg);
115
116TF_API void
117Tf_PostQuietlyErrorHelper(
118 const TfCallContext &context,
119 const TfEnum &code,
120 const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
121
122
123// Helper functions for posting a warning with TF_WARN.
124TF_API void
125Tf_PostWarningHelper(const TfCallContext &context,
126 const std::string &msg);
127
128TF_API void
129Tf_PostWarningHelper(const TfCallContext &context,
130 const char *fmt, ...) ARCH_PRINTF_FUNCTION(2, 3);
131
132TF_API void
133Tf_PostWarningHelper(
134 const TfCallContext &context,
135 const TfEnum &code,
136 const std::string &msg);
137
138TF_API void
139Tf_PostWarningHelper(
140 const TfCallContext &context,
141 TfDiagnosticType code,
142 const std::string &msg);
143
144TF_API void
145Tf_PostWarningHelper(
146 const TfCallContext &context,
147 const TfEnum &code,
148 const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
149
150TF_API void
151Tf_PostWarningHelper(
152 const TfCallContext &context,
153 TfDiagnosticType code,
154 const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
155
156TF_API void
157Tf_PostWarningHelper(
158 const TfCallContext &context,
159 const TfDiagnosticInfo &info,
160 const TfEnum &code,
161 const std::string &msg);
162
163TF_API void
164Tf_PostWarningHelper(
165 const TfCallContext &context,
166 const TfDiagnosticInfo &info,
167 const TfEnum &code,
168 const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
169
170TF_API void
171Tf_PostStatusHelper(
172 const TfCallContext &context,
173 const char *fmt, ...) ARCH_PRINTF_FUNCTION(2, 3);
174
175TF_API void
176Tf_PostStatusHelper(
177 const TfCallContext &context,
178 const std::string &msg);
179
180
181TF_API void
182Tf_PostStatusHelper(
183 const TfCallContext &context,
184 const TfEnum &code,
185 const std::string &msg);
186
187TF_API void
188Tf_PostStatusHelper(
189 const TfCallContext &context,
190 const TfEnum &code,
191 const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
192
193TF_API void
194Tf_PostStatusHelper(
195 const TfCallContext &context,
196 const TfDiagnosticInfo &info,
197 const TfEnum &code,
198 const std::string &msg);
199
200TF_API void
201Tf_PostStatusHelper(
202 const TfCallContext &context,
203 const TfDiagnosticInfo &info,
204 const TfEnum &code,
205 const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
206
207PXR_NAMESPACE_CLOSE_SCOPE
208
209#endif // PXR_BASE_TF_DIAGNOSTIC_HELPER_H
Define function attributes.
#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
Macro used to indicate a function takes a printf-like specification.
Definition: attributes.h:51
An enum class that records both enum type and enum value.
Definition: enum.h:137
Represents an object that contains error information.
Definition: error.h:49
TfDiagnosticType
Enum describing various diagnostic conditions.
STL namespace.