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