fm_plugin 0.1.17

Build plug-ins for use with FileMaker Pro and FileMaker Server.
Documentation
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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/*

 Copyright © 1998 - 2019  Claris International Inc.
 All rights reserved.

 Claris International Inc. grants you a non-exclusive limited license to use this file solely
 to enable licensees of Claris FileMaker Pro to compile plug-ins for use with Claris products.
 Redistribution and use in source and binary forms, without modification, are permitted provided
 that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this list of
 conditions and the following disclaimer.

 * The name Claris International Inc. may not be used to endorse or promote products derived
 from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY CLARIS INTERNATIONAL INC. ''AS IS'' AND ANY
 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL FILEMAKER, INC. BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 */

#ifndef _h_BinaryData_
#define _h_BinaryData_


#include "FMXClient.h"
#include "FMXTypes.h"

extern "C++"
{
	namespace fmx
	{
		// A BinaryData type is a collection of streams. Each stream has two parts, a TypeId and Data.
		//              There can be multiple related streams, but there should never be more than one
		//              stream of the same type.  Streams should not be empty.
		// Container fields can be considered to be of type BinaryData when data is stored in the database
		//          as opposed to objects inserted by reference (path of file as text).
		//
		// To iterate through the streams of a BinaryData, use GetCount and then call GetIndex to
		//              get the TypeID for each stream.
		//
		// To create a new BinaryData object, use the autoptr version to construct the object, then
		//      Add() streams if you didn't use one of the auto populating constructors.
		class BinaryData
		{
		public:
			// Here are some common QuadChar types you may encounter, and notes on required usage.
			// The actual format of the data should adhere to the standard documented by
			// the format creator.
			//
			//  "FNAM" is a filename stream. This is used either to display the filename of the file
			//          in the field (non-images or images that cannot be displayed) and for a initial
			//          suggested filename when exporting field contents. Please use the special accessors
			//          below ("GetFNAMData and AddFNAMData) to get a text representation of this data.
			//
			//  Images:
			//          { "JPEG", "GIFf", "EPS ", "META", "PNGf", "BMPf", "PDF " }
			//          Images must have at least a JPEG, GIFf, or PNGf stream in addition to any
			//          other image type. A "SIZE" stream is also required for FileMaker to display
			//          the image. Please use the special accessors below (GetSIZEData and AddSIZEData)
			//          to get the height and width values for the image.
			//
			// When generating other kinds of graphical data, use JPEG or PNGf for a preview,
			// and the other format will be preferred if possible. For example, to generate
			// a TIFF picture, you have to add "TIFF" and "JPEG" streams.
			//
			//  Files:
			//          { "FILE" (binary file data), "ZLIB" (compressed file data), "FORK" (Mac only resource fork) }
			//          Compressed file data is compressed using zlib but using the gzip headers. Parameters used are:
			//              deflateInit2( ctx, Z_BEST_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY );
			//          Decompression also uses zlib set to detect zlib or gzip headers. Parameters used are:
			//              inflateInit2( ctx, 15 + 32 )
			//
			//  Sound:
			//          { "snd " }
			//          Always Mac raw format.
			//
			//  Other types:
			//          { "MAIN" }
			//          When saving the contents of a container field to disk, FileMaker will first
			//          check if there is a MAIN stream and if present read the first four bytes as
			//          the QuadChar of the stream that is considered the main stream for the container.
			//          If this does not existed it falls back to the default rules for picking the
			//          main stream.

			// Any other types you encounter are not documented for plug-in use. Use them at your own risk.

			inline BinaryData &operator = ( const BinaryData &source );
			inline bool operator == ( const BinaryData &compareData ) const;
			inline bool operator != ( const BinaryData &compareData ) const;
			inline int32 GetCount () const;
			inline int32 GetIndex ( const QuadChar& dataType ) const;
			inline uint32 GetTotalSize () const;
			inline void GetType ( int32 index, QuadChar& dataType ) const;
			inline uint32 GetSize ( int32 index ) const;
			inline errcode GetData ( int32 index, uint32 offset, uint32 amount, void *buffer ) const;

			// You should exercise great care in using the following functions. Removing or modifying a required stream
			// could have undesirable and undefined results.
			inline errcode Add ( const QuadChar& dataType, uint32 amount, void *buffer );
			inline bool Remove ( const QuadChar& dataType );
			inline void RemoveAll ();

			inline void operator delete ( void *obj );

			// New to FileMaker Pro 8 (API VERSION 51) and later
			// Special accessors for FileMaker specific storage formats
			inline errcode GetFNAMData ( Text &filepathlist ) const;
			inline errcode AddFNAMData ( const Text &filepathlist );
			inline errcode GetSIZEData ( short &width, short &height ) const;
			inline errcode AddSIZEData ( short width, short height );

			// New to FileMaker Pro 14 (API VERSION 55) and later
			// Use to to add a new stream type to a binary data object without
			// having to load it all in memory at the same time.
			inline errcode AddBegin ( const QuadChar& dataType, uint32* context );
			inline errcode AddAppend ( uint32 context, uint32 amount, void *buffer );
			inline errcode AddFinish ( uint32 context );

		private:
			BinaryData ();
			BinaryData ( const BinaryData &source );

		};

#if FMX_USE_AUTO_PTR
		// DEPRECATED in FileMaker Pro 15. C++11 deprecated std::auto_ptr and replaced with std::unique_ptr.
		class DEPRECATED BinaryDataAutoPtr : public std::auto_ptr<BinaryData>
		{
			typedef BinaryDataAutoPtr   UpCaster;
		public:
			inline BinaryDataAutoPtr ();
			inline BinaryDataAutoPtr ( const BinaryData &sourceData );

			// New to FileMaker Pro 13 (API VERSION 54) and later
			// This method sets the FNAM, SIZE, main stream, and all other information streams
			// for the given data. The extension of the file name passed in is used to determine
			// the type of data passed in the buffer. This routine does not read data from the
			// disk itself. Please use this to do "Insert from..." type operations.
			inline BinaryDataAutoPtr ( const Text &name, uint32 amount, void *buffer );

			// New to FileMaker Pro 14 (API VERSION 55) and later
			// Same as the above constructor except use AddAppend/AddFinish for the data
			inline BinaryDataAutoPtr ( const Text &name, uint32* context );
		};
#endif

#if FMX_USE_UNIQUE_PTR
		class BinaryDataUniquePtr : public std::unique_ptr<BinaryData>
		{
			typedef BinaryDataUniquePtr   UpCaster;
		public:
			inline BinaryDataUniquePtr ();
			inline BinaryDataUniquePtr ( const BinaryData &sourceData );

			inline BinaryDataUniquePtr ( const Text &name, uint32 amount, void *buffer );
			inline BinaryDataUniquePtr ( const Text &name, uint32* context );
		};
#endif
	}
}


