From 6cfdbf44cce0b0881d1811e7ec06c4e79e637c96 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 12 Apr 2009 17:06:48 +0000 Subject: Write C++ error handling wrapper. --- libdimension/dimension/error.h | 2 -- libdimensionxx/Makefile.am | 2 +- libdimensionxx/dimensionxx/error.hpp | 8 ++++++++ libdimensionxx/error.cpp | 36 ++++++++++++++++++++++++++++++++++++ libdimensionxx/geometry.cpp | 21 --------------------- tests/pngxx.cpp | 2 +- 6 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 libdimensionxx/error.cpp delete mode 100644 libdimensionxx/geometry.cpp diff --git a/libdimension/dimension/error.h b/libdimension/dimension/error.h index 9fdfdd8..2c00a4a 100644 --- a/libdimension/dimension/error.h +++ b/libdimension/dimension/error.h @@ -25,8 +25,6 @@ #ifndef DIMENSION_ERROR_H #define DIMENSION_ERROR_H -/* Debug and error handling stuff */ - typedef enum { DMNSN_SEVERITY_LOW, /* Only die on low resilience */ DMNSN_SEVERITY_MEDIUM, /* Die on low or medium resilience */ diff --git a/libdimensionxx/Makefile.am b/libdimensionxx/Makefile.am index da8f544..143ab83 100644 --- a/libdimensionxx/Makefile.am +++ b/libdimensionxx/Makefile.am @@ -23,6 +23,6 @@ INCLUDES = -I../libdimension -I../libdimension-png lib_LTLIBRARIES = libdimensionxx.la -libdimensionxx_la_SOURCES = $(nobase_include_HEADERS) canvas.cpp color.cpp cookie.cpp geometry.cpp png.cpp +libdimensionxx_la_SOURCES = $(nobase_include_HEADERS) canvas.cpp color.cpp cookie.cpp error.cpp png.cpp libdimensionxx_la_LDFLAGS = -version-info 0:0:0 libdimensionxx_la_LIBADD = ../libdimension/libdimension.la ../libdimension-png/libdimension-png.la diff --git a/libdimensionxx/dimensionxx/error.hpp b/libdimensionxx/dimensionxx/error.hpp index a6a4ca6..072949f 100644 --- a/libdimensionxx/dimensionxx/error.hpp +++ b/libdimensionxx/dimensionxx/error.hpp @@ -25,6 +25,14 @@ namespace Dimension { + enum Severity { + SEVERITY_LOW = DMNSN_SEVERITY_LOW, + SEVERITY_MEDIUM = DMNSN_SEVERITY_MEDIUM, + SEVERITY_HIGH = DMNSN_SEVERITY_HIGH + }; + + Severity resilience(); + void resilience(Severity resilience); } #endif /* DIMENSIONXX_ERROR_HPP */ diff --git a/libdimensionxx/error.cpp b/libdimensionxx/error.cpp new file mode 100644 index 0000000..fce453e --- /dev/null +++ b/libdimensionxx/error.cpp @@ -0,0 +1,36 @@ +/************************************************************************* + * Copyright (C) 2008 Tavian Barnes * + * * + * This file is part of The Dimension Library. * + * * + * The Dimension Library is free software; you can redistribute it and/ * + * or modify it under the terms of the GNU Lesser General Public License * + * as published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * The Dimension Library is distributed in the hope that it will be * + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this program. If not, see * + * . * + *************************************************************************/ + +#include "dimensionxx.hpp" + +namespace Dimension +{ + Severity + resilience() + { + return static_cast(dmnsn_get_resilience()); + } + + void + resilience(Severity resilience) + { + dmnsn_set_resilience(static_cast(resilience)); + } +} diff --git a/libdimensionxx/geometry.cpp b/libdimensionxx/geometry.cpp deleted file mode 100644 index 8b90fe9..0000000 --- a/libdimensionxx/geometry.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/************************************************************************* - * Copyright (C) 2008 Tavian Barnes * - * * - * This file is part of The Dimension Library. * - * * - * The Dimension Library is free software; you can redistribute it and/ * - * or modify it under the terms of the GNU Lesser General Public License * - * as published by the Free Software Foundation; either version 3 of the * - * License, or (at your option) any later version. * - * * - * The Dimension Library is distributed in the hope that it will be * - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with this program. If not, see * - * . * - *************************************************************************/ - -#include "dimensionxx.hpp" diff --git a/tests/pngxx.cpp b/tests/pngxx.cpp index ed7cffd..8dc79b2 100644 --- a/tests/pngxx.cpp +++ b/tests/pngxx.cpp @@ -24,7 +24,7 @@ int main() { - dmnsn_set_resilience(DMNSN_SEVERITY_LOW); + Dimension::resilience(Dimension::SEVERITY_LOW); const unsigned int width = 333, height = 300; -- cgit v1.2.3