当前位置: 首页>>代码示例>>C++>>正文


C++ Method::isVolatile方法代码示例

本文整理汇总了C++中Method::isVolatile方法的典型用法代码示例。如果您正苦于以下问题:C++ Method::isVolatile方法的具体用法?C++ Method::isVolatile怎么用?C++ Method::isVolatile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Method的用法示例。


在下文中一共展示了Method::isVolatile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testClass

void ClassTestSuite::testClass()
{
	//Class test = ClassOf<Test1>();

	Class test = Class::lookup("ClassTest::Test1");

	TS_ASSERT_EQUALS(test.simpleName(), "Test1");

#ifndef NO_RTTI
	TS_ASSERT(test.describes<ClassTest::Test1>())

	Class test2 = Class::lookup(typeid(ClassTest::Test1));
	TS_ASSERT_EQUALS(test2.simpleName(), "Test1");
	TS_ASSERT_EQUALS(test, test2);
#endif

	Class::ClassList superClasses = test.superclasses();

	TS_ASSERT_EQUALS(superClasses.size(), 2);

	Class base1;
	Class base2;

	TS_ASSERT_THROWS(base1.simpleName(), std::runtime_error); // uninitialized handle

	for(const Class& c: superClasses) {
		if (c.fullyQualifiedName() == "ClassTest::TestBase1") {
			base1 = c;
		} else if (c.fullyQualifiedName() == "ClassTest::TestBase2") {
			base2 = c;
		}
	}

	TS_ASSERT_EQUALS(base1.fullyQualifiedName(), "ClassTest::TestBase1");
	TS_ASSERT_EQUALS(base1.simpleName(), "TestBase1");
	TS_ASSERT_EQUALS(base2.fullyQualifiedName(), "ClassTest::TestBase2");
	TS_ASSERT_EQUALS(base2.simpleName(), "TestBase2");

	TS_ASSERT(inheritanceRelation(test, base1));
	TS_ASSERT(inherits(test, base1));
	TS_ASSERT(inheritedBy(base1, test));

	TS_ASSERT(inheritanceRelation(test, base2));
	TS_ASSERT(inherits(test, base2));
	TS_ASSERT(inheritedBy(base2, test));

	TS_ASSERT(!inheritanceRelation(base1, base2));

	Class::ConstructorList base1Constructors = base1.constructors();
	TS_ASSERT_EQUALS(base1.constructors().size(), 1);

	Constructor base1Constructor = base1Constructors.front();

	TS_ASSERT_EQUALS(base1Constructor.numberOfArguments(), 0);
	TS_ASSERT_THROWS(base1Constructor.call(), std::runtime_error); // abstract class


	Class::ConstructorList base2Constructors = base2.constructors();
	TS_ASSERT_EQUALS(base2.constructors().size(), 1);

	Constructor base2Constructor = base2Constructors.front();

	TS_ASSERT_EQUALS(base2Constructor.numberOfArguments(), 0);

	VariantValue b2Inst = base2Constructor.call();
	TS_ASSERT(b2Inst.isValid());

	TS_ASSERT_EQUALS(base2.attributes().size(), 0);
	Class::MethodList base2Methods = base2.methods();
	TS_ASSERT_EQUALS(base2Methods.size(), 1);

	Method base2Method1 = base2Methods.front();

	TS_ASSERT_EQUALS(base2Method1.name(), "base2Method1");
	TS_ASSERT(base2Method1.isConst());
	TS_ASSERT(!base2Method1.isVolatile());
	TS_ASSERT(!base2Method1.isStatic());
	TS_ASSERT_EQUALS(base2Method1.numberOfArguments(), 0);
	TS_ASSERT_EQUALS(base2Method1.call(b2Inst).value<int>(), 6);


	Class::ConstructorList testConstructors = test.constructors();
	Class::AttributeList   attributes       = test.attributes();

	TS_ASSERT_EQUALS(attributes.size(), 2);
	Attribute attr = attributes.front();

	WITH_RTTI(TS_ASSERT(attr.type() == typeid(int)));

	TS_ASSERT_EQUALS(testConstructors.size(), 3);

	Constructor defaultConstr;
	Constructor intConstr;

	TS_ASSERT_THROWS(defaultConstr.argumentSpellings(), std::runtime_error);

	for (const Constructor& c: testConstructors) {
		if (c.numberOfArguments() == 0) {
			defaultConstr = c;
		} else if (c.numberOfArguments() == 1  && c.argumentSpellings()[0] == "int"){
//.........这里部分代码省略.........
开发者ID:maxdebayser,项目名称:SelfPortrait,代码行数:101,代码来源:class_test.cpp

示例2: testClass

void ClassTestSuite::testClass()
{
    //Class test = ClassOf<Test1>();

    Class test = Class::lookup("ClassTest::Test1");

    TS_ASSERT_EQUALS(test.simpleName(), "Test1");

    Class::ClassList superClasses = test.superclasses();

    TS_ASSERT_EQUALS(superClasses.size(), 2);

    Class base1;
    Class base2;

    TS_ASSERT_THROWS(base1.simpleName(), std::runtime_error); // uninitialized handle

    for(const Class& c: superClasses) {
        if (c.fullyQualifiedName() == "ClassTest::TestBase1") {
            base1 = c;
        } else if (c.fullyQualifiedName() == "ClassTest::TestBase2") {
            base2 = c;
        }
    }

    TS_ASSERT_EQUALS(base1.fullyQualifiedName(), "ClassTest::TestBase1");
    TS_ASSERT_EQUALS(base1.simpleName(), "TestBase1");
    TS_ASSERT_EQUALS(base2.fullyQualifiedName(), "ClassTest::TestBase2");
    TS_ASSERT_EQUALS(base2.simpleName(), "TestBase2");

    Class::ConstructorList base1Constructors = base1.constructors();
    TS_ASSERT_EQUALS(base1.constructors().size(), 1);

    Constructor base1Constructor = base1Constructors.front();

    TS_ASSERT_EQUALS(base1Constructor.numberOfArguments(), 0);
    TS_ASSERT_THROWS(base1Constructor.call(), std::runtime_error); // abstract class


    Class::ConstructorList base2Constructors = base2.constructors();
    TS_ASSERT_EQUALS(base2.constructors().size(), 1);

    Constructor base2Constructor = base2Constructors.front();

    TS_ASSERT_EQUALS(base2Constructor.numberOfArguments(), 0);

    VariantValue b2Inst = base2Constructor.call();
    TS_ASSERT(b2Inst.isValid());

    TS_ASSERT_EQUALS(base2.attributes().size(), 0);
    Class::MethodList base2Methods = base2.methods();
    TS_ASSERT_EQUALS(base2Methods.size(), 1);

    Method base2Method1 = base2Methods.front();

    TS_ASSERT_EQUALS(base2Method1.name(), "base2Method1");
    TS_ASSERT(base2Method1.isConst());
    TS_ASSERT(!base2Method1.isVolatile());
    TS_ASSERT(!base2Method1.isStatic());
    TS_ASSERT_EQUALS(base2Method1.numberOfArguments(), 0);
    TS_ASSERT_EQUALS(base2Method1.call(b2Inst).value<int>(), 6);


    Class::ConstructorList testConstructors = test.constructors();
    Class::AttributeList   attributes       = test.attributes();

    TS_ASSERT_EQUALS(attributes.size(), 2);
    Attribute attr = attributes.front();

    WITH_RTTI(TS_ASSERT(attr.type() == typeid(int)));

    TS_ASSERT_EQUALS(testConstructors.size(), 3);

    Constructor defaultConstr;
    Constructor intConstr;

    TS_ASSERT_THROWS(defaultConstr.argumentSpellings(), std::runtime_error);

    for (const Constructor& c: testConstructors) {
        if (c.numberOfArguments() == 0) {
            defaultConstr = c;
        } else if (c.numberOfArguments() == 1  && c.argumentSpellings()[0] == "int") {
            intConstr = c;
        }
    }


    TS_ASSERT_EQUALS(defaultConstr.numberOfArguments(), 0);
    TS_ASSERT_EQUALS(intConstr.numberOfArguments(), 1);

    VariantValue testInst1 = defaultConstr.call();

    TS_ASSERT(testInst1.isA<Test1>());

    TS_ASSERT_EQUALS(attr.get(testInst1).value<int>(), 3);


    VariantValue testInst2 = intConstr.call(77);

    TS_ASSERT(testInst2.isA<Test1>());
//.........这里部分代码省略.........
开发者ID:maxdebayser,项目名称:reflection,代码行数:101,代码来源:class_test.cpp


注:本文中的Method::isVolatile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。