예제 #1
0
파일: field.c 프로젝트: aburan28/ironbee
ib_status_t ib_field_value(
    const ib_field_t *f,
    void             *out_pval
)
{
    return ib_field_value_ex(f, out_pval, NULL, 0);
}
예제 #2
0
ConstByteString ConstField::value_as_byte_string(
    const char* arg,
    size_t      arg_length
) const
{
    Internal::check_type(BYTE_STRING, type());
    const ib_bytestr_t* v;
    throw_if_error(ib_field_value_ex(
        ib(), ib_ftype_bytestr_out(&v),
        arg, arg_length
    ));
    return ConstByteString(v);
}
예제 #3
0
const char* ConstField::value_as_null_string(
    const char* arg,
    size_t      arg_length
) const
{
    Internal::check_type(NULL_STRING, type());
    const char* v;
    throw_if_error(ib_field_value_ex(
        ib(), ib_ftype_nulstr_out(&v),
        arg, arg_length
    ));
    return v;
}
예제 #4
0
long double ConstField::value_as_float(
    const char* arg,
    size_t      arg_length
) const
{
    Internal::check_type(FLOAT, type());
    long double v;
    throw_if_error(ib_field_value_ex(
        ib(), ib_ftype_float_out(&v),
        arg, arg_length
    ));
    return v;
}
예제 #5
0
int64_t ConstField::value_as_number(
    const char* arg,
    size_t      arg_length
) const
{
    Internal::check_type(NUMBER, type());
    int64_t v;
    throw_if_error(ib_field_value_ex(
        ib(), ib_ftype_num_out(&v),
        arg, arg_length
    ));
    return v;
}
예제 #6
0
uint64_t ConstField::value_as_time(
    const char* arg,
    size_t      arg_length
) const
{
    Internal::check_type(TIME, type());
    uint64_t v;
    throw_if_error(ib_field_value_ex(
        ib(), ib_ftype_time_out(&v),
        arg, arg_length
    ));
    return v;
}
예제 #7
0
파일: field.c 프로젝트: aburan28/ironbee
ib_status_t ib_field_value_type_ex(
    const ib_field_t *f,
    void             *out_pval,
    ib_ftype_t        t,
    const void       *arg,
    size_t            alen
)
{
    /* Compare the types */
    if (f->type != t) {
        return IB_EINVAL;
    }

    /* Return the value as normal. */
    return ib_field_value_ex(f, out_pval, arg, alen);
}
예제 #8
0
///@test Test util field library - ib_field_dyn_register_get()
TEST_F(TestIBUtilField, test_dyn_field)
{
    ib_field_t *dynf;
    ib_field_t *cdynf;
    ib_status_t rc;
    const char *fval;

    /* Create a field with no initial value. */
    rc = ib_field_create_dynamic(
        &dynf, MM(),
        IB_S2SL("test_dynf"), IB_FTYPE_NULSTR,
        dyn_get, (void *)"dynf_get",
        dyn_set, (void *)"dynf_set"
    );
    ASSERT_EQ(IB_OK, rc);
    ASSERT_TRUE(dynf);
    ASSERT_EQ(9UL, dynf->nlen);
    ASSERT_EQ(0, memcmp("test_dynf", dynf->name, 9));

    /* Get the value from the dynamic field. */
    rc = ib_field_value_ex(dynf,
        ib_ftype_nulstr_out(&fval),
        (void *)"fetch1", 6
    );
    ASSERT_EQ(IB_OK, rc);
    ASSERT_TRUE(fval);
    ASSERT_EQ(
        std::string("testval_dynf_get_fetch1_call01"),
        fval
    );

    /* Get the value from the dynamic field again. */
    rc = ib_field_value_ex(dynf,
        ib_ftype_nulstr_out(&fval),
        (void *)"fetch2", 6
    );
    ASSERT_EQ(IB_OK, rc);
    ASSERT_TRUE(fval);
    ASSERT_EQ(
        std::string("testval_dynf_get_fetch2_call02"),
        fval
    );

    /* Set */
    rc = ib_field_setv_ex(dynf, (void *)"val1", (void *)"set1", 4);
    ASSERT_EQ(IB_OK, rc);
    ASSERT_EQ(std::string("testval_dynf_set_set1_val1_call03"), g_dyn_call_val);

    /* Reset call counter. */
    g_dyn_call_count = 0;

    /* Create another field with no initial value. */
    rc = ib_field_create_dynamic(
        &cdynf, MM(),
        IB_S2SL("test_cdynf"), IB_FTYPE_NULSTR,
        dyn_get_cached, (void *)("cdynf_get"),
        dyn_set, NULL
    );
    ASSERT_EQ(IB_OK, rc);
    ASSERT_TRUE(cdynf);
    ASSERT_EQ(10UL, cdynf->nlen);
    ASSERT_EQ(0, memcmp("test_cdynf", cdynf->name, 10));

    /* Get the value from the dynamic field. */
    rc = ib_field_value_ex(cdynf,
        ib_ftype_nulstr_out(&fval),
        (void *)"fetch1", 6
    );
    ASSERT_EQ(IB_OK, rc);
    ASSERT_TRUE(fval);
    ASSERT_EQ(
        std::string("testval_cdynf_get_fetch1_call01"),
        fval
    );

    /* Get the value from the dynamic field again. */
    rc = ib_field_value_ex(cdynf,
        ib_ftype_nulstr_out(&fval),
        NULL, 0
    );
    ASSERT_EQ(IB_OK, rc);
    ASSERT_TRUE(fval);
    ASSERT_EQ(
        std::string("testval_cdynf_get_fetch1_call01"),
        fval
    );
}