HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VEX_Error.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: VEX_Error.h ( VEX Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __VEX_Error__
12 #define __VEX_Error__
13 
14 #include "VEX_API.h"
15 #include <UT/UT_NonCopyable.h>
16 #include <UT/UT_StringArray.h>
17 #include <SYS/SYS_Types.h>
18 #include <stdarg.h>
19 
20 class VEX_ErrorList;
21 
22 // Pure virtual interface for accumulating error information
24 {
25 public:
26  VEX_ErrorLog() = default;
27  virtual ~VEX_ErrorLog() {}
29 
30  void error(const char *fmt, ...)
32  void warning(const char *fmt, ...)
33  SYS_PRINTF_CHECK_ATTRIBUTE(2,3);
34 
35  void error(const char *fmt, va_list args);
36  void warning(const char *fmt, va_list args);
37 
38  void mergeFrom(const VEX_ErrorList &list);
39 
40 protected:
41  virtual void addError(const char *msg) = 0;
42  virtual void addWarning(const char *msg) = 0;
43 };
44 
45 // Print errors to the console
47 public:
49 
50 protected:
51  void addError(const char *msg) override;
52  void addWarning(const char *msg) override;
53 };
54 
55 // Accumulate errors into lists
57 public:
58  const UT_StringArray &errors() const { return myErrors; }
59  const UT_StringArray &warnings() const { return myWarnings; }
60 
61 protected:
62  void addError(const char *msg) override;
63  void addWarning(const char *msg) override;
64 
65 private:
66  UT_StringArray myErrors;
67  UT_StringArray myWarnings;
68 };
69 
70 // Accumulate errors into a single string
72 public:
73  const UT_String &errors() const { return myErrors; }
74  const UT_String &warnings() const { return myWarnings; }
75 
76  void clear();
77 
78 protected:
79  void addError(const char *msg) override;
80  void addWarning(const char *msg) override;
81 
82 private:
83  UT_String myErrors;
84  UT_String myWarnings;
85 };
86 
87 #endif
88 
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
void
Definition: png.h:1083
virtual void addError(const char *msg)=0
const UT_String & warnings() const
Definition: VEX_Error.h:74
const UT_StringArray & warnings() const
Definition: VEX_Error.h:59
virtual void addWarning(const char *msg)=0
#define VEX_API
Definition: VEX_API.h:14
const UT_String & errors() const
Definition: VEX_Error.h:73
< returns > If no error
Definition: snippets.dox:2
const UT_StringArray & errors() const
Definition: VEX_Error.h:58
#define SYS_PRINTF_CHECK_ATTRIBUTE(string_index, first_to_check)
Definition: SYS_Types.h:447
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
**If you just want to fire and args
Definition: thread.h:609
#define const
Definition: zconf.h:214
virtual ~VEX_ErrorLog()
Definition: VEX_Error.h:27