// These functions are only useful for C-only environments or for porting to other languages (ex., Pascal).
extern "C"
{
	fmx::BinaryData FMX_API *FM_BinaryData_Constructor1 ( fmx::_fmxcpt &_x ) throw ();
	fmx::BinaryData FMX_API *FM_BinaryData_Constructor2 ( const fmx::BinaryData &sourceData, fmx::_fmxcpt &_x ) throw ();
	fmx::BinaryData FMX_API *FM_BinaryData_Constructor3 ( const fmx::Text &name, fmx::uint32 amount, void *buffer, fmx::_fmxcpt &_x ) throw ();
	fmx::BinaryData FMX_API *FM_BinaryData_Constructor4 ( const fmx::Text &name, fmx::uint32* context, fmx::_fmxcpt &_x ) throw ();
	fmx::BinaryData FMX_API *FM_BinaryData_operatorAS ( void *_self, const fmx::BinaryData &source, fmx::_fmxcpt &_x ) throw ();
	bool FMX_API FM_BinaryData_operatorEQ ( const void *_self, const fmx::BinaryData &compareData, fmx::_fmxcpt &_x ) throw ();
	bool FMX_API FM_BinaryData_operatorNE ( const void *_self, const fmx::BinaryData &compareData, fmx::_fmxcpt &_x ) throw ();
	fmx::int32 FMX_API FM_BinaryData_GetCount ( const void *_self, fmx::_fmxcpt &_x ) throw ();
	fmx::int32 FMX_API FM_BinaryData_GetIndex ( const void *_self, const fmx::QuadChar& dataType, fmx::_fmxcpt &_x ) throw ();
	fmx::uint32 FMX_API FM_BinaryData_GetTotalSize ( const void *_self, fmx::_fmxcpt &_x ) throw ();
	void FMX_API FM_BinaryData_GetType ( const void *_self, fmx::int32 index, fmx::QuadChar& dataType, fmx::_fmxcpt &_x ) throw ();
	fmx::uint32 FMX_API FM_BinaryData_GetSize ( const void *_self, fmx::int32 index, fmx::_fmxcpt &_x ) throw ();
	fmx::errcode FMX_API FM_BinaryData_GetData ( const void *_self, fmx::int32 index, fmx::uint32 offset, fmx::uint32 amount, void *buffer, fmx::_fmxcpt &_x ) throw ();
	fmx::errcode FMX_API FM_BinaryData_Add ( void *_self, const fmx::QuadChar& dataType, fmx::uint32 amount, void *buffer, fmx::_fmxcpt &_x ) throw ();
	bool FMX_API FM_BinaryData_Remove ( void *_self, const fmx::QuadChar& dataType, fmx::_fmxcpt &_x ) throw ();
	void FMX_API FM_BinaryData_RemoveAll ( void *_self, fmx::_fmxcpt &_x ) throw ();
	void FMX_API FM_BinaryData_Delete ( void *_self, fmx::_fmxcpt &_x ) throw ();

	fmx::errcode FMX_API FM_BinaryData_GetFNAMData ( const void *_self, fmx::Text &filepathlist, fmx::_fmxcpt &_x ) throw ();
	fmx::errcode FMX_API FM_BinaryData_AddFNAMData ( void *_self, const fmx::Text &filepathlist, fmx::_fmxcpt &_x ) throw ();
	fmx::errcode FMX_API FM_BinaryData_GetSIZEData ( const void *_self, short &width, short &height, fmx::_fmxcpt &_x ) throw ();
	fmx::errcode FMX_API FM_BinaryData_AddSIZEData ( void *_self, short width, short height, fmx::_fmxcpt &_x ) throw ();

	fmx::errcode FMX_API FM_BinaryData_AddBegin ( void *_self, const fmx::QuadChar& dataType, fmx::uint32* context, fmx::_fmxcpt &_x ) throw ();
	fmx::errcode FMX_API FM_BinaryData_AddAppend ( void *_self, fmx::uint32 context, fmx::uint32 amount, void *buffer, fmx::_fmxcpt &_x ) throw ();
	fmx::errcode FMX_API FM_BinaryData_AddFinish ( void *_self, fmx::uint32 context, fmx::_fmxcpt &_x ) throw ();
}


