summaryrefslogtreecommitdiff
path: root/include/cosv/csv_env.hxx
blob: f49ed54ea4649f4b6c4692787f70897f96b6a916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef CSV_CSV_ENV_HXX
#define CSV_CSV_ENV_HXX



//*******       Include c-language-types        ************//
// size_t, wchar_t
#include <stdlib.h>



//*******       Builtin types of exact length        ************//

// Exact length builtin types
typedef signed char     INT8;
typedef unsigned char   UINT8;
typedef short           INT16;
typedef unsigned short  UINT16;
typedef long            INT32;
typedef unsigned long   UINT32;
typedef float           REAL32;
typedef double          REAL64;


// Additional builtin types
typedef INT32        intt;      // standard sized integer.
typedef UINT32       uintt;     // standard sized unsigned integer.
typedef REAL64       real;      // standard sized real.

//  Constants
//  ---------
// Zero-pointer for use in ellipsed (...) parameter lists which expect a
//   pointer which may have another size than an int.
//   Must be a define to be used in precompiled headers:
#define NIL   ((void*)0)
// char '\0'
#define NULCH '\0'



// Boolesche Operatoren
#define AND &&
#define OR  ||
#define NOT !

// Macro for distinguishing dynamic allocated pointers from
//   referencing pointers
#define DYN     // Exact specification: DYN has to be used if and only if:
                //  1. DYN specifies a class member pointer or reference variable and
                //     the class must free the referenced memory.
                //  2. DYN specifies a pointer or reference (return-) parameter of a function
                //     and for in-parameters the function or its class
                //     must free the referenced memory, the parameter is then called
                //     a let-parameter.
                //     For out- and inout-parameters
                //     or return values the caller of the function hast to
                //     free the referenced memory.
                //
                //     It is irrelevant who allocated the memory!
                //
                //     DYN - variables use the prefixes "dp" or "dr" instead of "p" or "r".


//******        Assertions          ******//

namespace csv
{
void                PerformAssertion(
                        const char *        condition,
                        const char *        file,
                        unsigned            line );
}

// Programming by contract
#ifndef CSV_NO_ASSERTIONS

#ifdef CSV_USE_CSV_ASSERTIONS
#define csv_assert(x)       ( (x) ? (void)(0) : ::csv::PerformAssertion( #x, __FILE__, __LINE__) )
#else

// Save NDEBUG state
#ifdef NDEBUG
#define CSV_CSV_ENV_HXX_HAD_NDEBUG
#undef NDEBUG
#endif

#if OSL_DEBUG_LEVEL == 0
#define NDEBUG
#endif
#include <assert.h>

#define csv_assert(x)       assert(x);

// Restore NDEBUG state
#ifdef CSV_CSV_ENV_HXX_HAD_NDEBUG
#define NDEBUG
#else
#undef NDEBUG
#endif

#endif

#else // #ifndef CSV_NO_ASSERTIONS else

#define csv_assert(x)

#endif  // end ifndef CSV_NO_ASSERTIONS else



/* Additional Programming Conventions

1. see above at "#define DYN"
2. function parameters get one of these prefixes:
    - i_     := Function uses only the value, but must not change a referenced variable.
    - o_     := Parameter is undefined until function has set it.
                Parametere must be set by the function.
    - io_    := Function may use and change the referenced variable.
    - pass_  := Funktion may use and change the referenced variable and HAS TO free the
                associated memory.
3. Global constants get the prefix 'C_', global variables the prefix 'G_'.
4. Static members end with an underscore '_'.

*/


#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */