forked from hazelcast/hazelcast-cpp-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompact.h
More file actions
1482 lines (1357 loc) · 53.4 KB
/
compact.h
File metadata and controls
1482 lines (1357 loc) · 53.4 KB
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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved.
*
* Licensed 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HAZELCAST_CLIENT_SERIALIZATION_PIMPL_COMPACT_H_
#define HAZELCAST_CLIENT_SERIALIZATION_PIMPL_COMPACT_H_
// We are using ifdef guards instead of pragmas because, ide could not recognize
// pragma once for this specific case. compact.h and compact.i.h is included in
// serialization.h not in the beginning but later to avoid cyclic dependency.
#include <boost/thread/future.hpp>
#include <boost/property_tree/ptree.hpp>
#include <utility>
#include "hazelcast/util/export.h"
#include "hazelcast/client/serialization/serialization.h"
#include "hazelcast/util/SynchronizedMap.h"
#include "hazelcast/client/serialization/field_kind.h"
#include "hazelcast/client/serialization/pimpl/compact/default_schema_service.h"
#include "hazelcast/client/serialization/pimpl/compact/schema_writer.h"
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
#pragma warning(push)
#pragma warning(disable : 4251) // for dll export
#endif
namespace hazelcast {
namespace client {
namespace spi {
class ClientContext;
}
namespace serialization {
namespace compact {
class compact_reader;
class compact_writer;
} // namespace compact
namespace pimpl {
class schema;
class default_compact_writer;
class schema_writer;
compact::compact_writer HAZELCAST_API
create_compact_writer(pimpl::default_compact_writer* default_compact_writer);
compact::compact_writer HAZELCAST_API
create_compact_writer(pimpl::schema_writer* schema_writer);
compact::compact_reader HAZELCAST_API
create_compact_reader(
pimpl::compact_stream_serializer& compact_stream_serializer,
object_data_input& object_data_input,
const pimpl::schema& schema);
struct field_descriptor;
} // namespace pimpl
namespace compact {
/**
* Classes derived from this class should implement the following static
* methods:
* static std::string type_name() noexpect;
* static void write(const T& object, compact_writer &out);
* static T read(compact_reader &in);
*
* @Beta
* @since 5.1
*/
class compact_serializer
{};
/**
* Provides means of reading compact serialized fields from the binary data.
* <p>
* Read operations might throw hazelcast_serialization exception
* when a field with the given name is not found or there is a type mismatch. On
* such occasions, one might provide default values to the read methods to
* return it. Providing default values might be especially useful if the class
* might evolve in the future, either by adding or removing fields.
*
* @Beta
* @since 5.1
*/
class HAZELCAST_API compact_reader
{
public:
/**
* Reads a boolean.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
bool read_boolean(const std::string& field_name);
/**
* Reads an 8-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
int8_t read_int8(const std::string& field_name);
/**
* Reads a 16-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
int16_t read_int16(const std::string& field_name);
/**
* Reads a 32-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
int32_t read_int32(const std::string& field_name);
/**
* Reads a 64-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
int64_t read_int64(const std::string& field_name);
/**
* Reads a 32-bit IEEE 754 floating point number.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
float read_float32(const std::string& field_name);
/**
* Reads a 64-bit IEEE 754 floating point number.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
double read_float64(const std::string& field_name);
/**
* Reads an UTF-8 encoded string.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
*in the schema.
*/
boost::optional<std::string> read_string(const std::string& field_name);
/**
* Reads an arbitrary precision and scale floating point number.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<big_decimal> read_decimal(const std::string& field_name);
/**
* Reads a time consisting of hour, minute, second, and nano seconds.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<local_time> read_time(const std::string& field_name);
/**
* Reads a date consisting of year, month, and day.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<local_date> read_date(const std::string& field_name);
/**
* Reads a timestamp consisting of date and time.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<local_date_time> read_timestamp(
const std::string& field_name);
/**
* Reads a timestamp with timezone consisting of date, time and timezone
* offset.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<offset_date_time> read_timestamp_with_timezone(
const std::string& field_name);
/**
* Reads a compact object
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
template<typename T>
boost::optional<T> read_compact(const std::string& field_name);
/**
* Reads an array of booleans.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<bool>> read_array_of_boolean(
const std::string& field_name);
/**
* Reads an array of 8-bit two's complement signed integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<int8_t>> read_array_of_int8(
const std::string& field_name);
/**
* Reads an array of 16-bit two's complement signed integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<int16_t>> read_array_of_int16(
const std::string& field_name);
/**
* Reads an array of 32-bit two's complement signed integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<int32_t>> read_array_of_int32(
const std::string& field_name);
/**
* Reads an array of 64-bit two's complement signed integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<int64_t>> read_array_of_int64(
const std::string& field_name);
/**
* Reads an array of 32-bit IEEE 754 floating point numbers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<float>> read_array_of_float32(
const std::string& field_name);
/**
* Reads an array of 64-bit IEEE 754 floating point numbers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<double>> read_array_of_float64(
const std::string& field_name);
/**
* Reads an array of UTF-8 encoded strings.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<std::string>>>
read_array_of_string(const std::string& field_name);
/**
* Reads an array of arbitrary precision and scale floating point numbers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<big_decimal>>>
read_array_of_decimal(const std::string& field_name);
/**
* Reads an array of times consisting of hour, minute, second, and
* nanoseconds.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<local_time>>>
read_array_of_time(const std::string& field_name);
/**
* Reads an array of dates consisting of year, month, and day.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<local_date>>>
read_array_of_date(const std::string& field_name);
/**
* Reads an array of timestamps consisting of date and time.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<local_date_time>>>
read_array_of_timestamp(const std::string& field_name);
/**
* Reads an array of timestamps with timezone consisting of date, time and
* timezone offset.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<offset_date_time>>>
read_array_of_timestamp_with_timezone(const std::string& field_name);
/**
* Reads an array of compact objects.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
template<typename T>
boost::optional<std::vector<boost::optional<T>>> read_array_of_compact(
const std::string& field_name);
/**
* Reads a nullable boolean.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<bool> read_nullable_boolean(const std::string& field_name);
/**
* Reads a nullable 8-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<int8_t> read_nullable_int8(const std::string& field_name);
/**
* Reads a nullable 16-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<int16_t> read_nullable_int16(const std::string& field_name);
/**
* Reads a nullable 32-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<int32_t> read_nullable_int32(const std::string& field_name);
/**
* Reads a nullable 64-bit two's complement signed integer.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<int64_t> read_nullable_int64(const std::string& field_name);
/**
* Reads a nullable 32-bit IEEE 754 floating point number.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<float> read_nullable_float32(const std::string& field_name);
/**
* Reads a nullable 64-bit IEEE 754 floating point number.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<double> read_nullable_float64(
const std::string& field_name);
/**
* Reads a nullable array of nullable booleans.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<bool>>>
read_array_of_nullable_boolean(const std::string& field_name);
/**
* Reads a nullable array of nullable 8-bit two's complement signed
* integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<int8_t>>>
read_array_of_nullable_int8(const std::string& field_name);
/**
* Reads a nullable array of nullable 16-bit two's complement signed
* integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<int16_t>>>
read_array_of_nullable_int16(const std::string& field_name);
/**
* Reads a nullable array of nullable 32-bit two's complement signed
* integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<int32_t>>>
read_array_of_nullable_int32(const std::string& field_name);
/**
* Reads a nullable array of nullable 64-bit two's complement signed
* integers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<int64_t>>>
read_array_of_nullable_int64(const std::string& field_name);
/**
* Reads a nullable array of nullable 32-bit IEEE 754 floating point
* numbers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<float>>>
read_array_of_nullable_float32(const std::string& field_name);
/**
* Reads a nullable array of nullable 64-bit IEEE 754 floating point
* numbers.
*
* @param field_name name of the field.
* @return the value of the field.
* @throws hazelcast_serialization if the field does not exist in the
* schema or the type of the field does not match with the one defined
* in the schema.
*/
boost::optional<std::vector<boost::optional<double>>>
read_array_of_nullable_float64(const std::string& field_name);
private:
compact_reader(pimpl::compact_stream_serializer& compact_stream_serializer,
object_data_input& object_data_input,
const pimpl::schema& schema);
friend compact_reader pimpl::create_compact_reader(
pimpl::compact_stream_serializer& compact_stream_serializer,
object_data_input& object_data_input,
const pimpl::schema& schema);
template<typename T>
T read_primitive(const std::string& field_name,
field_kind kind,
field_kind nullable_kind,
const std::string& method_suffix);
template<typename T>
T read_primitive(const pimpl::field_descriptor& field_descriptor);
bool is_field_exists(const std::string& field_name, field_kind kind) const;
const pimpl::field_descriptor& get_field_descriptor(
const std::string& field_name) const;
const pimpl::field_descriptor& get_field_descriptor(
const std::string& field_name,
field_kind field_kind) const;
template<typename T>
boost::optional<T> read_variable_size(
const pimpl::field_descriptor& field_descriptor);
template<typename T>
boost::optional<T> read_variable_size(const std::string& field_name,
field_kind field_kind);
template<typename T>
T read_variable_size_as_non_null(
const pimpl::field_descriptor& field_descriptor,
const std::string& field_name,
const std::string& method_suffix);
template<typename T>
typename std::enable_if<
std::is_same<bool, typename std::remove_cv<T>::type>::value ||
std::is_same<int8_t, typename std::remove_cv<T>::type>::value ||
std::is_same<int16_t, typename std::remove_cv<T>::type>::value ||
std::is_same<int32_t, typename std::remove_cv<T>::type>::value ||
std::is_same<int64_t, typename std::remove_cv<T>::type>::value ||
std::is_same<float, typename std::remove_cv<T>::type>::value ||
std::is_same<double, typename std::remove_cv<T>::type>::value ||
std::is_same<std::string, typename std::remove_cv<T>::type>::value ||
std::is_same<std::vector<int8_t>,
typename std::remove_cv<T>::type>::value ||
std::is_same<std::vector<int16_t>,
typename std::remove_cv<T>::type>::value ||
std::is_same<std::vector<int32_t>,
typename std::remove_cv<T>::type>::value ||
std::is_same<std::vector<int64_t>,
typename std::remove_cv<T>::type>::value ||
std::is_same<std::vector<float>,
typename std::remove_cv<T>::type>::value ||
std::is_same<std::vector<double>,
typename std::remove_cv<T>::type>::value ||
std::is_same<std::vector<boost::optional<std::string>>,
typename std::remove_cv<T>::type>::value,
typename boost::optional<T>>::type
read();
template<typename T>
typename std::enable_if<
std::is_base_of<compact::compact_serializer, hz_serializer<T>>::value,
typename boost::optional<T>>::type
read();
template<typename T>
typename std::enable_if<
std::is_same<generic_record::generic_record, T>::value,
typename boost::optional<T>>::type
read();
template<typename T>
typename std::enable_if<
std::is_same<std::vector<bool>, typename std::remove_cv<T>::type>::value,
typename boost::optional<T>>::type
read();
template<typename T>
typename std::enable_if<
std::is_same<std::vector<boost::optional<bool>>,
typename std::remove_cv<T>::type>::value,
typename boost::optional<T>>::type
read();
template<typename T>
typename std::enable_if<
std::is_same<big_decimal, typename std::remove_cv<T>::type>::value ||
std::is_same<local_time, typename std::remove_cv<T>::type>::value ||
std::is_same<local_date, typename std::remove_cv<T>::type>::value ||
std::is_same<local_date_time,
typename std::remove_cv<T>::type>::value ||
std::is_same<offset_date_time, typename std::remove_cv<T>::type>::value,
typename boost::optional<T>>::type
read();
template<typename T>
boost::optional<T> read_array_of_primitive(
const std::string& field_name,
field_kind kind,
field_kind nullable_kind,
const std::string& method_suffix);
template<typename T>
boost::optional<std::vector<boost::optional<T>>>
read_array_of_variable_size(
const pimpl::field_descriptor& field_descriptor);
template<typename T>
boost::optional<T> read_nullable_array_as_primitive_array(
const pimpl::field_descriptor& field_descriptor,
const std::string& field_name,
const std::string& method_suffix);
using offset_func = std::function<
int32_t(serialization::object_data_input&, uint32_t, uint32_t)>;
static const offset_func BYTE_OFFSET_READER;
static const offset_func SHORT_OFFSET_READER;
static const offset_func INT_OFFSET_READER;
template<typename T>
boost::optional<T> read_nullable_primitive(const std::string& field_name,
field_kind kind,
field_kind nullable_kind);
template<typename T>
boost::optional<std::vector<boost::optional<T>>> read_array_of_nullable(
const std::string& field_name,
field_kind kind,
field_kind nullable_kind);
template<typename T>
boost::optional<std::vector<boost::optional<T>>>
read_primitive_array_as_nullable_array(
const pimpl::field_descriptor& field_descriptor);
static std::function<
int32_t(serialization::object_data_input&, uint32_t, uint32_t)>
get_offset_reader(int32_t data_length);
static exception::hazelcast_serialization unexpected_null_value_in_array(
const std::string& field_name,
const std::string& method_suffix);
exception::hazelcast_serialization unknown_field(
const std::string& field_name) const;
exception::hazelcast_serialization unexpected_field_kind(
field_kind kind,
const std::string& field_name) const;
static exception::hazelcast_serialization unexpected_null_value(
const std::string& field_name,
const std::string& method_suffix);
size_t read_fixed_size_position(
const pimpl::field_descriptor& field_descriptor) const;
int32_t read_var_size_position(
const pimpl::field_descriptor& field_descriptor) const;
pimpl::compact_stream_serializer& compact_stream_serializer;
serialization::object_data_input& object_data_input;
const pimpl::schema& schema;
int32_t data_start_position;
size_t variable_offsets_position;
/**
* Returns the offset of the variable-size field at the given index.
* @param serialization::object_data_input& Input to read the offset from.
* @param uint32_t start of the variable-size field offsets
* section of the input.
* @param uint32_t index of the field.
* @return The offset.
*/
std::function<
int32_t(serialization::object_data_input&, uint32_t, uint32_t)>
get_offset;
};
/**
* Provides means of writing compact serialized fields to the binary data.
*
* @Beta
* @since 5.1
*/
class HAZELCAST_API compact_writer
{
public:
/**
* Writes a boolean value.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_boolean(const std::string& field_name, bool value);
/**
* Writes an 8-bit two's complement signed integer.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_int8(const std::string& field_name, int8_t value);
/**
* Writes a 16-bit two's complement signed integer.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_int16(const std::string& field_name, int16_t value);
/**
* Writes a 32-bit two's complement signed integer.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_int32(const std::string& field_name, int32_t value);
/**
* Writes a 64-bit two's complement signed integer.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_int64(const std::string& field_name, int64_t value);
/**
* Writes a 32-bit IEEE 754 floating point number.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_float32(const std::string& field_name, float value);
/**
* Writes a 64-bit IEEE 754 floating point number.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_float64(const std::string& field_name, double value);
/**
* Writes an UTF-8 encoded string.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_string(const std::string& field_name,
const boost::optional<std::string>& value);
/**
* Writes an arbitrary precision and scale floating point number.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_decimal(const std::string& field_name,
const boost::optional<big_decimal>& value);
/**
* Writes a time consisting of hour, minute, second, and nanoseconds.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_time(const std::string& field_name,
const boost::optional<local_time>& value);
/**
* Writes a date consisting of year, month, and day.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_date(const std::string& field_name,
const boost::optional<local_date>& value);
/**
* Writes a timestamp consisting of date and time.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_timestamp(const std::string& field_name,
const boost::optional<local_date_time>& value);
/**
* Writes a timestamp with timezone consisting of date, time and timezone
* offset.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_timestamp_with_timezone(
const std::string& field_name,
const boost::optional<offset_date_time>& value);
/**
* Writes a nested compact object.
*
* @param field_name name of the field.
* @param value to be written.
*/
template<typename T>
void write_compact(const std::string& field_name,
const boost::optional<T>& value);
/**
* Writes an array of booleans.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_boolean(
const std::string& field_name,
const boost::optional<std::vector<bool>>& value);
/**
* Writes an array of 8-bit two's complement signed integers.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_int8(const std::string& field_name,
const boost::optional<std::vector<int8_t>>& value);
/**
* Writes an array of 16-bit two's complement signed integers.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_int16(
const std::string& field_name,
const boost::optional<std::vector<int16_t>>& value);
/**
* Writes an array of 32-bit two's complement signed integers.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_int32(
const std::string& field_name,
const boost::optional<std::vector<int32_t>>& value);
/**
* Writes an array of 64-bit two's complement signed integers.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_int64(
const std::string& field_name,
const boost::optional<std::vector<int64_t>>& value);
/**
* Writes an array of 32-bit IEEE 754 floating point numbers.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_float32(
const std::string& field_name,
const boost::optional<std::vector<float>>& value);
/**
* Writes an array of 64-bit IEEE 754 floating point numbers.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_float64(
const std::string& field_name,
const boost::optional<std::vector<double>>& value);
/**
* Writes an array of UTF-8 encoded strings.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_string(
const std::string& field_name,
const boost::optional<std::vector<boost::optional<std::string>>>& value);
/**
* Writes an array of arbitrary precision and scale floating point numbers.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_decimal(
const std::string& field_name,
const boost::optional<std::vector<boost::optional<big_decimal>>>& value);
/**
* Writes an array of times consisting of hour, minute, second, and nano
* seconds.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_time(
const std::string& field_name,
const boost::optional<std::vector<boost::optional<local_time>>>& value);
/**
* Writes an array of dates consisting of year, month, and day.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_date(
const std::string& field_name,
const boost::optional<std::vector<boost::optional<local_date>>>& value);
/**
* Writes an array of timestamps consisting of date and time.
*
* @param field_name name of the field.
* @param value to be written.
*/
void write_array_of_timestamp(
const std::string& field_name,
const boost::optional<std::vector<boost::optional<local_date_time>>>&
value);
/**