extern "C++"
{
	namespace fmx
	{
		inline BinaryData &BinaryData::operator = ( const BinaryData &source )
		{
			_fmxcpt _x;
			BinaryData *_rtn = FM_BinaryData_operatorAS ( this, source, _x );
			_x.Check ();
			return *_rtn;
		}
		inline bool BinaryData::operator == ( const BinaryData &compareData ) const
		{
			_fmxcpt _x;
			bool _rtn = FM_BinaryData_operatorEQ ( this, compareData, _x );
			_x.Check ();
			return _rtn;
		}
		inline bool BinaryData::operator != ( const BinaryData &compareData ) const
		{
			_fmxcpt _x;
			bool _rtn = FM_BinaryData_operatorNE ( this, compareData, _x );
			_x.Check ();
			return _rtn;
		}
		inline int32 BinaryData::GetCount () const
		{
			_fmxcpt _x;
			int32 _rtn = FM_BinaryData_GetCount ( this, _x );
			_x.Check ();
			return _rtn;
		}
		inline int32 BinaryData::GetIndex ( const QuadChar& dataType ) const
		{
			_fmxcpt _x;
			int32 _rtn = FM_BinaryData_GetIndex ( this, dataType, _x );
			_x.Check ();
			return _rtn;
		}
		inline uint32 BinaryData::GetTotalSize () const
		{
			_fmxcpt _x;
			uint32 _rtn = FM_BinaryData_GetTotalSize ( this, _x );
			_x.Check ();
			return _rtn;
		}
		inline void BinaryData::GetType ( int32 index, QuadChar& dataType ) const
		{
			_fmxcpt _x;
			FM_BinaryData_GetType ( this, index, dataType, _x );
			_x.Check ();
		}
		inline uint32 BinaryData::GetSize ( int32 index ) const
		{
			_fmxcpt _x;
			uint32 _rtn = FM_BinaryData_GetSize ( this, index, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::GetData ( int32 index, uint32 offset, uint32 amount, void *buffer ) const
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_GetData ( this, index, offset, amount, buffer, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::Add ( const QuadChar& dataType, uint32 amount, void *buffer )
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_Add ( this, dataType, amount, buffer, _x );
			_x.Check ();
			return _rtn;
		}
		inline bool BinaryData::Remove ( const QuadChar& dataType )
		{
			_fmxcpt _x;
			bool _rtn = FM_BinaryData_Remove ( this, dataType, _x );
			_x.Check ();
			return _rtn;
		}
		inline void BinaryData::RemoveAll ()
		{
			_fmxcpt _x;
			FM_BinaryData_RemoveAll ( this, _x );
			_x.Check ();
		}
		inline void BinaryData::operator delete ( void *obj )
		{
			_fmxcpt _x;
			FM_BinaryData_Delete ( obj, _x );
			_x.Check ();
		}

#if FMX_USE_AUTO_PTR
		inline BinaryDataAutoPtr::BinaryDataAutoPtr ()
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor1 ( _x ) );
			_x.Check ();
		}
		inline BinaryDataAutoPtr::BinaryDataAutoPtr ( const BinaryData &sourceData )
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor2 ( sourceData, _x ) );
			_x.Check ();
		}
		inline BinaryDataAutoPtr::BinaryDataAutoPtr ( const Text &name, uint32 amount, void *buffer )
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor3 ( name, amount, buffer, _x ) );
			_x.Check ();
		}
		inline BinaryDataAutoPtr::BinaryDataAutoPtr ( const Text &name, fmx::uint32* context )
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor4 ( name, context, _x ) );
			_x.Check ();
		}
