Fileseq C++ API
A library for parsing file sequence strings commonly used in VFX and animation applications.
error.h
1 #pragma clang diagnostic push
2 #pragma ide diagnostic ignored "google-explicit-constructor"
3 #pragma ide diagnostic ignored "modernize-use-equals-default"
4 #ifndef FILESEQ_ERROR_H_
5 #define FILESEQ_ERROR_H_
6 
7 #include <iostream>
8 #include <ostream>
9 #include <string>
10 
11 
12 #ifdef __GNUC__
13 #define DEPRECATED(func) func __attribute__ ((deprecated))
14 #elif defined(_MSC_VER)
15 #define DEPRECATED(func) __declspec(deprecated) func
16 #else
17 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
18 #define DEPRECATED(func) func
19 #endif
20 
21 
22 namespace fileseq {
23 
24 
31 class Status {
32 
33 public:
34  Status() = default;
35 
37  operator bool() const { return m_error.empty(); }
38 
40  operator std::string() const { return m_error; }
41 
42  Status(const Status& rhs) : m_error(rhs.m_error) {}
43 
44  Status& operator=(const Status& rhs) {
45  m_error = rhs.m_error;
46  return *this;
47  }
48 
49  void clearError() { m_error.clear(); }
50  void setError(const std::string &err) { m_error = err; }
51  void setError(const char* err) { m_error = err; }
52 
53  friend std::ostream& operator<< (std::ostream& stream, const Status& stat) {
54  stream << (std::string)stat;
55  return stream;
56  }
57 
58 private:
59  std::string m_error;
60 
61 };
62 
63 
64 namespace internal {
65 
66 void handleErrorStatus(const std::string &msg, Status* stat= nullptr);
67 
68 void setError(const std::string &msg, Status* stat);
69 
70 } // internal
71 
72 
73 } // fileseq
74 
75 #endif // FILESEQ_ERROR_H_
76 
77 
78 #pragma clang diagnostic pop
Definition: error.h:31