Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:43:50

0001 #ifndef FILE_EXCEPTION_TYPE_H
0002 #define FILE_EXCEPTION_TYPE_H
0003 
0004 /**
0005  * @file FileExceptionType.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date 15 September 2014
0008  * @version 1.0
0009  *
0010  * Last update : 15 September 2014
0011  */
0012 
0013 #include <string>
0014 
0015 namespace ElemUtils {
0016 
0017 //TODO refactoring
0018 
0019 /**
0020  * @struct FileExceptionType
0021  *
0022  * @brief
0023  */
0024 struct FileExceptionType {
0025     //prevent automatic conversion for any other built-in types such as bool, int, etc
0026     template<typename T>
0027     operator T() const;
0028 
0029 public:
0030     enum Type {
0031         DEFAULT, UNREADABLE
0032     };
0033     Type t_;
0034     FileExceptionType(Type t) :
0035             t_(t) {
0036     }
0037     operator Type() const {
0038         return t_;
0039     }
0040 
0041     std::string toString() {
0042         switch (t_) {
0043         case UNREADABLE:
0044             return "UNREADABLE";
0045             break;
0046         default:
0047             return "default";
0048         }
0049     }
0050 
0051     static FileExceptionType fromString(const std::string &type) {
0052         if (type == "UNREADABLE") {
0053             return UNREADABLE;
0054         }
0055 
0056         return DEFAULT;
0057     }
0058 };
0059 
0060 } // namespace ElemUtils
0061 
0062 #endif /* FILE_EXCEPTION_TYPE_H */