00001 /// @file include/dmlite/cpp/status.h 00002 /// @brief Status objects used by the API 00003 /// @author Georgios Bitzes <georgios.bitzes@cern.ch> 00004 #ifndef DMLITE_CPP_STATUS_H 00005 #define DMLITE_CPP_STATUS_H 00006 00007 #include "dmlite/common/config.h" 00008 #include "dmlite/common/errno.h" 00009 #include "exceptions.h" 00010 00011 #include <cstdarg> 00012 #include <exception> 00013 #include <string> 00014 00015 namespace dmlite { 00016 00017 class DmStatus { 00018 public: 00019 DmStatus(); 00020 DmStatus(int code); 00021 DmStatus(int code, const std::string &string); 00022 DmStatus(int code, const char* fmt, va_list args); 00023 DmStatus(int code, const char* fmt, ...); 00024 00025 DmStatus(const DmStatus &de); 00026 DmStatus(const DmException &de); 00027 00028 virtual ~DmStatus() throw(); 00029 00030 int code() const throw(); 00031 const char* what() const throw(); 00032 00033 bool ok() const throw(); 00034 DmException exception() const throw(); 00035 00036 protected: 00037 int errorCode_; 00038 std::string errorMsg_; 00039 00040 void setMessage(const char* fmt, va_list args); 00041 }; 00042 00043 }; 00044 #endif // DMLITE_CPP_STATUS_H