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


C++ Any::type方法代码示例

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


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

示例1:

Any Any::operator + (const Any &r) const {
	switch (this->type()) {
		case Any::Int:
			switch (r.type()) {
				case Any::Int: return this->getInt() + r.getInt();
				case Any::Float: return this->getInt() + r.getFloat();
				case Any::String: return boost::lexical_cast<string>(this->getInt()) + r.getString();
			}
			break;
		case Any::Float:
			switch (r.type()) {
				case Any::Int: return this->getFloat() + r.getInt();
				case Any::Float: return this->getFloat() + r.getFloat();
				case Any::String: return boost::lexical_cast<string>(this->getFloat()) + r.getString();
			}
			break;
		case Any::String:
			switch (r.type()) {
				case Any::Int: return this->getString() + boost::lexical_cast<string>(r.getInt());
				case Any::Float: return this->getString() + boost::lexical_cast<string>(r.getFloat());
				case Any::String: return this->getString() + r.getString();
			}
			break;
	}
	FIXME("Unsupported operation %s + %s", this->typeInfo().name(), r.typeInfo().name());
	return 0;
}
开发者ID:fennekki,项目名称:cbEnchanted,代码行数:27,代码来源:any.cpp

示例2: shr

int32_t Any::shr (const Any &l, const Any &r) {
	if (l.type() == Any::Int && r.type() == Any::Int) {
		int32_t a = l.getInt();
		int32_t b = r.getInt();
		uint32_t ret = *reinterpret_cast<uint32_t*>( &a ) >> *reinterpret_cast<uint32_t*>( &b );
		return *reinterpret_cast<int32_t*>( &ret );
	}
开发者ID:fennekki,项目名称:cbEnchanted,代码行数:7,代码来源:any.cpp

示例3: if

Texture::Encoding::Encoding(const Any& a) {
    *this = Encoding();

    if (a.type() == Any::STRING) {
        format = ImageFormat::fromString(a);
    } else if (a.nameBeginsWith("Color4")) {
        readMultiplyFirst = a;
	}
	else if (anyNameIsColor3Variant(a)) {
        readMultiplyFirst = Color4(Color3(a), 1.0f);
    } else if (a.type() == Any::NUMBER) {
        readMultiplyFirst = Color4::one() * float(a.number());
    } else {
        AnyTableReader r(a);

        r.getIfPresent("frame", frame);
        r.getIfPresent("readMultiplyFirst", readMultiplyFirst);
        r.getIfPresent("readAddSecond", readAddSecond);

        String fmt;
        if (r.getIfPresent("format", fmt)) {
            format = ImageFormat::fromString(fmt);
        }
    }
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:25,代码来源:Texture_Specification.cpp

示例4: Any

Any Converter<float>::convert(const Any& a)
{
	if (typeid(int) == a.type())
		return Any(helper<float, int>::convert(a));
	else if (typeid(const char *) == a.type())
		return Any(helper<float, const char *>::convert(a));

	return any_cast<float>(a);
}
开发者ID:biofag,项目名称:UMOF,代码行数:9,代码来源:converters.cpp

示例5: if

Any Converter<int>::convert(const Any& a)
{
	if (Type::from<float>() == a.type())
		return helper<int, double>::convert(a);
    else if (Type::from<const char *>() == a.type())
		return helper<int, const char *>::convert(a);

	return any_cast<int>(a);
}
开发者ID:crazybie,项目名称:uMOF,代码行数:9,代码来源:converter.cpp

示例6: Any

Any Converter<float>::convert(const Any& a)
{
    if (Type::from<int>() == a.type())
		return Any(helper<float, int>::convert(a));
    else if (Type::from<const char *>() == a.type())
		return Any(helper<float, const char *>::convert(a));

	return any_cast<float>(a);
}
开发者ID:crazybie,项目名称:uMOF,代码行数:9,代码来源:converter.cpp

示例7: if

Any Converter<int>::convert(const Any& a)
{
	if (typeid(float) == a.type())
		return helper<int, double>::convert(a);
	else if (typeid(const char *) == a.type())
		return helper<int, const char *>::convert(a);

	return any_cast<int>(a);
}
开发者ID:biofag,项目名称:UMOF,代码行数:9,代码来源:converters.cpp

示例8: r

Texture::Specification::Specification(const Any& any, bool assumesRGBForAuto, Dimension defaultDimension) {
    *this = Specification();
    assumeSRGBSpaceForAuto = assumesRGBForAuto;
    dimension              = defaultDimension;

    if (any.type() == Any::STRING) {
        filename = any.string();
        if (filename == "<whiteCube>") {
            filename = "<white>";
            dimension = Texture::DIM_CUBE_MAP;
        }

        if (! beginsWith(filename, "<")) {
            filename = any.resolveStringAsFilename();
            if (FilePath::containsWildcards(filename)) {

                // Assume this is a cube map
                dimension = Texture::DIM_CUBE_MAP;
            }
        }
    } else if ((any.type() == Any::NUMBER) ||
               any.nameBeginsWith("Color4") || 
			   anyNameIsColor3Variant(any)) {
        filename = "<white>";
        encoding.readMultiplyFirst = Color4(any);
    } else {

        any.verifyNameBeginsWith("Texture::Specification");
        AnyTableReader r(any);
        r.getFilenameIfPresent("filename", filename);
        r.getFilenameIfPresent("alphaFilename", alphaFilename);
        r.getIfPresent("encoding", encoding);
        r.getIfPresent("assumeSRGBSpaceForAuto", assumeSRGBSpaceForAuto);
        {
            Any a;
            if (r.getIfPresent("dimension", a)) {
                dimension = toDimension(a);
            }
        }
        r.getIfPresent("generateMipMaps", generateMipMaps);
        r.getIfPresent("preprocess", preprocess);
        r.getIfPresent("visualization", visualization);
        r.getIfPresent("cachable", cachable);
        r.verifyDone();

        if (! any.containsKey("dimension") && FilePath::containsWildcards(filename)) {
            // Assume this is a cube map
            dimension = Texture::DIM_CUBE_MAP;
        }
    }
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:51,代码来源:Texture_Specification.cpp

示例9: testParse

static void testParse() {
    {
        const String& src = "name[ \"foo\", b4r, { a = b, c = d}]";
        Any a = Any::parse(src);
        a.verifyType(Any::ARRAY);
        a[0].verifyType(Any::STRING);
        testAssert(a[0].string() == "foo"); 
        testAssert(a[1].string() == "b4r");
        testAssert(a[2]["a"].string() == "b");
    }
    {
        const String& src =  
        "[v = 1,\r\n/*\r\n*/\r\nx = 1]";
        Any a = Any::parse(src);
        testAssert(a.type() == Any::TABLE);
        testAssert(a.size() == 2);

        Any val1 = a["v"];
        testAssert(val1.type() == Any::NUMBER);
        testAssert(val1.number() == 1);
    }
    {
        const String& src =  
        "{\n\
            val0 : (1);\n\
           \n\
           // Comment 1\n\
           val1 : 3;\n\
           \
           // Comment 2\n\
           // Comment 3\n\
           val2 : None;\n\
           val3 : none;\n\
           val4 : NIL;\n\
        }";

        Any a = Any::parse(src);
        testAssert(a.type() == Any::TABLE);
        testAssert(a.size() == 5);

        Any val1 = a["val1"];
        testAssert(val1.type() == Any::NUMBER);
        testAssert(val1.number() == 3);
        testAssert(val1.comment() == "Comment 1");
        testAssert(a["val2"].isNil());       
        testAssert(a["val3"].string() == "none");
        testAssert(a["val4"].isNil());
    }
开发者ID:elfprince13,项目名称:G3D10,代码行数:48,代码来源:tAny.cpp

示例10: commandPlaySound

void SoundInterface::commandPlaySound(void) {
	int32_t freg = cb->popValue().toInt();
	float balance = cb->popValue().toFloat();
	float volume = cb->popValue().toFloat();
	Any any = cb->popValue();
	
	// If passed parameter is integer, the sound is preloaded. Otherwise load it.
	if (any.type() == Any::Int) {
		CBChannel* channel = new CBChannel;
		channel->setMixer(al_get_default_mixer());
		int32_t id = any.toInt();
		channel->playSound((*sounds[id]), volume, balance, freg);
		int32_t nextChannel = nextChannelId();
		channels[nextChannel] = channel;
	}
	else {
		CBChannel* channel = new CBChannel;
		channel->setMixer(al_get_default_mixer());
		ALLEGRO_PATH *path = any.toString().getPath();
		const char *cpath = al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP);
		channel->playSound(cpath, volume, balance, freg);
		int32_t nextChannel = nextChannelId();
		channels[nextChannel] = channel;
	}
}
开发者ID:fennekki,项目名称:cbEnchanted,代码行数:25,代码来源:soundinterface.cpp

示例11: any_safe

    void
    Any_Handler::extract_into_any (const Any& desc,
                                   CORBA::Any& toconfig)
    {
      DANCE_TRACE("Any_Handler::extract_into_any");
      try
        {
          DynamicAny::DynAny_var dyn = DYNANY_HANDLER->extract_into_dynany (desc.type (),
                                                                            desc.value ());
          CORBA::Any_var any_safe (dyn->to_any ());
          toconfig = *any_safe;

          dyn->destroy ();
        }
      catch (CORBA::Exception &ex)
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO
                           ACE_TEXT ("Any_Handler::extract_into_any -")
                           ACE_TEXT (" Caught CORBA Exception while extracting into")
                           ACE_TEXT (" dynany: %C\n"),
                           ex._info ().c_str ()));
          throw Config_Error (ACE_TEXT (""),
                              ACE_TEXT ("CORBA Exception while extracting into dynany\n"));
        }
      catch (Config_Error &ex)
        {
          throw ex;
        }
      catch (...)
        {
          throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Caught error whilst parsing XML into Any\n"));
        }
    }