#endif

#if FMX_USE_UNIQUE_PTR
		inline BinaryDataUniquePtr::BinaryDataUniquePtr ()
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor1 ( _x ) );
			_x.Check ();
		}
		inline BinaryDataUniquePtr::BinaryDataUniquePtr ( const BinaryData &sourceData )
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor2 ( sourceData, _x ) );
			_x.Check ();
		}
		inline BinaryDataUniquePtr::BinaryDataUniquePtr ( const Text &name, uint32 amount, void *buffer )
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor3 ( name, amount, buffer, _x ) );
			_x.Check ();
		}
		inline BinaryDataUniquePtr::BinaryDataUniquePtr ( const Text &name, fmx::uint32* context )
		{
			_fmxcpt _x;
			reset ( FM_BinaryData_Constructor4 ( name, context, _x ) );
			_x.Check ();
		}
#endif

		inline errcode BinaryData::GetFNAMData ( Text &filepathlist ) const
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_GetFNAMData ( this, filepathlist, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::AddFNAMData ( const Text &filepathlist )
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_AddFNAMData ( this, filepathlist, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::GetSIZEData ( short &width, short &height ) const
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_GetSIZEData ( this, width, height, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::AddSIZEData ( short width, short height )
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_AddSIZEData ( this, width, height, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::AddBegin ( const QuadChar& dataType, uint32* context )
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_AddBegin ( this, dataType, context, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::AddAppend ( uint32 context, uint32 amount, void *buffer )
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_AddAppend ( this, context, amount, buffer, _x );
			_x.Check ();
			return _rtn;
		}
		inline errcode BinaryData::AddFinish ( uint32 context )
		{
			_fmxcpt _x;
			errcode _rtn = FM_BinaryData_AddFinish ( this, context, _x );
			_x.Check ();
			return _rtn;
		}
	}
}


#endif /* _h_BinaryData_ */