1 #ifndef MUP_DEFINES_H 2 #define MUP_DEFINES_H 3 4 /** \file 5 \brief A file containing macros used by muParserX 6 7 <pre> 8 __________ ____ ___ 9 _____ __ _\______ \_____ _______ ______ __________\ \/ / 10 / \| | \ ___/\__ \\_ __ \/ ___// __ \_ __ \ / 11 | Y Y \ | / | / __ \| | \/\___ \\ ___/| | \/ \ 12 |__|_| /____/|____| (____ /__| /____ >\___ >__| /___/\ \ 13 \/ \/ \/ \/ \_/ 14 Copyright (C) 2021 Ingo Berg, et. al. 15 All rights reserved. 16 17 Redistribution and use in source and binary forms, with or without 18 modification, are permitted provided that the following conditions are met: 19 20 * Redistributions of source code must retain the above copyright notice, 21 this list of conditions and the following disclaimer. 22 * Redistributions in binary form must reproduce the above copyright notice, 23 this list of conditions and the following disclaimer in the documentation 24 and/or other materials provided with the distribution. 25 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 27 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 28 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 30 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 32 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 33 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 POSSIBILITY OF SUCH DAMAGE. 36 </pre> 37 */ 38 #include <cassert> 39 40 #if defined(_UNICODE) 41 #if !defined(_T) 42 #define _T(x) L##x 43 #endif // not defined _T 44 #define MUP_STRING_TYPE std::wstring 45 #else 46 #ifndef _T 47 /** \brief Macro needed for the "unicodification" of strings. */ 48 #define _T(x) x 49 #endif 50 51 /** \brief The string type used by muParserX. 52 53 This macro is needed for UNICODE support. 54 */ 55 #define MUP_STRING_TYPE std::string 56 #endif 57 58 /** \brief A macro containing the version of muParserX. */ 59 #define MUP_PARSER_VERSION _T("4.0.11 (2021-11-23)") 60 61 /** \brief A macro for setting the parser namespace. */ 62 #define MUP_NAMESPACE_START namespace mup { 63 64 /** \brief Closing bracket for the parser namespace macro. */ 65 #define MUP_NAMESPACE_END } 66 67 /** \brief Floating point type used by the parser. */ 68 #define MUP_FLOAT_TYPE double 69 70 #define MUP_INT_TYPE int64_t 71 72 /** \brief Verifies whether a given condition is met. 73 74 If the condition is not met an exception is thrown otherwise nothing happens. 75 This macro is used for implementing asserts. Unlike MUP_ASSERT, MUP_VERIFY 76 will not be removed in release builds. 77 */ 78 #define MUP_VERIFY(COND) \ 79 if (!(COND)) \ 80 { \ 81 stringstream_type ss; \ 82 ss << _T("Assertion \"") _T(#COND) _T("\" failed: ") \ 83 << __FILE__ << _T(" line ") \ 84 << __LINE__ << _T("."); \ 85 throw ParserError( ss.str() ); \ 86 } 87 88 #if defined(_DEBUG) 89 #define MUP_TOK_CAST(TYPE, POINTER) dynamic_cast<TYPE>(POINTER); 90 91 /** \brief Debug macro to force an abortion of the programm with a certain message. 92 */ 93 #define MUP_FAIL(MSG) \ 94 bool MSG=false; \ 95 assert(MSG); 96 97 #define MUP_LEAKAGE_REPORT 98 #else 99 #define MUP_FAIL(MSG) 100 #define MUP_TOK_CAST(TYPE, POINTER) static_cast<TYPE>(POINTER); 101 #endif 102 103 #endif 104 105 106