开发者ID:molixiaoge,项目名称:ACE,代码行数:33,代码来源:Any_Handler.cpp

示例12: r

Sampler::Sampler(const Any& any) {
    *this = Sampler::defaults();
    any.verifyNameBeginsWith("Sampler");
    if (any.type() == Any::TABLE) {
        AnyTableReader r(any);
        r.getIfPresent("maxAnisotropy", maxAnisotropy);
        r.getIfPresent("maxMipMap", maxMipMap);
        r.getIfPresent("minMipMap", minMipMap);
        r.getIfPresent("mipBias", mipBias);
        r.getIfPresent("xWrapMode", xWrapMode);
        if (! r.getIfPresent("yWrapMode", yWrapMode)) {
            yWrapMode = xWrapMode;
        }
        r.getIfPresent("depthReadMode", depthReadMode);
        r.getIfPresent("interpolateMode", interpolateMode);
        r.verifyDone();
    } else {
        any.verifySize(0);
        const String& n = any.name();
        if (n == "Sampler::defaults") {
            // Done!
        } else if (n == "Sampler::buffer") {
            *this = Sampler::buffer();
        } else if (n == "Sampler::cubeMap") {
            *this = Sampler::cubeMap();
        } else if (n == "Sampler::shadow") {
            *this = Sampler::shadow();
        } else if (n == "Sampler::video") {
            *this = Sampler::video();
        } else {
            any.verify(false, "Unrecognized name for Sampler constructor or factory method.");
        }
    }
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:34,代码来源:Sampler.cpp

示例13: switch

ArticulatedModel::Instruction::Identifier::Identifier(const Any& a) {
    switch (a.type()) {
    case Any::NUMBER:
        id = ID(iRound(a.number()));
        a.verify(id >= 0, "Illegal ID");
        break;

    case Any::STRING:
        name = a.string();
        break;

    case Any::ARRAY:
        a.verifySize(0);
        if (a.name() == "root") {
            *this = root();
        } else if (a.name() == "all") {
            *this = all();
        } else {
            a.verify(false, "Illegal function call: " + a.name());
        }
        break;

    default:
        a.verify(false, "Expected a name, integer ID, root(), or all()");
    }
}
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:26,代码来源:ArticulatedModel_serialize.cpp

示例14: toLower

PhysicsFrame::PhysicsFrame(const Any& a) {
    const std::string& n = toLower(a.name());
    *this = PhysicsFrame();

    if (beginsWith(n, "vector3")) {
        *this = PhysicsFrame(Vector3(a));
    } else if (beginsWith(n, "matrix3")) {        
        *this = PhysicsFrame(Matrix3(a));
    } else if (beginsWith(n, "cframe") || beginsWith(n, "coordinateframe")) {        
        *this = PhysicsFrame(CoordinateFrame(a));
    } else if (beginsWith(n, "pframe") || beginsWith(n, "physicsframe")) {
        if (a.type() == Any::ARRAY) {
            a.verifySize(2);
            rotation    = a[0];
            translation = a[1];
        } else {
            for (Any::AnyTable::Iterator it = a.table().begin(); it.hasMore(); ++it) {
                const std::string& n = toLower(it->key);
                if (n == "translation") {
                    translation = it->value;
                } else if (n == "rotation") {
                    rotation = it->value;
                } else {
                    a.verify(false, "Illegal table key: " + it->key);
                }
            }
        }
    }
}
开发者ID:Sandshroud,项目名称:Sandshroud-Prodigy,代码行数:29,代码来源:PhysicsFrame.cpp

示例15: testDefaultCtor

void AnyTest::testDefaultCtor()
{
	const Any value;
	
	assert (value.empty());
	assert (0 == AnyCast<int>(&value));
	assert (value.type() == typeid(void));
}
开发者ID:1514louluo,项目名称:poco,代码行数:8,代码来源:AnyTest.cpp


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