il.h"
typedef struct PLCB_st PLCB_t;
enum {
PLCB_CONVERTERS_CUSTOM = 1,
PLCB_CONVERTERS_JSON,
PLCB_CONVERTERS_STORABLE
};
enum {
PLCB_SETTING_INT,
PLCB_SETTING_UINT,
PLCB_SE
PLCB_OPCTXIDX_REMAINING,
PLCB_OPCTXIDX_QUEUE,
PLCB_OPCTXIDX_EXTRA
};
enum {
PLCB_LF_JSON = 0x00,
PLCB_LF_STORABLE = 0x01 << 3,
PLCB_LF_RAW = 0x03 << 3,
PLCB_LF_UTF8 = 0x04 <<
B_CF_NONE,
PLCB_CF_PRIVATE = 0x01 << 24,
PLCB_CF_STORABLE = PLCB_CF_PRIVATE,
PLCB_CF_JSON = 0x02 << 24,
PLCB_CF_RAW = 0x03 << 24,
PLCB_CF_UTF8 = 0x04 << 24,
PLCB_CF_MASK = 0xF
use Couchbase::_GlueConstants;
use Couchbase::N1QL::Params;
use JSON::MaybeXS;
use base (qw(Couchbase::View::Handle));
my $JSON = JSON::MaybeXS->new->allow_nonref;
sub new {
my ($cls, $bucket,
h %$qargs) {
$pobj->namedparam("\$$k", $JSON->encode($v));
}
} elsif (ref $qargs eq 'ARRAY') {
$pobj->posparam($JSON->encode($_)) for @$qargs;
}
while (my ($k,
urn bless $self, $cls;
}
sub process_meta {
my ($self) = @_;
eval {
$self->meta($JSON->decode($self->meta));
}; if ($@) {
return;
}
$self->_priv->{errinfo} = $sel
t->fld = NULL; }
_free_cv(cv_serialize); _free_cv(cv_deserialize);
_free_cv(cv_jsonenc); _free_cv(cv_jsondec);
_free_cv(cv_customenc); _free_cv(cv_customdec);
#undef _free_cv
}
/*Cons
ct->cv_customdec;
} else if (type == PLCB_CONVERTERS_JSON) {
*cv_encode = &object->cv_jsonenc;
*cv_decode = &object->cv_jsondec;
} else if (type == PLCB_CONVERTERS_STORABLE) {
e("Client does not have a config yet");
}
tmpstr = lcbvb_save_json(orig);
if (!tmpstr) {
die("Couldn't get JSON dump");
}
cp = lcbvb_create();
if (!cp) {
free(t
package Couchbase::Bucket;
use strict;
use warnings;
use JSON::MaybeXS;
use URI;
use Storable;
use Couchbase::Core;
use Couchbase::_GlueConstants;
use Couchbase::Document;
use Couchbase::Settings;
TPDocument;
use Couchbase::N1QL::Handle;
my $_JSON = JSON::MaybeXS->new()->allow_nonref;
sub _js_encode { $_JSON->encode($_[0]) }
sub _js_decode { $_JSON->decode($_[0]) }
sub new {
my ($pkg, $co
);
$self->connect() unless $noconn;
$self->_encoder(CONVERTERS_JSON, \&_js_encode);
$self->_decoder(CONVERTERS_JSON, \&_js_decode);
$self->_encoder(CONVERTERS_STORABLE, \&Storable::fr
],
bucket => [ 0x30, SETTING_STRING ]
);
my %ENCMAP = (
json_encoder => CONVERTERS_JSON,
json_decoder => CONVERTERS_JSON,
storable_encoder => CONVERTERS_STORABLE,
storable_decode
ings();
$settings->{operation_timeout} = 5.0;
# Or
$bucket->settings->{json_encoder} = sub { encode_json(shift) };
=head1 DESCRIPTION
This object represents a tied hash which can modif
onnected to.
=item C<json_encoder>
Takes a subroutine reference which returns an encoded JSON string from a Perl object.
This may be used if you wish to use an alternate JSON encoder. The function
Couchbase::_GlueConstants;
use Couchbase;
use base qw(Exporter);
our @EXPORT = (qw(COUCHBASE_FMT_JSON COUCHBASE_FMT_UTF8 COUCHBASE_FMT_RAW COUCHBASE_FMT_STORABLE));
use Class::XSAccessor::Array {
$pkg;
$rv->id($id);
$rv->value($doc);
$rv->errnum(-1);
$rv->format(COUCHBASE_FMT_JSON);
if ($options) {
while (my ($k,$v) = each %$options) {
no strict 'refs'
SE_FMT_UTF8,
raw => COUCHBASE_FMT_RAW,
storable => COUCHBASE_FMT_STORABLE,
json => COUCHBASE_FMT_JSON
);
our %FMT_NUM2STR = reverse(%FMT_STR2NUM);
sub format {
my ($self, $fmtspec) =
cessor {
accessors => [ qw(cbo) ]
};
use constant {
DESIGN_NAME => "blog"
};
my $DESIGN_JSON = {
_id => "_design/blog",
language => "javascript",
views => {
recent_posts
st(no_plan) {
my $self = shift;
my $o = $self->cbo;
my $ret = $o->design_put($DESIGN_JSON);
ok($ret->is_ok, "Design doc put did not return errors");
my $design = $o->design_get(D
ve HTTP 200");
ok($design->is_ok, "Overall object OK");
is_deeply($design->value, $DESIGN_JSON, "Got back view");
}
sub TV02_create_invalid_ddoc :Test(no_plan) {
my $self = shift;
my
is($exptxt, $doc->value,
"Serializing/Deserializing UTF-8 characters (not bytes!) = FMT_JSON");
$doc->format('utf8');
$o->upsert($doc);
$o->get($doc);
is($exptxt, $doc->valu
ois.kisa.or.kr에서 서비스 되고 있습니다.";
my $doc = Couchbase::Document->new('utf8json', { string => $txt });
my $cb = $self->cbo;
$cb->upsert($doc);
$cb->get($doc);
is
Couchbase;
use Couchbase::_GlueConstants;
use URI::Escape qw(uri_escape);
use Carp qw(cluck);
use JSON::MaybeXS;
use base (qw(Couchbase::Document));
use Constant::Generate [qw(ERRINFO ROWCOUNT REQFLAG
,
rows => VHIDX_ROWBUF,
meta => VHIDX_META,
remaining_json => VHIDX_META,
http_code => VHIDX_HTCODE
};
my $JSON = JSON::MaybeXS->new->allow_nonref;
sub new {
my ($cls, $parent, $
JSON
# parser.
my $parse_whole =
$self->[VHIDX_PLPRIV]->[REQFLAGS] & LCB_CMDVIEWQUERY_F_NOROWPARSE;
foreach my $row (@$rows) {
if ($parse_whole) {
$row = $JSON
cfg)
PREINIT:
SV *sv;
char *s;
CODE:
s = lcbvb_save_json(cfg);
if (!s) {
die("Couldn't get JSON!");
}
sv = newSV(0);
sv_usepvn(sv, s, strlen(s));
RETVA
emory");
}
if (0 != lcbvb_load_json(vbc, s)) {
const char *err = lcbvb_get_error(vbc);
lcbvb_destroy(vbc);
die("Couldn't load json: %s", err);
}
RETVAL = vbc;