1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef CSV_CSV_ENV_HXX 29 #define CSV_CSV_ENV_HXX 30 31 32 33 //******* Include c-language-types ************// 34 // size_t, wchar_t 35 #include <stdlib.h> 36 37 38 39 //******* Builtin types of exact length ************// 40 41 // Exact length builtin types 42 typedef signed char INT8; 43 typedef unsigned char UINT8; 44 typedef short INT16; 45 typedef unsigned short UINT16; 46 typedef long INT32; 47 typedef unsigned long UINT32; 48 typedef float REAL32; 49 typedef double REAL64; 50 51 52 // Additional builtin types 53 typedef INT32 intt; // standard sized integer. 54 typedef UINT32 uintt; // standard sized unsigned integer. 55 typedef REAL64 real; // standard sized real. 56 57 // Constants 58 // --------- 59 // Zero-pointer for use in ellipsed (...) parameter lists which expect a 60 // pointer which may have another size than an int. 61 // Must be a define to be used in precompiled headers: 62 #define NIL ((void*)0) 63 // char '\0' 64 #define NULCH '\0' 65 66 67 68 // Boolesche Operatoren 69 #define AND && 70 #define OR || 71 #define NOT ! 72 73 // Macro for distinguishing dynamic allocated pointers from 74 // referencing pointers 75 #define DYN // Exact specification: DYN has to be used if and only if: 76 // 1. DYN specifies a class member pointer or reference variable and 77 // the class must free the referenced memory. 78 // 2. DYN specifies a pointer or reference (return-) parameter of a function 79 // and for in-parameters the function or its class 80 // must free the referenced memory, the parameter is then called 81 // a let-parameter. 82 // For out- and inout-parameters 83 // or return values the caller of the function hast to 84 // free the referenced memory. 85 // 86 // It is irrelevant who allocated the memory! 87 // 88 // DYN - variables use the prefixes "dp" or "dr" instead of "p" or "r". 89 90 91 //****** Assertions ******// 92 93 namespace csv 94 { 95 void PerformAssertion( 96 const char * condition, 97 const char * file, 98 unsigned line ); 99 } 100 101 // Programming by contract 102 #ifndef CSV_NO_ASSERTIONS 103 104 #ifdef CSV_USE_CSV_ASSERTIONS 105 #define csv_assert(x) ( (x) ? (void)(0) : ::csv::PerformAssertion( #x, __FILE__, __LINE__) ) 106 #else 107 108 // Save NDEBUG state 109 #ifdef NDEBUG 110 #define CSV_CSV_ENV_HXX_HAD_NDEBUG 111 #undef NDEBUG 112 #endif 113 114 #if OSL_DEBUG_LEVEL == 0 115 #define NDEBUG 116 #endif 117 #include <assert.h> 118 119 #define csv_assert(x) assert(x); 120 121 // Restore NDEBUG state 122 #ifdef CSV_CSV_ENV_HXX_HAD_NDEBUG 123 #define NDEBUG 124 #else 125 #undef NDEBUG 126 #endif 127 128 #endif 129 130 #else // #ifndef CSV_NO_ASSERTIONS else 131 132 #define csv_assert(x) 133 134 #endif // end ifndef CSV_NO_ASSERTIONS else 135 136 137 138 /* Additional Programming Conventions 139 140 1. see above at "#define DYN" 141 2. function parameters get one of these prefixes: 142 - i_ := Function uses only the value, but must not change a referenced variable. 143 - o_ := Parameter is undefined until function has set it. 144 Parametere must be set by the function. 145 - io_ := Function may use and change the referenced variable. 146 - pass_ := Funktion may use and change the referenced variable and HAS TO free the 147 associated memory. 148 3. Global constants get the prefix 'C_', global variables the prefix 'G_'. 149 4. Static members end with an underscore '_'. 150 151 */ 152 153 154 #endif 155