00001 /* 00002 * WOscLib, an object oriented OSC library. 00003 * Copyright (C) 2005 Uli Clemens Franke, Weiss Engineering LTD, Switzerland. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 * 00019 * For details see lgpl.txt 00020 * 00021 * Weiss Engineering LTD. 00022 * Florastrass 42 00023 * 8610 Uster 00024 * Switzerland 00025 * 00026 * uli.franke@weiss.ch 00027 */ 00028 00029 /** WOscException header file. 00030 * \file 00031 * 00032 * $Author: cls-nebadje $ ( \ref _UcfWOscLib ) 00033 * $Date: 2009-01-13 17:23:19 $ 00034 * $Revision: 1.4 $ 00035 * 00036 * Copyright (c) Weiss Engineering Ltd 00037 * 00038 */ 00039 #ifndef __WOSCEXCEPTION_H__ 00040 #define __WOSCEXCEPTION_H__ 00041 00042 #include "WOscLib.h" 00043 #include <string> 00044 00045 /** The error codes of all exceptions which are thrown inside the Weiss OSC 00046 * Library. Refer to these defines when handling exceptions. 00047 */ 00048 enum ErrorCodes { 00049 ERR_NO_ERROR = 0, /**< No exception occurred (should not happen 00050 * when throwing exceptions). 00051 */ 00052 ERR_REMOVE_FROM_EMPTY_QUEUE, /**< Trying to remove items from an empty 00053 * priority queue. \see WOscPriorityQueue. 00054 */ 00055 ERR_INVALID_ADDRESS_NO_SLASH, /**< Trying to initialize a WOscMessage with 00056 * a corrupt address with missing slash at the 00057 * beginning. 00058 */ 00059 ERR_NOT_DISPATCHING_FROM_ROOT, /**< Messages can only be dispatched beginning 00060 * at a root container. 00061 * \see WOscContainer 00062 */ 00063 ERR_PARENT_POINTER_NULL, /**< During construction of a WOscContainer or WOscMethod a NULL pointer was passed 00064 * as parent or someone tried to add an OSC container alias (or an 00065 * OSC method/method-alias) with NULL pointer as parent. 00066 * \see WOscContainer. 00067 */ 00068 ERR_ROOT_ALIAS, /** The root container can not be added as alias to any container. 00069 * 00070 */ 00071 ERR_NULL_ADDRESS, /**< NULL-pointer argument passed to constructor 00072 * of WOscMessage. 00073 * \see WOscMessage::WOscMessage(const char *address) 00074 */ 00075 ERR_OSC_STR_BUFF_TOO_SMALL, /**< When using the getBuffer(char* buffer, int bufferLen) 00076 * functions (included in several classes) and the 00077 * passed buffer of length "bufferLen" is smaller than 00078 * the object-internal data-length, this exception will be 00079 * raised. 00080 * \see WOscMessage | WOscBundle | WOscString 00081 */ 00082 ERR_NULL_BUFFER, /**< When passed a null pointer to the constructor 00083 * of an OSC-message when constructing from a byte-stream. 00084 * \see WOscMessage::WOscMessage(char* buffer, int bufferLen) 00085 */ 00086 ERR_INVALID_INDEX, /**< When extracting bundle elements (messages or bundles) from 00087 * a WOscBundle object or arguments from a WOscMessage object, 00088 * make sure the "idx" parameter remains in valid boundaries by 00089 * getting the number of elements contained in the bundle. 00090 * \see WOscMessage WOscBundle::GetMessage(int idx) | 00091 * WOscBundle WOscBundle::GetBundle(int idx). | 00092 * WOscBundle::GetNumMessages() | WOscBundle::GetNumBundles() 00093 * WOscMessage::getFloat(int idx) | WOscMessage::getInt(int idx) | 00094 * WOscMessage::getString(int idx) | WOscMessage::getBlob(int idx) 00095 */ 00096 ERR_BUFFER_TO_SMALL, /**< When using the getBuffer(char* buffer, int bufferLen) 00097 * functions (included in several classes) and the 00098 * passed buffer of length "bufferLen" is smaller than 00099 * the object-internal data-length, this exception will be 00100 * raised. 00101 * \see WOscBundle | WOscBundle::getBuffer(char* buffer, int bufferLen) 00102 */ 00103 ERR_NOT_ROOT_CONTAINER, /**< Trying to set a not-root-conatiner as address-space. 00104 * \see WOscReceiver::setAddressSpace(WOscContainer* addrSpaceRootContainer) 00105 */ 00106 ERR_RECURSIVE_ALIAS, /**<\todo */ 00107 00108 ERR_TOO_SHORT, 00109 ERR_EMPTY_BUNDLE, 00110 ERR_INVALID_TAG, 00111 ERR_CURRUPT_BUNDLE_LAYOUT, 00112 ERR_NO_ITEMS_IN_BUNDLE, 00113 ERR_CAN_NOT_CLONE_UNINITIALIZED_BUNDLE, 00114 }; 00115 00116 /** Exceptions which occur inside the WOsc-Library. You should catch by const 00117 * reference. 00118 */ 00119 class WOSC_EXPORT WOscException{ 00120 00121 public: 00122 WOscException(ErrorCodes err, std::string file, int line) : 00123 m_err(err), m_file(file), m_line(line) { } 00124 virtual ~WOscException() { } 00125 ErrorCodes GetErr() const { return m_err; } 00126 static std::string GetErrStr(ErrorCodes err); 00127 std::string GetErrStr() const { return GetErrStr(m_err); } 00128 const std::string& GetFile() const { return m_file; } 00129 int GetLine() const { return m_line; } 00130 00131 private: 00132 WOscException(); 00133 /** Error number. Defines the reason why an exception was thrown.*/ 00134 ErrorCodes m_err; 00135 /** Source file. */ 00136 std::string m_file; 00137 /** Line in source file. */ 00138 int m_line; 00139 }; 00140 00141 #endif // #ifndef __WOSCEXCEPTION_H__