示例#1
0
int getDoubleFromObjectOrReply(client *c, robj *o, double *target, const char *msg) {
    double value;
    if (getDoubleFromObject(o, &value) != C_OK) {
        if (msg != NULL) {
            addReplyError(c,(char*)msg);
        } else {
            addReplyError(c,"value is not a valid float");
        }
        return C_ERR;
    }
    *target = value;
    return C_OK;
}
//从对象中将字符串值转换为double并存储在target中,若失败,失败发送信息给client
int getDoubleFromObjectOrReply(client *c, robj *o, double *target, const char *msg) {
    double value;
    if (getDoubleFromObject(o, &value) != C_OK) {   //如果出错
        if (msg != NULL) {                  //msg不为空
            addReplyError(c,(char*)msg);    //发送指定的msg给client
        } else {
            addReplyError(c,"value is not a valid float");  //发送普通字符串
        }
        return C_ERR;
    }
    *target = value;    //将转换成功的值存到传入参数中,返回0成功
    return C_OK;
}
示例#3
0
int getDoubleFromObjectOrReply(rr_client_t *c, robj *o, double *target, const char *msg) {
    double value;
    if (getDoubleFromObject(o, &value) != RR_OK) {
        if (msg != NULL) {
            reply_add_err(c,(char*) msg);
        } else {
            reply_add_err(c,"value is not a valid float");
        }
        return RR_ERROR;
    }
    *target = value;
    return RR_OK;
}
示例#4
0
文件: object.c 项目: tjweir/redis
int getDoubleFromObjectOrReply(redisClient *c, robj *o, double *target, const char *msg) {
    double value;
    if (getDoubleFromObject(o, &value) != REDIS_OK) {
        if (msg != NULL) {
            addReplySds(c, sdscatprintf(sdsempty(), "-ERR %s\r\n", msg));
        } else {
            addReplySds(c, sdsnew("-ERR value is not a double\r\n"));
        }
        return REDIS_ERR;
    }

    *target = value;
    return REDIS_OK;
}
示例#5
0
int getDoubleFromObjectOrReply(redisClient *c, robj *o, double *target, const char *msg) {
    double value;
    if (getDoubleFromObject(o, &value) != REDIS_OK) {
        if (msg != NULL) {
            addReplyError(c,(char*)msg);
        } else {
            addReplyError(c,"value is not a double");
        }
        return REDIS_ERR;
    }

    *target = value;
    return REDIS_OK;
}