本文整理汇总了C++中IOASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ IOASSERT函数的具体用法?C++ IOASSERT怎么用?C++ IOASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IOASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IoObject_getSlot_
IoObject *IoTokyoCabinetPrefixCursor_key(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc TokyoCabinetPrefixCursor key
Returns current cursor key or nil.
*/
int size;
char *ks;
IoSeq *prefix = IoObject_getSlot_(self, IOSYMBOL("prefix"));
IOASSERT(ISSEQ(prefix), "prefix must be a sequence");
IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
ks = tcbdbcurkey(TokyoCabinetPrefixCursor(self), &size);
if (ks)
{
UArray *k = UArray_newWithData_type_size_copy_(ks, CTYPE_uint8_t, size, 1);
if (UArray_beginsWith_(k, IoSeq_rawUArray(prefix)))
{
//printf("prefix '%s'\n", UArray_bytes(IoSeq_rawUArray(prefix)));
//printf("before clip '%s'\n", UArray_bytes(k));
UArray_clipBeforeEndOf_(k, IoSeq_rawUArray(prefix));
UArray_removeFirst(k); // remove separator
//printf("after clip '%s'\n", UArray_bytes(k));
return IoSeq_newWithUArray_copy_(IOSTATE, k, 0);
}
UArray_free(k);
}
return IONIL(self);
}
示例2: IO_METHOD
IO_METHOD(IoDate, setDay)
{
/*doc Date setDay(aNumber)
Sets the day of the receiver. Returns self.
*/
int v = IoMessage_locals_intArgAt_(m, locals, 0);
int month = Date_month(DATA(self)) + 1;
IOASSERT(v >= 1 && v <= 31, "day must be within range 1-31");
if (month == 2)
{
if (Date_isLeapYear(DATA(self)))
{
IOASSERT(v >= 1 && v <= 29, "day must be within range 1-29");
}
else
{
IOASSERT(v >= 1 && v <= 28, "day must be within range 1-28");
}
}
else if (month == 11)
{
IOASSERT(v >= 1 && v <= 30, "day must be within range 1-30");
}
else if (month == 12)
{
IOASSERT(v >= 1 && v <= 31, "day must be within range 1-31");
}
Date_setDay_(DATA(self), v);
IoObject_isDirty_(self, 1);
return self;
}
示例3: IoMessage_locals_listArgAt_
/*doc Memcached getMulti(keys)
Asks memcached to retrieve data corresponding to the list of keys.
Returns a Map with the results.
If some of the keys appearing in a retrieval request are not sent back
by the server in the item list this means that the server does not
hold items with such keys
*/
IoObject *IoMemcached_getMulti(IoMemcached *self, IoObject *locals, IoMessage *m)
{
IoList *keys_list = IoMessage_locals_listArgAt_(m, locals, 0);
size_t keys_list_size = IoList_rawSize(keys_list);
IoObject *results_map = IoMap_new(IOSTATE);
if(keys_list_size == 0)
return results_map;
int i;
for(i = 0; i < keys_list_size; i++) {
IoSeq *key = IoList_rawAt_(keys_list, i);
IOASSERT(ISSEQ(key), "key must be a Sequence");
IOASSERT(IOSEQ_LENGTH(key) > 0, "key cannot be an empty Sequence");
IOASSERT(IOSEQ_LENGTH(key) < MEMCACHED_MAX_KEY, "key is too long");
}
const char **ckeys = (const char **) malloc(sizeof(const char *) * keys_list_size);
size_t *ckey_lengths = (size_t *) malloc(sizeof(size_t) * keys_list_size);
for(i = 0; i < keys_list_size; i++) {
ckeys[i] = CSTRING(IoList_rawAt_(keys_list, i));
ckey_lengths[i] = strlen(ckeys[i]);
}
memcached_return_t rc = memcached_mget(DATA(self)->mc, ckeys, ckey_lengths, keys_list_size);
free(ckeys);
free(ckey_lengths);
char returned_key[MEMCACHED_MAX_KEY], *returned_value;
size_t returned_key_length, returned_value_length;
uint32_t flags;
returned_value = memcached_fetch(DATA(self)->mc,
returned_key, &returned_key_length,
&returned_value_length, &flags, &rc
);
while(returned_value != NULL) {
IoMap_rawAtPut(results_map,
IoSeq_newSymbolWithData_length_(IOSTATE, returned_key, returned_key_length),
IoMemcached_deserialize(self, returned_value, returned_value_length, flags)
);
free(returned_value);
returned_value = memcached_fetch(DATA(self)->mc,
returned_key, &returned_key_length,
&returned_value_length, &flags, &rc
);
}
return results_map;
}
示例4: IOASSERT
IoObject *IoTokyoCabinetPrefixCursor_remove(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc TokyoCabinetPrefixCursor remove
Removes the current cursor postion. Returns self.
*/
IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
IOASSERT(tcbdbcurout(TokyoCabinetPrefixCursor(self)), tcbdberrmsg(tcbdbecode(TokyoCabinet(self))));
return self;
}
示例5: IoMessage_locals_seqArgAt_
IoObject *IoTokyoCabinetPrefixCursor_put(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc TokyoCabinetPrefixCursor put(value)
Sets the value at the current cursor postion. Returns self.
*/
IoSeq *value = IoMessage_locals_seqArgAt_(m, locals, 0);
IOASSERT(TokyoCabinetPrefixCursor(self), "invalid TokyoCabinetPrefixCursor");
IOASSERT(tcbdbcurput(TokyoCabinetPrefixCursor(self), (const char *)IoSeq_rawBytes(value), IoSeq_rawSizeInBytes(value), BDBCPCURRENT), tcbdberrmsg(tcbdbecode(TokyoCabinet(self))));
return self;
}
示例6: IoObject_getSlot_
IoObject *IoEvConnection_connect(IoEvConnection *self, IoObject *locals, IoMessage *m)
{
IoEventManager *em = IoObject_getSlot_(self, IOSYMBOL("eventManager"));
IoSeq *address = IoObject_seqGetSlot_(self, IOSYMBOL("address"));
int port = IoObject_doubleGetSlot_(self, IOSYMBOL("port"));
IOASSERT(CONN(self) == 0x0, "already have connection");
IOASSERT(ISEEVENTMANAGER(em), "eventManager slot not set properly");
//printf("IoEventManager_rawBase(em) = %p\n", (void *)IoEventManager_rawBase(em));
IoObject_setDataPointer_(self, evhttp_connection_new(CSTRING(address), port));
evhttp_connection_set_base(CONN(self), IoEventManager_rawBase(em));
evhttp_connection_set_closecb(CONN(self), IoEvConnection_ConnectionCloseCallback, self);
return self;
}
示例7: th_decode_ycbcr_out
IoObject *IoTheoraDecodeContext_ycbcr(IoTheoraDecodeContext *self, IoObject *locals, IoMessage *m)
{
/*doc TheoraDecodecontext ycbcr
Returns an object containing the YUV data from the decoded frame.
*/
th_ycbcr_buffer buffer;
int ret = th_decode_ycbcr_out(DATA(self)->ctx, buffer);
IOASSERT(ret == 0, "th_decode_ycbcr_out failed");
IoObject* yuv0 = IoObject_new(IOSTATE);
IoObject* yuv1 = IoObject_new(IOSTATE);
IoObject* yuv2 = IoObject_new(IOSTATE);
IoObject_setSlot_to_(yuv0, IOSYMBOL("width"), IONUMBER(buffer[0].width));
IoObject_setSlot_to_(yuv0, IOSYMBOL("height"), IONUMBER(buffer[0].height));
IoObject_setSlot_to_(yuv0, IOSYMBOL("stride"), IONUMBER(buffer[0].stride));
IoObject_setSlot_to_(yuv0, IOSYMBOL("data"), IOSEQ(buffer[0].data, buffer[0].stride * buffer[0].height));
IoObject_setSlot_to_(yuv1, IOSYMBOL("width"), IONUMBER(buffer[1].width));
IoObject_setSlot_to_(yuv1, IOSYMBOL("height"), IONUMBER(buffer[1].height));
IoObject_setSlot_to_(yuv1, IOSYMBOL("stride"), IONUMBER(buffer[1].stride));
IoObject_setSlot_to_(yuv1, IOSYMBOL("data"), IOSEQ(buffer[1].data, buffer[1].stride * buffer[1].height));
IoObject_setSlot_to_(yuv2, IOSYMBOL("width"), IONUMBER(buffer[2].width));
IoObject_setSlot_to_(yuv2, IOSYMBOL("height"), IONUMBER(buffer[2].height));
IoObject_setSlot_to_(yuv2, IOSYMBOL("stride"), IONUMBER(buffer[2].stride));
IoObject_setSlot_to_(yuv2, IOSYMBOL("data"), IOSEQ(buffer[2].data, buffer[2].stride * buffer[2].height));
IoList* result = IoList_new(IOSTATE);
IoList_rawAppend_(result, yuv0);
IoList_rawAppend_(result, yuv1);
IoList_rawAppend_(result, yuv2);
return result;
}
示例8: IoState_currentCoroutine
IoObject *IoObject_performWithDebugger(IoCoroutine *self, IoObject *locals, IoMessage *m)
{
IoState *state = IOSTATE;
IoObject *currentCoroutine = IoState_currentCoroutine(state);
if (IoCoroutine_rawDebuggingOn(currentCoroutine))
{
IoObject *debugger = state->debugger; // stack retain it?
if (debugger)
{
IoObject_setSlot_to_(debugger, IOSYMBOL("messageCoroutine"), currentCoroutine);
IoObject_setSlot_to_(debugger, IOSYMBOL("messageSelf"), self);
IoObject_setSlot_to_(debugger, IOSYMBOL("messageLocals"), locals);
IoObject_setSlot_to_(debugger, IOSYMBOL("message"), m);
{
IoObject *context;
IoCoroutine *c = IoObject_rawGetSlot_context_(debugger, IOSYMBOL("debuggerCoroutine"), &context);
IOASSERT(c, "Debugger needs a debuggerCoroutine slot");
IoCoroutine_rawResume(c);
}
}
}
return IoObject_perform(self, locals, m);
}
示例9: DATA
Uint64Array *IoTagDB_tagArrayForTagNames_(IoTagDB *self, IoMessage *m, IoList *tagNames)
{
TagDB *tdb = DATA(self);
Uint64Array *tags = Uint64Array_new();
int i;
for (i = 0; i < IoList_rawSize(tagNames); i ++)
{
IoSeq *tagName = IoList_rawAt_(tagNames, i);
symbolid_t keyid;
IOASSERT(ISSEQ(tagName), "tag names must be Sequences");
keyid = TagDB_idForSymbol_size_(tdb, CSTRING(tagName), IoSeq_rawSize(tagName));
Uint64Array_append_(tags, keyid);
/*
{
Datum *keyDatum = TagDB_symbolForId_(tdb, keyid);
printf("%s -> %i && ", CSTRING(tagName), (int)keyid);
printf("%i -> %s\n", (int)keyid, (char *)(keyDatum->data));
Datum_free(keyDatum);
}
*/
}
return tags;
}
示例10: IOASSERT
IoObject *IoTokyoCabinetCursor_last(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc TokyoCabinetCursor last
Move cursor to last record. Returns self
*/
IOASSERT(TokyoCabinetCursor(self), "invalid TokyoCabinetCursor");
return IOBOOL(self, tcbdbcurlast(TokyoCabinetCursor(self)));
}
示例11: IO_METHOD
IO_METHOD(IoSeq, insertSeqEvery)
{
/*doc MutableSequence IoSeq_insertSeqEvery(aSequence, aNumberOfItems)
Inserts aSequence every aNumberOfItems. Returns self.
*/
IoSeq *otherSeq = IoMessage_locals_valueAsStringArgAt_(m, locals, 0);
size_t itemCount = IoMessage_locals_sizetArgAt_(m, locals, 1);
IO_ASSERT_NOT_SYMBOL(self);
IOASSERT(itemCount > 0, "aNumberOfItems must be > 0");
IOASSERT(itemCount <= UArray_size(DATA(self)), "aNumberOfItems out of sequence bounds");
UArray_insert_every_(DATA(self), DATA(otherSeq), itemCount);
return self;
}
示例12: IoMessage_locals_cStringArgAt_
//doc Loudmouth registerAccount(server, username, password) Registers a new account at XMPP server. Returns <code>true</code> or <code>false</code>.
IoObject *IoLoudmouth_registerAccount(IoLoudmouth *self, IoObject *locals, IoMessage *m) {
char *server = IoMessage_locals_cStringArgAt_(m, locals, 0),
*username = IoMessage_locals_cStringArgAt_(m, locals, 1),
*password = IoMessage_locals_cStringArgAt_(m, locals, 2),
*error_message = "Unknown error";
LmConnection *connection = lm_connection_new(server);
LmMessage *xmpp_msg, *xmpp_reply;
LmMessageNode *query, *node;
int success = 0;
if(!lm_connection_open_and_block(connection, NULL)) {
error_message = "Could not open connection";
success = 0;
} else {
xmpp_msg = lm_message_new_with_sub_type(NULL, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_SET);
query = lm_message_node_add_child(xmpp_msg->node, "query", NULL);
lm_message_node_set_attributes(query,
"xmlns", "jabber:iq:register",
NULL);
lm_message_node_add_child(query, "username", username);
lm_message_node_add_child(query, "password", password);
xmpp_reply = lm_connection_send_with_reply_and_block(connection, xmpp_msg, NULL);
lm_connection_close(connection, NULL);
lm_connection_unref(connection);
if(!xmpp_reply) {
success = 0;
error_message = "No reply from server";
} else {
switch(lm_message_get_sub_type(xmpp_reply)) {
case LM_MESSAGE_SUB_TYPE_RESULT:
success = 1;
break;
case LM_MESSAGE_SUB_TYPE_ERROR:
default:
success = 0;
node = lm_message_node_find_child(xmpp_reply->node, "error");
error_message = (node == NULL) ? lm_message_node_get_value(node) : "Unknown error";
lm_message_node_unref(node);
}
}
lm_message_unref(xmpp_reply);
lm_message_unref(xmpp_msg);
lm_message_node_unref(query);
}
free(server);
free(username);
free(password);
IOASSERT(success, error_message);
free(error_message);
return IOBOOL(self, success);
}
示例13: IOASSERT
IoObject *IoSkipDBM_compact(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc SkipDBM compact
Compacts the database. Returns self.
*/
IOASSERT(SkipDBM_isOpen(SKIPDBM(self)), "skipdbm not open");
SkipDBM_compact(SKIPDBM(self));
return self;
}
示例14: IOASSERT
IoObject *IoSkipDBCursor_previous(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc SkipDBCursor previous
Move cursor to previous item. Returns self.
*/
IOASSERT(CURSOR(self), "SkipDBCursor invalid");
SkipDBCursor_previous(CURSOR(self));
return self;
}
示例15: IOASSERT
IoObject *IoSkipDB_size(IoObject *self, IoObject *locals, IoMessage *m)
{
/*doc SkipDB size
Returns the number of keys in the receiver.
*/
IOASSERT(SKIPDB(self) && SkipDB_isOpen(SKIPDB(self)), "invalid skipdb");
return IONUMBER(SkipDB_count(SKIPDB(self)));
}