All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 TF_DIAGNOSTIC_HELPER_H
25 #define TF_DIAGNOSTIC_HELPER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/tf/api.h"
29 #include "pxr/base/arch/attributes.h"
30 
31 // XXX: This include is a hack to avoid build errors due to
32 // incompatible macro definitions in pyport.h on macOS.
33 #include <locale>
34 
35 #include <boost/any.hpp>
36 #include <string>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 typedef boost::any TfDiagnosticInfo;
41 class TfCallContext;
42 enum TfDiagnosticType : int;
43 class TfEnum;
44 class TfError;
45 
46 TF_API bool
47 Tf_PostErrorHelper(
48  const TfCallContext &context,
49  const TfEnum &code,
50  const std::string &msg);
51 
52 TF_API bool
53 Tf_PostErrorHelper(
54  const TfCallContext &context,
55  TfDiagnosticType code,
56  const std::string &msg);
57 
58 TF_API bool
59 Tf_PostErrorHelper(
60  const TfCallContext &context,
61  const TfEnum &code,
62  const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
63 
64 TF_API bool
65 Tf_PostErrorHelper(
66  const TfCallContext &context,
67  TfDiagnosticType code,
68  const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
69 
70 TF_API bool
71 Tf_PostErrorHelper(
72  const TfCallContext &context,
73  const TfDiagnosticInfo &info,
74  const TfEnum &code,
75  const std::string &msg);
76 
77 TF_API bool
78 Tf_PostErrorHelper(
79  const TfCallContext &context,
80  const TfDiagnosticInfo &info,
81  const TfEnum &code,
82  const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
83 
84 TF_API bool
85 Tf_PostQuietlyErrorHelper(
86  const TfCallContext &context,
87  const TfEnum &code,
88  const TfDiagnosticInfo &info,
89  const std::string &msg);
90 
91 TF_API bool
92 Tf_PostQuietlyErrorHelper(
93  const TfCallContext &context,
94  const TfEnum &code,
95  const TfDiagnosticInfo &info,
96  const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
97 
98 TF_API bool
99 Tf_PostQuietlyErrorHelper(
100  const TfCallContext &context,
101  const TfEnum &code,
102  const std::string &msg);
103 
104 TF_API bool
105 Tf_PostQuietlyErrorHelper(
106  const TfCallContext &context,
107  const TfEnum &code,
108  const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
109 
110 
111 // Helper functions for posting a warning with TF_WARN.
112 TF_API void
113 Tf_PostWarningHelper(const TfCallContext &context,
114  const std::string &msg);
115 
116 TF_API void
117 Tf_PostWarningHelper(const TfCallContext &context,
118  const char *fmt, ...) ARCH_PRINTF_FUNCTION(2, 3);
119 
120 TF_API void
121 Tf_PostWarningHelper(
122  const TfCallContext &context,
123  const TfEnum &code,
124  const std::string &msg);
125 
126 TF_API void
127 Tf_PostWarningHelper(
128  const TfCallContext &context,
129  TfDiagnosticType code,
130  const std::string &msg);
131 
132 TF_API void
133 Tf_PostWarningHelper(
134  const TfCallContext &context,
135  const TfEnum &code,
136  const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
137 
138 TF_API void
139 Tf_PostWarningHelper(
140  const TfCallContext &context,
141  TfDiagnosticType code,
142  const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
143 
144 TF_API void
145 Tf_PostWarningHelper(
146  const TfCallContext &context,
147  const TfDiagnosticInfo &info,
148  const TfEnum &code,
149  const std::string &msg);
150 
151 TF_API void
152 Tf_PostWarningHelper(
153  const TfCallContext &context,
154  const TfDiagnosticInfo &info,
155  const TfEnum &code,
156  const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
157 
158 TF_API void
159 Tf_PostStatusHelper(
160  const TfCallContext &context,
161  const char *fmt, ...) ARCH_PRINTF_FUNCTION(2, 3);
162 
163 TF_API void
164 Tf_PostStatusHelper(
165  const TfCallContext &context,
166  const std::string &msg);
167 
168 
169 TF_API void
170 Tf_PostStatusHelper(
171  const TfCallContext &context,
172  const TfEnum &code,
173  const std::string &msg);
174 
175 TF_API void
176 Tf_PostStatusHelper(
177  const TfCallContext &context,
178  const TfEnum &code,
179  const char *fmt, ...) ARCH_PRINTF_FUNCTION(3, 4);
180 
181 TF_API void
182 Tf_PostStatusHelper(
183  const TfCallContext &context,
184  const TfDiagnosticInfo &info,
185  const TfEnum &code,
186  const std::string &msg);
187 
188 TF_API void
189 Tf_PostStatusHelper(
190  const TfCallContext &context,
191  const TfDiagnosticInfo &info,
192  const TfEnum &code,
193  const char *fmt, ...) ARCH_PRINTF_FUNCTION(4, 5);
194 
195 PXR_NAMESPACE_CLOSE_SCOPE
196 
197 #endif // TF_DIAGNOSTIC_HELPER_H
An enum class that records both enum type and enum value.
Definition: enum.h:140
#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
Macro used to indicate a function takes a printf-like specification.
Definition: attributes.h:51
TfDiagnosticType
Enum describing various diagnostic conditions.
Represents an object that contains error information.
Definition: error.h:49