-
Notifications
You must be signed in to change notification settings - Fork 50
/
phpstubstr.h
1707 lines (1707 loc) · 56.7 KB
/
phpstubstr.h
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
// File autogenerated, do not modify directly!
typedef struct { const char * filename; const char * data; } pcbc_stub_data;
pcbc_stub_data PCBC_PHP_CODESTR[] = {
{"[CouchbaseNative]/constants.php","\n" \
"/**\n" \
" * Various constants used for flags, data-type encoding and decoding, etc...\n" \
" * throughout this SDK.\n" \
" *\n" \
" * @author Brett Lawson <brett19@gmail.com>\n" \
" */\n" \
"\n" \
"/** @internal */ define('COUCHBASE_VAL_MASK', 0x1F);\n" \
"/** @internal */ define('COUCHBASE_VAL_IS_STRING', 0);\n" \
"/** @internal */ define('COUCHBASE_VAL_IS_LONG', 1);\n" \
"/** @internal */ define('COUCHBASE_VAL_IS_DOUBLE', 2);\n" \
"/** @internal */ define('COUCHBASE_VAL_IS_BOOL', 3);\n" \
"/** @internal */ define('COUCHBASE_VAL_IS_SERIALIZED', 4);\n" \
"/** @internal */ define('COUCHBASE_VAL_IS_IGBINARY', 5);\n" \
"/** @internal */ define('COUCHBASE_VAL_IS_JSON', 6);\n" \
"/** @internal */ define('COUCHBASE_COMPRESSION_MASK', 0x7 << 5);\n" \
"/** @internal */ define('COUCHBASE_COMPRESSION_NONE', 0 << 5);\n" \
"/** @internal */ define('COUCHBASE_COMPRESSION_ZLIB', 1 << 5);\n" \
"/** @internal */ define('COUCHBASE_COMPRESSION_FASTLZ', 2 << 5);\n" \
"/** @internal */ define('COUCHBASE_COMPRESSION_MCISCOMPRESSED', 1 << 4);\n" \
"\n" \
"/** @internal */ define('COUCHBASE_SERTYPE_JSON', 0);\n" \
"/** @internal */ define('COUCHBASE_SERTYPE_IGBINARY', 1);\n" \
"/** @internal */ define('COUCHBASE_SERTYPE_PHP', 2);\n" \
"/** @internal */ define('COUCHBASE_CMPRTYPE_NONE', 0);\n" \
"/** @internal */ define('COUCHBASE_CMPRTYPE_ZLIB', 1);\n" \
"/** @internal */ define('COUCHBASE_CMPRTYPE_FASTLZ', 2);\n" \
"\n" \
"/** @internal */ define('COUCHBASE_CFFMT_MASK', 0xFF << 24);\n" \
"/** @internal */ define('COUCHBASE_CFFMT_PRIVATE', 1 << 24);\n" \
"/** @internal */ define('COUCHBASE_CFFMT_JSON', 2 << 24);\n" \
"/** @internal */ define('COUCHBASE_CFFMT_RAW', 3 << 24);\n" \
"/** @internal */ define('COUCHBASE_CFFMT_STRING', 4 << 24);\n" \
""},
{"[CouchbaseNative]/connstr.php","\n" \
"/**\n" \
" * Various helpers for dealing with connection strings.\n" \
" *\n" \
" * @author Brett Lawson <brett19@gmail.com>\n" \
" */\n" \
"\n" \
"/**\n" \
" * Normalizes a connection string object.\n" \
" *\n" \
" * @param $dsnObj A connstr object.\n" \
" * @return array\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function _cbdsn_normalize($dsnObj) {\n" \
" $out = array();\n" \
"\n" \
" if (isset($dsnObj['scheme'])) {\n" \
" $out['scheme'] = $dsnObj['scheme'];\n" \
" } else {\n" \
" $out['scheme'] = '';\n" \
" }\n" \
"\n" \
" $out['hosts'] = array();\n" \
" if (isset($dsnObj['hosts'])) {\n" \
" if (is_string($dsnObj['hosts'])) {\n" \
" $dsnObj['hosts'] = array($dsnObj['hosts']);\n" \
" }\n" \
"\n" \
" foreach($dsnObj['hosts'] as $host) {\n" \
" if (is_string($host)) {\n" \
" $portPos = strstr($host, ':');\n" \
" if ($portPos) {\n" \
" $hostName = substr($host, 0, $portPos);\n" \
" $portNum = intval(substr($host, $portPos+1));\n" \
" array_push($out['hosts'], array(\n" \
" $hostName, $portNum\n" \
" ));\n" \
" } else {\n" \
" array_push($out['hosts'], $host);\n" \
" }\n" \
" } else {\n" \
" array_push($out['hosts'], $host);\n" \
" }\n" \
" }\n" \
" }\n" \
"\n" \
" if (isset($dsnObj['bucket'])) {\n" \
" $out['bucket'] = $dsnObj['bucket'];\n" \
" } else {\n" \
" $out['bucket'] = 'default';\n" \
" }\n" \
"\n" \
" if (isset($dsnObj['options'])) {\n" \
" $out['options'] = $dsnObj['options'];\n" \
" } else {\n" \
" $out['options'] = array();\n" \
" }\n" \
"\n" \
" return $out;\n" \
"}\n" \
"\n" \
"/**\n" \
" * Normalizes a connection string object or string.\n" \
" *\n" \
" * @param $dsn A connection string or connstr object.\n" \
" * @return array|string\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function cbdsn_normalize($dsn) {\n" \
" if (is_string($dsn)) {\n" \
" return _cbdsn_stringify(\n" \
" _cbdsn_normalize(\n" \
" _cbdsn_parse($dsn)\n" \
" )\n" \
" );\n" \
" }\n" \
" return _cbdsn_normalize($dsn);\n" \
"}\n" \
"\n" \
"/**\n" \
" * Parses a connection string into a object.\n" \
" *\n" \
" * @param $dsn A connection string.\n" \
" * @return array\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function _cbdsn_parse($dsn) {\n" \
" $out = array();\n" \
"\n" \
" if (!$dsn) {\n" \
" return $out;\n" \
" }\n" \
"\n" \
" preg_match(\"/((.*):\\\\/\\\\/)?([^\\\\/?]*)(\\\\/([^\\\\?]*))?(\\\\?(.*))?/\", $dsn, $parts);\n" \
" if (isset($parts[2])) {\n" \
" $out['scheme'] = $parts[2];\n" \
" }\n" \
" if (isset($parts[3])) {\n" \
" $out['hosts'] = array();\n" \
"\n" \
" preg_match_all(\"/([^;\\\\,\\\\:]+)(:([0-9]*))?(;\\\\,)?/\", $parts[3], $hosts, PREG_SET_ORDER);\n" \
" foreach($hosts as $host) {\n" \
" array_push($out['hosts'], array(\n" \
" $host[1],\n" \
" isset($host[3]) ? intval($host[3]) : 0\n" \
" ));\n" \
" }\n" \
" }\n" \
" if (isset($parts[5])) {\n" \
" $out['bucket'] = $parts[5];\n" \
" }\n" \
" if (isset($parts[7])) {\n" \
" $out['options'] = array();\n" \
"\n" \
" preg_match_all(\"/([^=]*)=([^&?]*)[&?]?/\", $parts[7], $kvs, PREG_SET_ORDER);\n" \
" foreach($kvs as $kv) {\n" \
" $out['options'][urldecode($kv[1])] = urldecode($kv[2]);\n" \
" }\n" \
" }\n" \
"\n" \
" return $out;\n" \
"}\n" \
"\n" \
"/**\n" \
" * Parses a connection string and ensures its normalized.\n" \
" *\n" \
" * @param $dsn A connection string.\n" \
" * @return array\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function cbdsn_parse($dsn) {\n" \
" return _cbdsn_normalize(_cbdsn_parse($dsn));\n" \
"}\n" \
"\n" \
"/**\n" \
" * Converts a connstr object to a connection string.\n" \
" *\n" \
" * @param $dsnObj\n" \
" * @return string\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function _cbdsn_stringify($dsnObj) {\n" \
" $dsn = '';\n" \
"\n" \
" if ($dsnObj['scheme']) {\n" \
" $dsn .= $dsnObj['scheme'] . '://';\n" \
" }\n" \
"\n" \
" foreach($dsnObj['hosts'] as $i => $host) {\n" \
" if ($i !== 0) {\n" \
" $dsn .= ',';\n" \
" }\n" \
" $dsn .= $host[0];\n" \
" if ($host[1]) {\n" \
" $dsn .= ':' . $host[1];\n" \
" }\n" \
" }\n" \
"\n" \
" if ($dsnObj['bucket']) {\n" \
" $dsn .= '/' . $dsnObj['bucket'];\n" \
" }\n" \
"\n" \
" if ($dsnObj['options']) {\n" \
" $isFirstOption = true;\n" \
" foreach($dsnObj['options'] as $k => $v) {\n" \
" if ($isFirstOption) {\n" \
" $dsn .= '?';\n" \
" $isFirstOption = false;\n" \
" } else {\n" \
" $dsn .= '&';\n" \
" }\n" \
" $dsn .= urlencode($k) . '=' . urlencode($v);\n" \
" }\n" \
" }\n" \
"\n" \
" return $dsn;\n" \
"}\n" \
"\n" \
"/**\n" \
" * Ensures a connstr object is normalized then generates a connection string.\n" \
" *\n" \
" * @param $dsnObj\n" \
" * @return string\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function cbdsn_stringify($dsnObj) {\n" \
" return _cbdsn_stringify(_cbdsn_normalize($dsnObj));\n" \
"}\n" \
""},
{"[CouchbaseNative]/default_transcoder.php","\n" \
"/**\n" \
" * Various transcoder functions that are packaged by default with the\n" \
" * PHP SDK.\n" \
" *\n" \
" * @author Brett Lawson <brett19@gmail.com>\n" \
" */\n" \
"\n" \
"/**\n" \
" * The default options for V1 encoding when using the default\n" \
" * transcoding functionality.\n" \
" * @internal\n" \
" */\n" \
"$COUCHBASE_DEFAULT_ENCOPTS = array(\n" \
" 'sertype' => COUCHBASE_SERTYPE_JSON,\n" \
" 'cmprtype' => COUCHBASE_CMPRTYPE_NONE,\n" \
" 'cmprthresh' => 0,\n" \
" 'cmprfactor' => 0\n" \
");\n" \
"\n" \
"/**\n" \
" * The default options from past versions of the PHP SDK.\n" \
" * @internal\n" \
" */\n" \
"$COUCHBASE_OLD_ENCOPTS = array(\n" \
" 'sertype' => COUCHBASE_SERTYPE_PHP,\n" \
" 'cmprtype' => COUCHBASE_CMPRTYPE_NONE,\n" \
" 'cmprthresh' => 2000,\n" \
" 'cmprfactor' => 1.3\n" \
");\n" \
"\n" \
"/**\n" \
" * The default options for V1 decoding when using the default\n" \
" * transcoding functionality.\n" \
" * @internal\n" \
" */\n" \
"$COUCHBASE_DEFAULT_DECOPTS = array(\n" \
" 'jsonassoc' => false\n" \
");\n" \
"\n" \
"/**\n" \
" * Performs encoding of user provided types into binary form for\n" \
" * on the server according to the original PHP SDK specification.\n" \
" *\n" \
" * @internal\n" \
" *\n" \
" * @param $value The value passed by the user\n" \
" * @param $options Various encoding options\n" \
" * @return array An array specifying the bytes, flags and datatype to store\n" \
" */\n" \
"function couchbase_basic_encoder_v1($value, $options) {\n" \
" $data = NULL;\n" \
" $flags = 0;\n" \
" $datatype = 0;\n" \
"\n" \
" $sertype = $options['sertype'];\n" \
" $cmprtype = $options['cmprtype'];\n" \
" $cmprthresh = $options['cmprthresh'];\n" \
" $cmprfactor = $options['cmprfactor'];\n" \
"\n" \
" $vtype = gettype($value);\n" \
" if ($vtype == 'string') {\n" \
" $flags = COUCHBASE_VAL_IS_STRING | COUCHBASE_CFFMT_STRING;\n" \
" $data = $value;\n" \
" } else if ($vtype == 'integer') {\n" \
" $flags = COUCHBASE_VAL_IS_LONG | COUCHBASE_CFFMT_JSON;\n" \
" $data = (string)$value;\n" \
" $cmprtype = COUCHBASE_CMPRTYPE_NONE;\n" \
" } else if ($vtype == 'double') {\n" \
" $flags = COUCHBASE_VAL_IS_DOUBLE | COUCHBASE_CFFMT_JSON;\n" \
" $data = (string)$value;\n" \
" $cmprtype = COUCHBASE_CMPRTYPE_NONE;\n" \
" } else if ($vtype == 'boolean') {\n" \
" $flags = COUCHBASE_VAL_IS_BOOL | COUCHBASE_CFFMT_JSON;\n" \
" $data = $value ? 'true' : 'false';\n" \
" $cmprtype = COUCHBASE_CMPRTYPE_NONE;\n" \
" } else {\n" \
" if ($sertype == COUCHBASE_SERTYPE_JSON) {\n" \
" $flags = COUCHBASE_VAL_IS_JSON | COUCHBASE_CFFMT_JSON;\n" \
" $data = json_encode($value);\n" \
" } else if ($sertype == COUCHBASE_SERTYPE_IGBINARY) {\n" \
" $flags = COUCHBASE_VAL_IS_IGBINARY | COUCHBASE_CFFMT_PRIVATE;\n" \
" $data = igbinary_serialize($value);\n" \
" } else if ($sertype == COUCHBASE_SERTYPE_PHP) {\n" \
" $flags = COUCHBASE_VAL_IS_SERIALIZED | COUCHBASE_CFFMT_PRIVATE;\n" \
" $data = serialize($value);\n" \
" }\n" \
" }\n" \
"\n" \
" if (strlen($data) < $cmprthresh) {\n" \
" $cmprtype = COUCHBASE_CMPRTYPE_NONE;\n" \
" }\n" \
"\n" \
" if ($cmprtype != COUCHBASE_CMPRTYPE_NONE) {\n" \
" $cmprdata = NULL;\n" \
" $cmprflags = COUCHBASE_COMPRESSION_NONE;\n" \
"\n" \
" if ($cmprtype == COUCHBASE_CMPRTYPE_ZLIB) {\n" \
" $cmprdata = couchbase_zlib_compress($data);\n" \
" $cmprflags = COUCHBASE_COMPRESSION_ZLIB;\n" \
" } else if ($cmprtype == COUCHBASE_CMPRTYPE_FASTLZ) {\n" \
" $cmprdata = couchbase_fastlz_compress($data);\n" \
" $cmprflags = COUCHBASE_COMPRESSION_FASTLZ;\n" \
" }\n" \
"\n" \
" if ($cmprdata != NULL) {\n" \
" if (strlen($data) > strlen($cmprdata) * $cmprfactor) {\n" \
" $data = $cmprdata;\n" \
" $flags |= $cmprflags;\n" \
" $flags |= COUCHBASE_COMPRESSION_MCISCOMPRESSED;\n" \
"\n" \
" $flags &= ~COUCHBASE_CFFMT_MASK;\n" \
" $flags |= COUCHBASE_CFFMT_PRIVATE;\n" \
" }\n" \
" }\n" \
" }\n" \
"\n" \
" return array($data, $flags, $datatype);\n" \
"}\n" \
"\n" \
"/**\n" \
" * Performs decoding of the server provided binary data into\n" \
" * PHP types according to the original PHP SDK specification.\n" \
" *\n" \
" * @internal\n" \
" *\n" \
" * @param $bytes The binary received from the server\n" \
" * @param $flags The flags received from the server\n" \
" * @param $datatype The datatype received from the server\n" \
" * @return mixed The resulting decoded value\n" \
" *\n" \
" * @throws CouchbaseException\n" \
" */\n" \
"function couchbase_basic_decoder_v1($bytes, $flags, $datatype, $options) {\n" \
" $cffmt = $flags & COUCHBASE_CFFMT_MASK;\n" \
" $sertype = $flags & COUCHBASE_VAL_MASK;\n" \
" $cmprtype = $flags & COUCHBASE_COMPRESSION_MASK;\n" \
"\n" \
" $data = $bytes;\n" \
" if ($cffmt != 0 && $cffmt != COUCHBASE_CFFMT_PRIVATE) {\n" \
" if ($cffmt == COUCHBASE_CFFMT_JSON) {\n" \
" $retval = json_decode($data, $options['jsonassoc']);\n" \
" } else if ($cffmt == COUCHBASE_CFFMT_RAW) {\n" \
" $retval = $data;\n" \
" } else if ($cffmt == COUCHBASE_CFFMT_STRING) {\n" \
" $retval = (string)$data;\n" \
" } else {\n" \
" throw new CouchbaseException(\"Unknown flags value -- cannot decode value\");\n" \
" }\n" \
" } else {\n" \
" if ($cmprtype == COUCHBASE_COMPRESSION_ZLIB) {\n" \
" $bytes = couchbase_zlib_decompress($bytes);\n" \
" } else if ($cmprtype == COUCHBASE_COMPRESSION_FASTLZ) {\n" \
" $data = couchbase_fastlz_decompress($bytes);\n" \
" }\n" \
"\n" \
" $retval = NULL;\n" \
" if ($sertype == COUCHBASE_VAL_IS_STRING) {\n" \
" $retval = $data;\n" \
" } else if ($sertype == COUCHBASE_VAL_IS_LONG) {\n" \
" $retval = intval($data);\n" \
" } else if ($sertype == COUCHBASE_VAL_IS_DOUBLE) {\n" \
" $retval = floatval($data);\n" \
" } else if ($sertype == COUCHBASE_VAL_IS_BOOL) {\n" \
" $retval = $data != \"\";\n" \
" } else if ($sertype == COUCHBASE_VAL_IS_JSON) {\n" \
" $retval = json_decode($data, $options['jsonassoc']);\n" \
" } else if ($sertype == COUCHBASE_VAL_IS_IGBINARY) {\n" \
" $retval = igbinary_unserialize($data);\n" \
" } else if ($sertype == COUCHBASE_VAL_IS_SERIALIZED) {\n" \
" $retval = unserialize($data);\n" \
" }\n" \
" }\n" \
"\n" \
" return $retval;\n" \
"}\n" \
"\n" \
"/**\n" \
" * Default passthru encoder which simply passes data\n" \
" * as-is rather than performing any transcoding.\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function couchbase_passthru_encoder($value) {\n" \
" return array($value, 0, 0);\n" \
"}\n" \
"\n" \
"/**\n" \
" * Default passthru encoder which simply passes data\n" \
" * as-is rather than performing any transcoding.\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function couchbase_passthru_decoder($bytes, $flags, $datatype) {\n" \
" return $bytes;\n" \
"}\n" \
"\n" \
"/**\n" \
" * The default encoder for the client. Currently invokes the\n" \
" * v1 encoder directly with the default set of encoding options.\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function couchbase_default_encoder($value) {\n" \
" global $COUCHBASE_DEFAULT_ENCOPTS;\n" \
" return couchbase_basic_encoder_v1($value, $COUCHBASE_DEFAULT_ENCOPTS);\n" \
"}\n" \
"\n" \
"/**\n" \
" * The default decoder for the client. Currently invokes the\n" \
" * v1 decoder directly.\n" \
" *\n" \
" * @internal\n" \
" */\n" \
"function couchbase_default_decoder($bytes, $flags, $datatype) {\n" \
" global $COUCHBASE_DEFAULT_DECOPTS;\n" \
" return couchbase_basic_decoder_v1($bytes, $flags, $datatype, $COUCHBASE_DEFAULT_DECOPTS);\n" \
"}\n" \
""},
{"[CouchbaseNative]/CouchbaseViewQuery.class.php","\n" \
"/**\n" \
" * File for the CouchbaseViewQuery class.\n" \
" */\n" \
"\n" \
"/**\n" \
" * Represents a view query to be executed against a Couchbase bucket.\n" \
" *\n" \
" * @package Couchbase\n" \
" */\n" \
"class CouchbaseViewQuery {\n" \
" /**\n" \
" * @var string\n" \
" * @internal\n" \
" */\n" \
" public $ddoc = '';\n" \
"\n" \
" /**\n" \
" * @var string\n" \
" * @internal\n" \
" */\n" \
" public $name = '';\n" \
"\n" \
" /**\n" \
" * @var array\n" \
" * @internal\n" \
" */\n" \
" public $options = array();\n" \
"\n" \
" const UPDATE_BEFORE = 1;\n" \
" const UPDATE_NONE = 2;\n" \
" const UPDATE_AFTER = 3;\n" \
"\n" \
" const ORDER_ASCENDING = 1;\n" \
" const ORDER_DESCENDING = 2;\n" \
"\n" \
" /**\n" \
" * @internal\n" \
" */\n" \
" private function __construct() {\n" \
" }\n" \
"\n" \
" /**\n" \
" * Creates a new Couchbase ViewQuery instance for performing a view query.\n" \
" *\n" \
" * @param $ddoc The name of the design document to query.\n" \
" * @param $name The name of the view to query.\n" \
" * @return _CouchbaseDefaultViewQuery\n" \
" */\n" \
" static public function from($ddoc, $name) {\n" \
" $res = new _CouchbaseDefaultViewQuery();\n" \
" $res->ddoc = $ddoc;\n" \
" $res->name = $name;\n" \
" return $res;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Creates a new Couchbase ViewQuery instance for performing a spatial query.\n" \
" *\n" \
" * @param $ddoc The name of the design document to query.\n" \
" * @param $name The name of the view to query.\n" \
" * @return _CouchbaseSpatialViewQuery\n" \
" */\n" \
" static public function fromSpatial($ddoc, $name) {\n" \
" $res = new _CouchbaseSpatialViewQuery();\n" \
" $res->ddoc = $ddoc;\n" \
" $res->name = $name;\n" \
" return $res;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies the mode of updating to perform before and after executing\n" \
" * this query.\n" \
" *\n" \
" * @param $stale\n" \
" * @return $this\n" \
" * @throws CouchbaseException\n" \
" */\n" \
" public function stale($stale) {\n" \
" if ($stale == self::UPDATE_BEFORE) {\n" \
" $this->options['stale'] = 'false';\n" \
" } else if ($stale == self::UPDATE_NONE) {\n" \
" $this->options['stale'] = 'ok';\n" \
" } else if ($stale == self::UPDATE_AFTER) {\n" \
" $this->options['stale'] = 'update_after';\n" \
" } else {\n" \
" throw new CouchbaseException('invalid option passed.');\n" \
" }\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Skips a number of records from the beginning of the result set.\n" \
" *\n" \
" * @param $skip\n" \
" * @return $this\n" \
" */\n" \
" public function skip($skip) {\n" \
" $this->options['skip'] = '' . $skip;\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Limits the result set to a restricted number of results.\n" \
" *\n" \
" * @param $limit\n" \
" * @return $this\n" \
" */\n" \
" public function limit($limit) {\n" \
" $this->options['limit'] = '' . $limit;\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies custom options to pass to the server. Note that these\n" \
" * options are expected to be already encoded.\n" \
" *\n" \
" * @param $opts\n" \
" * @return $this\n" \
" */\n" \
" public function custom($opts) {\n" \
" foreach ($opts as $k => $v) {\n" \
" $this->options[$k] = $v;\n" \
" }\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Generates the view query as it will be passed to the server.\n" \
" *\n" \
" * @return string\n" \
" * @internal\n" \
" */\n" \
" public function _toString($type) {\n" \
" $path = '/_design/' . $this->ddoc . '/' . $type . '/' . $this->name;\n" \
" $args = array();\n" \
" foreach ($this->options as $option => $value) {\n" \
" array_push($args, $option . '=' . urlencode($value));\n" \
" }\n" \
" $path .= '?' . implode('&', $args);\n" \
" return $path;\n" \
" }\n" \
"};\n" \
"\n" \
"/**\n" \
" * Represents a regular view query to perform against the server. Note that\n" \
" * this object should never be instantiated directly, but instead through\n" \
" * the CouchbaseViewQuery::from method.\n" \
" *\n" \
" * @package Couchbase\n" \
" */\n" \
"class _CouchbaseDefaultViewQuery extends CouchbaseViewQuery {\n" \
"\n" \
" /**\n" \
" * @internal\n" \
" */\n" \
" public function __construct() {\n" \
" }\n" \
"\n" \
" /**\n" \
" * Orders the results by key as specified.\n" \
" *\n" \
" * @param $order\n" \
" * @return $this\n" \
" * @throws CouchbaseException\n" \
" */\n" \
" public function order($order) {\n" \
" if ($order == self::ORDER_ASCENDING) {\n" \
" $this->options['descending'] = 'false';\n" \
" } else if ($order == self::ORDER_DESCENDING) {\n" \
" $this->options['descending'] = 'true';\n" \
" } else {\n" \
" throw new CouchbaseException('invalid option passed.');\n" \
" }\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies a reduction function to apply to the index.\n" \
" *\n" \
" * @param $reduce\n" \
" * @return $this\n" \
" */\n" \
" public function reduce($reduce) {\n" \
" if ($reduce) {\n" \
" $this->options['reduce'] = 'true';\n" \
" } else {\n" \
" $this->options['reduce'] = 'false';\n" \
" }\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies the level of grouping to use on the results.\n" \
" *\n" \
" * @param $group_level\n" \
" * @return $this\n" \
" */\n" \
" public function group($group) {\n" \
" if ($group == true) {\n" \
" $this->options['group'] = 'true';\n" \
" } else if ($group == false) {\n" \
" $this->options['group'] = 'false';\n" \
" \n" \
" // For backwards compatibility\n" \
" } else if ($group >= 0) {\n" \
" $this->options['group'] = 'false';\n" \
" $this->options['group_level'] = $group;\n" \
" } else {\n" \
" $this->options['group'] = 'true';\n" \
" $this->options['group_level'] = 0;\n" \
" }\n" \
" return $this;\n" \
" }\n" \
" \n" \
" /**\n" \
" * Specifies the level at which to perform view grouping.\n" \
" * \n" \
" * @param $group_level\n" \
" * @returns $this\n" \
" */\n" \
" public function group_level($group_level) {\n" \
" if ($group_level >= 0) {\n" \
" $this->options['group_level'] = $group_level;\n" \
" } else {\n" \
" unset($this->options['group_level']);\n" \
" }\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies a specific key to return from the index.\n" \
" *\n" \
" * @param $key\n" \
" * @return $this\n" \
" */\n" \
" public function key($key) {\n" \
" $this->options['key'] = \n" \
" str_replace('\\\\\\\\', '\\\\', json_encode($key));\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies a list of keys to return from the index.\n" \
" *\n" \
" * @param $keys\n" \
" * @return $this\n" \
" */\n" \
" public function keys($keys) {\n" \
" $this->options['keys'] =\n" \
" str_replace('\\\\\\\\', '\\\\', json_encode($keys));\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies a range of keys to return from the index.\n" \
" *\n" \
" * @param mixed $start\n" \
" * @param mixed $end\n" \
" * @param bool $inclusive_end\n" \
" * @return $this\n" \
" */\n" \
" public function range($start = NULL, $end = NULL, $inclusive_end = false) {\n" \
" if ($start !== NULL) {\n" \
" $this->options['startkey'] =\n" \
" str_replace('\\\\\\\\', '\\\\', json_encode($start));\n" \
" } else {\n" \
" unset($this->options['startkey']);\n" \
" }\n" \
" if ($end !== NULL) {\n" \
" $this->options['endkey'] =\n" \
" str_replace('\\\\\\\\', '\\\\', json_encode($end));\n" \
" } else {\n" \
" unset($this->options['endkey']);\n" \
" }\n" \
" $this->options['inclusive_end'] = $inclusive_end ? 'true' : 'false';\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies a range of document ids to return from the index.\n" \
" *\n" \
" * @param null $start\n" \
" * @param null $end\n" \
" * @return $this\n" \
" */\n" \
" public function id_range($start = NULL, $end = NULL) {\n" \
" if ($start !== NULL) {\n" \
" $this->options['startkey_docid'] =\n" \
" str_replace('\\\\\\\\', '\\\\', json_encode($start));\n" \
" } else {\n" \
" $this->options['startkey_docid'] = '';\n" \
" }\n" \
" if ($end !== NULL) {\n" \
" $this->options['endkey_docid'] =\n" \
" str_replace('\\\\\\\\', '\\\\', json_encode($end));\n" \
" } else {\n" \
" $this->options['endkey_docid'] = '';\n" \
" }\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Generates the view query as it will be passed to the server.\n" \
" *\n" \
" * @return string\n" \
" */\n" \
" public function toString() {\n" \
" return $this->_toString('_view');\n" \
" }\n" \
"};\n" \
"\n" \
"/**\n" \
" * Represents a spatial view query to perform against the server. Note that\n" \
" * this object should never be instantiated directly, but instead through\n" \
" * the CouchbaseViewQuery::fromSpatial method.\n" \
" *\n" \
" * @package Couchbase\n" \
" */\n" \
"class _CouchbaseSpatialViewQuery extends CouchbaseViewQuery {\n" \
"\n" \
" /**\n" \
" * @internal\n" \
" */\n" \
" public function __construct() {\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specifies the bounding box to search within.\n" \
" *\n" \
" * @param number[] $bbox\n" \
" * @return $this\n" \
" */\n" \
" public function bbox($bbox) {\n" \
" $this->options['bbox'] = implode(',', $bbox);\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Generates the view query as it will be passed to the server.\n" \
" *\n" \
" * @return string\n" \
" */\n" \
" public function toString() {\n" \
" return $this->_toString('_spatial');\n" \
" }\n" \
"};\n" \
""},
{"[CouchbaseNative]/CouchbaseN1qlQuery.class.php","\n" \
"/**\n" \
" * File for the CouchbaseN1qlQuery class.\n" \
" */\n" \
"\n" \
"/**\n" \
" * Represents a N1QL query to be executed against a Couchbase bucket.\n" \
" *\n" \
" * @package Couchbase\n" \
" */\n" \
"class CouchbaseN1qlQuery {\n" \
" /**\n" \
" * @var string\n" \
" * @internal\n" \
" */\n" \
" public $options = array();\n" \
"\n" \
" const NOT_BOUNDED = 1;\n" \
" const REQUEST_PLUS = 2;\n" \
" const STATEMENT_PLUS = 3;\n" \
"\n" \
" /**\n" \
" * Creates a new N1qlQuery instance directly from a N1QL DML.\n" \
" * @param $str\n" \
" * @return CouchbaseN1qlQuery\n" \
" */\n" \
" static public function fromString($str) {\n" \
" $res = new CouchbaseN1qlQuery();\n" \
" $res->options['statement'] = $str;\n" \
" $res->adhoc = true;\n" \
" return $res;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specify the consistency level for this query.\n" \
" *\n" \
" * @param $consistency\n" \
" * @return $this\n" \
" * @throws CouchbaseN1qlQuery\n" \
" */\n" \
" public function consistency($consistency) {\n" \
" if ($consistency == self::NOT_BOUNDED) {\n" \
" $this->options['scan_consistency'] = 'not_bounded';\n" \
" } else if ($consistency == self::REQUEST_PLUS) {\n" \
" $this->options['scan_consistency'] = 'request_plus';\n" \
" } else if ($consistency == self::STATEMENT_PLUS) {\n" \
" $this->options['scan_consistency'] = 'statement_plus';\n" \
" } else {\n" \
" throw new CouchbaseException('invalid option passed.');\n" \
" }\n" \
" return $this;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Specify whether this query is a one-time query, or if it\n" \
" * if it should be prepared.\n" \
" *\n" \
" * @param $adhoc\n" \
" * @return $this\n" \
" * @throws CouchbaseN1qlQuery\n" \
" */\n" \
" public function adhoc($adhoc) {\n" \
" $this->adhoc = !!$adhoc;\n" \
" }\n" \
"\n" \
" /**\n" \
" * Generates the N1QL object as it will be passed to the server.\n" \
" *\n" \
" * @return object\n" \
" */\n" \
" public function toObject() {\n" \
" return $this->options;\n" \
" }\n" \
" \n" \
" /**\n" \
" * Returns the string representation of this N1ql query (the statement).\n" \
" *\n" \
" * @return string\n" \
" */\n" \
" public function toString() {\n" \
" return $this->options['statement'];\n" \
" }\n" \
"}\n" \
""},
{"[CouchbaseNative]/CouchbaseCluster.class.php","\n" \
"/**\n" \
" * File for the CouchbaseCluster class.\n" \
" *\n" \
" * @author Brett Lawson <brett19@gmail.com>\n" \
" */\n" \
"\n" \
"/**\n" \
" * Represents a cluster connection.\n" \
" *\n" \
" * @package Couchbase\n" \
" */\n" \
"class CouchbaseCluster {\n" \
" /**\n" \
" * @var _CouchbaseCluster\n" \
" * @ignore\n" \
" *\n" \
" * Pointer to a manager instance if there is one.\n" \
" */\n" \
" private $_manager = NULL;\n" \
"\n" \
" /**\n" \
" * @var string\n" \
" * @ignore\n" \
" *\n" \
" * A cluster connection string to connect with.\n" \
" */\n" \
" private $_dsn;\n" \
"\n" \
" /**\n" \
" * Creates a connection to a cluster.\n" \
" *\n" \
" * Creates a CouchbaseCluster object and begins the bootstrapping\n" \
" * process necessary for communications with the Couchbase Server.\n" \
" *\n" \
" * @param string $connstr A cluster connection string to connect with.\n" \
" * @param string $username The username for the cluster.\n" \
" * @param string $password The password for the cluster.\n" \
" *\n" \
" * @throws CouchbaseException\n" \
" */\n" \
" public function __construct($connstr = 'http://127.0.0.1/', $username = '', $password = '') {\n" \
" $this->_dsn = cbdsn_parse($connstr);\n" \
" }\n" \
"\n" \
" /**\n" \
" * Constructs a connection to a bucket.\n" \
" *\n" \
" * @param string $name The name of the bucket to open.\n" \
" * @param string $password The bucket password to authenticate with.\n" \
" * @return CouchbaseBucket A bucket object.\n" \
" *\n" \
" * @throws CouchbaseException\n" \
" *\n" \
" * @see CouchbaseBucket CouchbaseBucket\n" \
" */\n" \
" public function openBucket($name = 'default', $password = '') {\n" \
" $bucketDsn = cbdsn_normalize($this->_dsn);\n" \
" $bucketDsn['bucket'] = $name;\n" \
" $dsnStr = cbdsn_stringify($bucketDsn);\n" \
" return new CouchbaseBucket($dsnStr, $name, $password);\n" \
" }\n" \
"\n" \
" /**\n" \
" * Creates a manager allowing the management of a Couchbase cluster.\n" \
" *\n" \
" * @param $username The administration username.\n" \
" * @param $password The administration password.\n" \
" * @return CouchbaseClusterManager\n" \
" */\n" \
" public function manager($username, $password) {\n" \
" if (!$this->_manager) {\n" \
" $this->_manager = new CouchbaseClusterManager(\n" \
" cbdsn_stringify($this->_dsn), $username, $password);\n" \
" }\n" \
" return $this->_manager;\n" \
" }\n" \
"\n" \
"}\n" \
""},
{"[CouchbaseNative]/CouchbaseClusterManager.class.php","\n" \
"/**\n" \
" * File for the CouchbaseClusterManager class.\n" \
" *\n" \
" * @author Brett Lawson <brett19@gmail.com>\n" \
" */\n" \
"\n" \
"/**\n" \
" * Class exposing the various available management operations that can be\n" \
" * performed on a cluster.\n" \
" *\n" \
" * @package Couchbase\n" \
" */\n" \
"class CouchbaseClusterManager {\n" \
" /**\n" \
" * @var _CouchbaseCluster\n" \
" * @ignore\n" \
" *\n" \
" * Pointer to our C binding backing class.\n" \
" */\n" \
" private $_me;\n" \
"\n" \
" /**\n" \
" * Constructs a cluster manager connection.\n" \
" *\n" \
" * @param string $connstr A connection string to connect with.\n" \
" * @param string $username The username to authenticate with.\n" \
" * @param string $password The password to authenticate with.\n" \
" *\n" \
" * @private\n" \
" * @ignore\n" \
" */\n" \
" public function __construct($connstr, $username, $password) {\n" \
" $this->_me = new _CouchbaseCluster($connstr, $username, $password);\n" \
" }\n" \