/usr/include/firebird/Message.h is in firebird-dev 3.0.2.32703.ds4-11ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | /*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.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.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* Software distributed under the License is distributed AS IS,
* WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights
* and limitations under the License.
*
* The Original Code was created by Adriano dos Santos Fernandes
* for the Firebird Open Source RDBMS project.
*
* Copyright (c) 2011 Adriano dos Santos Fernandes <adrianosf@uol.com.br>
* and all contributors signed below.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
#ifndef FIREBIRD_MESSAGE_H
#define FIREBIRD_MESSAGE_H
#include "ibase.h"
#include "./Interface.h"
#include <boost/preprocessor/seq/for_each_i.hpp>
#include <assert.h>
#include <string.h>
#define FB_MESSAGE(name, statusType, fields) \
FB__MESSAGE_I(name, statusType, 2, BOOST_PP_CAT(FB__MESSAGE_X fields, 0), )
#define FB__MESSAGE_X(x, y) ((x, y)) FB__MESSAGE_Y
#define FB__MESSAGE_Y(x, y) ((x, y)) FB__MESSAGE_X
#define FB__MESSAGE_X0
#define FB__MESSAGE_Y0
#define FB_TRIGGER_MESSAGE(name, statusType, fields) \
FB__MESSAGE_I(name, statusType, 3, BOOST_PP_CAT(FB_TRIGGER_MESSAGE_X fields, 0), \
FB_TRIGGER_MESSAGE_MOVE_NAMES(name, fields))
#define FB_TRIGGER_MESSAGE_X(x, y, z) ((x, y, z)) FB_TRIGGER_MESSAGE_Y
#define FB_TRIGGER_MESSAGE_Y(x, y, z) ((x, y, z)) FB_TRIGGER_MESSAGE_X
#define FB_TRIGGER_MESSAGE_X0
#define FB_TRIGGER_MESSAGE_Y0
#define FB__MESSAGE_I(name, statusType, size, fields, moveNames) \
struct name \
{ \
struct Type \
{ \
BOOST_PP_SEQ_FOR_EACH_I(FB__MESSAGE_FIELD, size, fields) \
}; \
\
static void setup(statusType* status, ::Firebird::IMetadataBuilder* builder) \
{ \
unsigned index = 0; \
moveNames \
BOOST_PP_SEQ_FOR_EACH_I(FB__MESSAGE_META, size, fields) \
} \
\
name(statusType* status, ::Firebird::IMaster* master) \
: desc(master, status, BOOST_PP_SEQ_SIZE(fields), setup) \
{ \
} \
\
::Firebird::IMessageMetadata* getMetadata() const \
{ \
return desc.getMetadata(); \
} \
\
void clear() \
{ \
memset(&data, 0, sizeof(data)); \
} \
\
Type* getData() \
{ \
return &data; \
} \
\
const Type* getData() const \
{ \
return &data; \
} \
\
Type* operator ->() \
{ \
return getData(); \
} \
\
const Type* operator ->() const \
{ \
return getData(); \
} \
\
Type data; \
::Firebird::MessageDesc desc; \
}
#define FB__MESSAGE_FIELD(r, _, i, xy) \
BOOST_PP_CAT(FB__TYPE_, BOOST_PP_TUPLE_ELEM(_, 0, xy)) BOOST_PP_TUPLE_ELEM(_, 1, xy); \
ISC_SHORT BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(_, 1, xy), Null);
#define FB__MESSAGE_META(r, _, i, xy) \
BOOST_PP_CAT(FB__META_, BOOST_PP_TUPLE_ELEM(_, 0, xy)) \
++index;
// Types - metadata
#define FB__META_FB_SCALED_SMALLINT(scale) \
builder->setType(status, index, SQL_SHORT); \
builder->setLength(status, index, sizeof(ISC_SHORT)); \
builder->setScale(status, index, scale);
#define FB__META_FB_SCALED_INTEGER(scale) \
builder->setType(status, index, SQL_LONG); \
builder->setLength(status, index, sizeof(ISC_LONG)); \
builder->setScale(status, index, scale);
#define FB__META_FB_SCALED_BIGINT(scale) \
builder->setType(status, index, SQL_INT64); \
builder->setLength(status, index, sizeof(ISC_INT64)); \
builder->setScale(status, index, scale);
#define FB__META_FB_FLOAT \
builder->setType(status, index, SQL_FLOAT); \
builder->setLength(status, index, sizeof(float));
#define FB__META_FB_DOUBLE \
builder->setType(status, index, SQL_DOUBLE); \
builder->setLength(status, index, sizeof(double));
#define FB__META_FB_BLOB \
builder->setType(status, index, SQL_BLOB); \
builder->setLength(status, index, sizeof(ISC_QUAD));
#define FB__META_FB_BOOLEAN \
builder->setType(status, index, SQL_BOOLEAN); \
builder->setLength(status, index, sizeof(ISC_BOOLEAN));
#define FB__META_FB_DATE \
builder->setType(status, index, SQL_DATE); \
builder->setLength(status, index, sizeof(FbDate));
#define FB__META_FB_TIME \
builder->setType(status, index, SQL_TIME); \
builder->setLength(status, index, sizeof(FbTime));
#define FB__META_FB_TIMESTAMP \
builder->setType(status, index, SQL_TIMESTAMP); \
builder->setLength(status, index, sizeof(FbTimestamp));
#define FB__META_FB_CHAR(len) \
builder->setType(status, index, SQL_TEXT); \
builder->setLength(status, index, len);
#define FB__META_FB_VARCHAR(len) \
builder->setType(status, index, SQL_VARYING); \
builder->setLength(status, index, len);
#define FB__META_FB_INTL_CHAR(len, charSet) \
builder->setType(status, index, SQL_TEXT); \
builder->setLength(status, index, len); \
builder->setCharSet(status, index, charSet);
#define FB__META_FB_INTL_VARCHAR(len, charSet) \
builder->setType(status, index, SQL_VARYING); \
builder->setLength(status, index, len); \
builder->setCharSet(status, index, charSet);
#define FB__META_FB_SMALLINT FB__META_FB_SCALED_SMALLINT(0)
#define FB__META_FB_INTEGER FB__META_FB_SCALED_INTEGER(0)
#define FB__META_FB_BIGINT FB__META_FB_SCALED_BIGINT(0)
// Types - struct
#define FB__TYPE_FB_SCALED_SMALLINT(x) ISC_SHORT
#define FB__TYPE_FB_SCALED_INTEGER(x) ISC_LONG
#define FB__TYPE_FB_SCALED_BIGINT(x) ISC_INT64
#define FB__TYPE_FB_SMALLINT ISC_SHORT
#define FB__TYPE_FB_INTEGER ISC_LONG
#define FB__TYPE_FB_BIGINT ISC_INT64
#define FB__TYPE_FB_FLOAT float
#define FB__TYPE_FB_DOUBLE double
#define FB__TYPE_FB_BLOB ISC_QUAD
#define FB__TYPE_FB_BOOLEAN ISC_UCHAR
#define FB__TYPE_FB_DATE ::Firebird::FbDate
#define FB__TYPE_FB_TIME ::Firebird::FbTime
#define FB__TYPE_FB_TIMESTAMP ::Firebird::FbTimestamp
#define FB__TYPE_FB_CHAR(len) ::Firebird::FbChar<(len)>
#define FB__TYPE_FB_VARCHAR(len) ::Firebird::FbVarChar<(len)>
#define FB__TYPE_FB_INTL_CHAR(len, charSet) ::Firebird::FbChar<(len)>
#define FB__TYPE_FB_INTL_VARCHAR(len, charSet) ::Firebird::FbVarChar<(len)>
#define FB_TRIGGER_MESSAGE_MOVE_NAMES(name, fields) \
FB_TRIGGER_MESSAGE_MOVE_NAMES_I(name, 3, BOOST_PP_CAT(FB_TRIGGER_MESSAGE_MOVE_NAMES_X fields, 0))
#define FB_TRIGGER_MESSAGE_MOVE_NAMES_X(x, y, z) ((x, y, z)) FB_TRIGGER_MESSAGE_MOVE_NAMES_Y
#define FB_TRIGGER_MESSAGE_MOVE_NAMES_Y(x, y, z) ((x, y, z)) FB_TRIGGER_MESSAGE_MOVE_NAMES_X
#define FB_TRIGGER_MESSAGE_MOVE_NAMES_X0
#define FB_TRIGGER_MESSAGE_MOVE_NAMES_Y0
#define FB_TRIGGER_MESSAGE_MOVE_NAMES_I(name, size, fields) \
BOOST_PP_SEQ_FOR_EACH_I(FB_TRIGGER_MESSAGE_MOVE_NAME, size, fields) \
builder->truncate(status, index); \
index = 0;
#define FB_TRIGGER_MESSAGE_MOVE_NAME(r, _, i, xy) \
builder->moveNameToIndex(status, BOOST_PP_TUPLE_ELEM(_, 2, xy), index++);
namespace Firebird {
template <unsigned N>
struct FbChar
{
char str[N];
};
template <unsigned N>
struct FbVarChar
{
ISC_USHORT length;
char str[N];
void set(const char* s)
{
length = strlen(s);
assert(length <= N);
memcpy(str, s, length);
}
};
// This class has memory layout identical to ISC_DATE.
class FbDate
{
public:
void decode(IUtil* util, unsigned* year, unsigned* month, unsigned* day) const
{
util->decodeDate(value, year, month, day);
}
unsigned getYear(IUtil* util) const
{
unsigned year;
decode(util, &year, NULL, NULL);
return year;
}
unsigned getMonth(IUtil* util) const
{
unsigned month;
decode(util, NULL, &month, NULL);
return month;
}
unsigned getDay(IUtil* util) const
{
unsigned day;
decode(util, NULL, NULL, &day);
return day;
}
void encode(IUtil* util, unsigned year, unsigned month, unsigned day)
{
value = util->encodeDate(year, month, day);
}
public:
ISC_DATE value;
};
// This class has memory layout identical to ISC_TIME.
class FbTime
{
public:
void decode(IUtil* util, unsigned* hours, unsigned* minutes, unsigned* seconds,
unsigned* fractions) const
{
util->decodeTime(value, hours, minutes, seconds, fractions);
}
unsigned getHours(IUtil* util) const
{
unsigned hours;
decode(util, &hours, NULL, NULL, NULL);
return hours;
}
unsigned getMinutes(IUtil* util) const
{
unsigned minutes;
decode(util, NULL, &minutes, NULL, NULL);
return minutes;
}
unsigned getSeconds(IUtil* util) const
{
unsigned seconds;
decode(util, NULL, NULL, &seconds, NULL);
return seconds;
}
unsigned getFractions(IUtil* util) const
{
unsigned fractions;
decode(util, NULL, NULL, NULL, &fractions);
return fractions;
}
void encode(IUtil* util, unsigned hours, unsigned minutes, unsigned seconds, unsigned fractions)
{
value = util->encodeTime(hours, minutes, seconds, fractions);
}
public:
ISC_TIME value;
};
// This class has memory layout identical to ISC_TIMESTAMP.
class FbTimestamp
{
public:
FbDate date;
FbTime time;
};
class MessageDesc
{
public:
template <typename StatusType>
MessageDesc(IMaster* master, StatusType* status, unsigned count,
void (*setup)(StatusType*, IMetadataBuilder*))
{
IMetadataBuilder* builder = master->getMetadataBuilder(status, count);
setup(status, builder);
metadata = builder->getMetadata(status);
builder->release();
}
~MessageDesc()
{
metadata->release();
}
IMessageMetadata* getMetadata() const
{
return metadata;
}
private:
IMessageMetadata* metadata;
};
} // namespace Firebird
#endif // FIREBIRD_MESSAGE_H
|