本文整理汇总了C++中SrsAmf0Object::get_property方法的典型用法代码示例。如果您正苦于以下问题:C++ SrsAmf0Object::get_property方法的具体用法?C++ SrsAmf0Object::get_property怎么用?C++ SrsAmf0Object::get_property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SrsAmf0Object
的用法示例。
在下文中一共展示了SrsAmf0Object::get_property方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
srs_amf0_t srs_amf0_object_property(srs_amf0_t amf0, const char* name)
{
SrsAmf0Any* any = (SrsAmf0Any*)amf0;
srs_assert(any->is_object());
SrsAmf0Object* obj = (SrsAmf0Object*)amf0;
return (srs_amf0_t)obj->get_property(name);
}
示例2: TEST
VOID TEST(AMF0Test, ApiObjectProps)
{
SrsAmf0Object* o = NULL;
// get/set property
if (true) {
o = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, o);
EXPECT_TRUE(NULL == o->get_property("name"));
o->set("name", SrsAmf0Any::str("winlin"));
EXPECT_TRUE(NULL != o->get_property("name"));
EXPECT_TRUE(NULL == o->get_property("age"));
o->set("age", SrsAmf0Any::number(100));
EXPECT_TRUE(NULL != o->get_property("age"));
}
// index property
if (true) {
o = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, o);
o->set("name", SrsAmf0Any::str("winlin"));
EXPECT_STREQ("name", o->key_at(0).c_str());
ASSERT_TRUE(o->value_at(0)->is_string());
EXPECT_STREQ("winlin", o->value_at(0)->to_str().c_str());
o->set("age", SrsAmf0Any::number(100));
EXPECT_STREQ("name", o->key_at(0).c_str());
ASSERT_TRUE(o->value_at(0)->is_string());
EXPECT_STREQ("winlin", o->value_at(0)->to_str().c_str());
EXPECT_STREQ("age", o->key_at(1).c_str());
ASSERT_TRUE(o->value_at(1)->is_number());
EXPECT_DOUBLE_EQ(100, o->value_at(1)->to_number());
}
// ensure property
if (true) {
o = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, o);
EXPECT_TRUE(NULL == o->ensure_property_string("name"));
EXPECT_TRUE(NULL == o->ensure_property_number("age"));
o->set("name", SrsAmf0Any::str("winlin"));
EXPECT_TRUE(NULL != o->ensure_property_string("name"));
EXPECT_TRUE(NULL == o->ensure_property_number("name"));
EXPECT_TRUE(NULL == o->ensure_property_number("age"));
o->set("age", SrsAmf0Any::number(100));
EXPECT_TRUE(NULL != o->ensure_property_string("name"));
EXPECT_TRUE(NULL == o->ensure_property_number("name"));
EXPECT_TRUE(NULL != o->ensure_property_number("age"));
EXPECT_TRUE(NULL == o->ensure_property_string("age"));
}
// count
if (true) {
o = SrsAmf0Any::object();
SrsAutoFree(SrsAmf0Object, o);
EXPECT_EQ(0, o->count());
o->set("name", SrsAmf0Any::str("winlin"));
EXPECT_EQ(1, o->count());
o->set("name", SrsAmf0Any::str("winlin"));
EXPECT_EQ(1, o->count());
o->set("age", SrsAmf0Any::number(100));
EXPECT_EQ(2, o->count());
}
}