Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
pencilerror.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2017 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 #ifndef PENCILERROR_H
19 #define PENCILERROR_H
20 
21 #include <QString>
22 #include <QStringList>
23 
24 class Status
25 {
26 public:
27  enum ErrorCode
28  {
29  OK = 0,
30  SAFE,
31  FAIL,
32  CANCELED,
33  FILE_NOT_FOUND,
34  NOT_SUPPORTED,
35  INVALID_ARGUMENT,
36  NOT_IMPLEMENTED_YET,
37 
38  // for Object loading
39  ERROR_FILE_CANNOT_OPEN,
40  ERROR_INVALID_XML_FILE,
41  ERROR_INVALID_PENCIL_FILE,
42 
43  // General
44  ERROR_INVALID_LAYER_TYPE,
45  ERROR_INVALID_FRAME_NUMBER,
46  ERROR_LOAD_IMAGE_FAIL,
47 
48  // Sound
49  ERROR_LOAD_SOUND_FILE,
50 
51  // Export
52  ERROR_FFMPEG_NOT_FOUND,
53  };
54 
55 
56  Status() {}
57  Status( ErrorCode eCode, QStringList detailsList = QStringList(), QString title = QString(), QString description = QString() );
58 
59  ErrorCode code() { return mCode; }
60  bool ok() const { return ( mCode == OK ) || ( mCode == SAFE ); }
61  QString msg();
62  QString title() { return !mTitle.isEmpty() ? mTitle : msg(); }
63  QString description() { return mDescription; }
64  QString details();
65  QStringList detailsList() { return mDetails; }
66 
67  void setTitle( QString title ) { mTitle = title; }
68  void setDescription( QString description ) { mDescription = description; }
69  void setDetailsList( QStringList detailsList ) { mDetails = detailsList; }
70 
71  bool operator==( ErrorCode code );
72 
73 private:
74  ErrorCode mCode = OK;
75  QString mTitle, mDescription;
76  QStringList mDetails;
77 };
78 
79 #ifndef STATUS_CHECK
80 #define STATUS_CHECK( x )\
81  { Status st = (x); if ( !st.ok() ) { return st; } }
82 #endif
83 #endif // PENCILERROR_H