* Add Variadic arguments to THROW_* macros

This commit is contained in:
2014-05-30 17:40:35 -07:00
parent 32f5b9cc03
commit 05db171ac4
9 changed files with 60 additions and 66 deletions

View File

@@ -17,6 +17,8 @@
#define __EXCEPTION_HPP__
#include <string>
#include <stdarg.h>
#include "Athena/Utility.hpp"
#define __STRX(x) #x
#define __STR(x) __STRX(x)
@@ -76,7 +78,10 @@ protected:
};
} // error
} // Athena
#define THROW_EXCEPTION(msg) \
do { throw Athena::error::Exception("Exception: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#define THROW_EXCEPTION(args...) \
do { \
std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while(0)
#endif

View File

@@ -47,7 +47,9 @@ public:
} // error
} // Athena
#define THROW_IO_EXCEPTION(msg) \
do { throw Athena::error::IOException("IOException: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#define THROW_IO_EXCEPTION(args...) \
do { \
std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::IOException(std::string("IOException: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while(0)
#endif

View File

@@ -43,7 +43,10 @@ public:
} // error
} // Athena
#define THROW_INVALID_DATA_EXCEPTION(msg) \
do { throw Athena::error::InvalidDataException("InvalidDataException: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#define THROW_INVALID_DATA_EXCEPTION(args...) \
do { \
std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::InvalidDataException(std::string("InvalidDataException: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while(0)
#endif // INVALIDDATAEXCEPTION_HPP

View File

@@ -17,6 +17,7 @@
#define __INVALID_OPERATION_EXCEPTION_HPP__
#include <string>
#include <stdarg.h>
#include "Exception.hpp"
namespace Athena
@@ -46,7 +47,9 @@ public:
} // error
} // Athena
#define THROW_INVALID_OPERATION_EXCEPTION(msg) \
do { throw Athena::error::InvalidOperationException("InvalidOperationException: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#define THROW_INVALID_OPERATION_EXCEPTION(args...) \
do { \
std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::InvalidOperationException(std::string("InvalidOperationException: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \
} while(0)
#endif // __INVALID_OPERATION_EXCEPTION_HPP__

View File

@@ -19,6 +19,7 @@
#include <string>
#include <vector>
#include <stdarg.h>
#include "Types.hpp"
namespace Athena
@@ -45,7 +46,8 @@ std::vector<std::string> split(const std::string &s, char delim);
std::string join(const std::vector<std::string>& elems, const std::string& delims);
void tolower(std::string& str);
void toupper(std::string& str);
std::string stdsprintf(const char* fmt, ...);
std::string vsprintf(const char* fmt, va_list list);
std::string sprintf(const char* fmt, ...);
bool parseBool(const std::string& boolean, bool* valid = NULL);
int countChar(const std::string& str, const char chr, int* lastOccur = NULL);

View File

@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _LZO_H
#ifndef LZO_H
#define LZO_H
#include "Athena/Types.hpp"