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


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

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


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

示例1: 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

示例2: convertToVariant

void convertToVariant(NPP npp, const Any& any, NPVariant* variant, bool result)
{
    switch (any.getType())
    {
    case Any::Empty:
        NULL_TO_NPVARIANT(*variant);
        break;
    case Any::Bool:
        BOOLEAN_TO_NPVARIANT(any.toBoolean(), *variant);
        break;
    case Any::Int32:
    case Any::Uint32:
        INT32_TO_NPVARIANT(static_cast<int32_t>(any), *variant);
        break;
    case Any::Int64:
    case Any::Uint64:
    case Any::Float32:
    case Any::Float64:
        DOUBLE_TO_NPVARIANT(static_cast<double>(any), *variant);
        break;
    case Any::Dynamic:
        if (any.isString())
        {
            std::string value = any.toString();
            if (value.length() == 0)
            {
                STRINGN_TO_NPVARIANT(0, 0, *variant);
            }
            else if (!result)
            {
                STRINGN_TO_NPVARIANT(value.c_str(), static_cast<uint32_t>(value.length()), *variant);
            }
            else {
                void* buffer = NPN_MemAlloc(value.length());
                if (!buffer)
                {
                    STRINGN_TO_NPVARIANT(0, 0, *variant);
                }
                else
                {
                    memmove(buffer, value.c_str(), value.length());
                    STRINGN_TO_NPVARIANT(static_cast<NPUTF8*>(buffer), static_cast<uint32_t>(value.length()), *variant);
                }
            }
        }
        else
        {
            assert(any.isObject());
            convertToVariant(npp, any.toObject(), variant, result);
        }
        break;
    default:
        VOID_TO_NPVARIANT(*variant);
        break;
    }
}
开发者ID:giobeatle1794,项目名称:es-operating-system,代码行数:56,代码来源:bridge.cpp


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