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


C++ KValueRef::SetInt方法代码示例

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


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

示例1: Checksum

void Codec::Checksum(const ValueList& args, KValueRef result)
{
    args.VerifyException("checksum", "s|o ?i");

    int type = CODEC_CRC32;
    
    if (args.size() == 2)
    {
        type = args.at(1)->ToInt();
    }
    
    Poco::Checksum *checksum = NULL;
    
    switch(type)
    {
        case CODEC_CRC32:
        {
            checksum = new Poco::Checksum(Poco::Checksum::TYPE_CRC32);
            break;
        }
        case CODEC_ADLER32:
        {
            checksum = new Poco::Checksum(Poco::Checksum::TYPE_ADLER32);
            break;
        }
        default:
        {
            std::ostringstream msg("Unsupported type: ");
            msg << type;
            throw ValueException::FromString(msg.str());
        }
    }

    if (args.at(0)->IsString())
    {
        std::string encoded = args.at(0)->ToString();
        const char *data = encoded.c_str();
        checksum->update(data,encoded.size());
        result->SetInt(checksum->checksum());
    }
    else if (args.at(0)->IsObject())
    {
        BytesRef bytes = args.at(0)->ToObject().cast<Bytes>();
        if (bytes.isNull())
        {
            delete checksum;
            throw ValueException::FromString("unsupported data type passed as argument 1");
        }
        checksum->update(bytes->Pointer(),bytes->Length());
        result->SetInt(checksum->checksum());
    }
    else
    {
        delete checksum;
        throw ValueException::FromString("unsupported data type passed as argument 1");
    }
    
    delete checksum;
}
开发者ID:Defachko,项目名称:titanium_desktop,代码行数:59,代码来源:Codec.cpp

示例2: Getter

	void PropertiesBinding::Getter(const ValueList& args, KValueRef result, Type type)
	{
		if (args.size() > 0 && args.at(0)->IsString())
		{
			std::string eprefix = "PropertiesBinding::Get: ";
			try
			{
				std::string property = args.at(0)->ToString();
				if (args.size() == 1)
				{
					switch (type)
					{
						case Bool: 
							result->SetBool(config->getBool(property));
							break;
						case Double:
							result->SetDouble(config->getDouble(property));
							break;
						case Int:
							result->SetInt(config->getInt(property));
							break;
						case String:
							result->SetString(config->getString(property).c_str());
							break;
						default:
							break;
					}
					return;
				}

				else if (args.size() >= 2)
				{
					switch (type)
					{
						case Bool:
							result->SetBool(config->getBool(property, args.at(1)->ToBool()));
							break;
						case Double:
							result->SetDouble(config->getDouble(property, args.at(1)->ToDouble()));
							break;
						case Int:
							result->SetInt(config->getInt(property, args.at(1)->ToInt()));
							break;
						case String:
							result->SetString(config->getString(property, args.at(1)->ToString()).c_str());
							break;
						default: break;
					}
					return;
				}
			}
			catch(Poco::Exception &e)
			{
				throw ValueException::FromString(eprefix + e.displayText());
			}
		}
	}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:57,代码来源:properties_binding.cpp

示例3: FieldCount

 void ResultSetBinding::FieldCount(const ValueList& args, KValueRef result)
 {
     if (rs.isNull())
     {
         result->SetInt(0);
     }
     else
     {
         result->SetInt(rs->columnCount());
     }
 }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:11,代码来源:resultset_binding.cpp

示例4: _GetPID

	void ApplicationBinding::_GetPID(const ValueList& args, KValueRef result)
	{
		if (this->current)
		{
			result->SetInt(GETPID());
		}
	}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:7,代码来源:application_binding.cpp

示例5: _GetPID

	void Process::_GetPID(const ValueList& args, KValueRef result)
	{
		int pid = GetPID();
		if (pid != -1)
			result->SetInt(GetPID());
		else
			result->SetNull();
	}
开发者ID:Val9,项目名称:titanium_desktop,代码行数:8,代码来源:process.cpp

示例6: _ByteAt

	void Bytes::_ByteAt(const ValueList& args, KValueRef result)
	{
		args.VerifyException("Bytes.byteAt", "n");
		size_t position = args.GetInt(0);
		
		if (position >= 0 && position < this->size)
		{
			result->SetInt(static_cast<unsigned char>(this->buffer[position]));
		}
	}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:10,代码来源:bytes.cpp

示例7: _LastIndexOf

	void Bytes::_LastIndexOf(const ValueList& args, KValueRef result)
	{
		// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/lastIndexOf
		args.VerifyException("Bytes.lastIndexOf", "s,?i");

		std::string target(this->AsString());
		int start = args.GetInt(1, target.length() + 1);
		if (start < 0) start = 0;
		size_t pos = target.rfind(args.GetString(0), start);

		if (pos == std::string::npos)
		{
			// No matches found
			result->SetInt(-1);
		}
		else
		{
			result->SetInt(pos);
		}
	}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:20,代码来源:bytes.cpp

示例8: _AddConnectivityListener

void Network::_AddConnectivityListener(const ValueList& args, KValueRef result)
{
    args.VerifyException("addConnectivityListener", "m");
    KMethodRef target = args.at(0)->ToMethod();

    static long nextListenerId = 0;
    Listener listener = Listener();
    listener.id = nextListenerId++;
    listener.callback = target;
    this->listeners.push_back(listener);
    result->SetInt(listener.id);
}
开发者ID:finglish,项目名称:titanium_desktop,代码行数:12,代码来源:Network.cpp

示例9: _ComponentGUIDToComponentType

 void APIBinding::_ComponentGUIDToComponentType(const ValueList& args, KValueRef result)
 {
     std::string type = args.at(0)->ToString();
     if (type == RUNTIME_UUID)
     {
         result->SetInt(RUNTIME);
     }
     else if (type == MODULE_UUID)
     {
         result->SetInt(MODULE);
     }
     else if (type == SDK_UUID)
     {
         result->SetInt(SDK);
     }
     else if (type == MOBILESDK_UUID)
     {
         result->SetInt(MOBILESDK);
     }
     else if (type == APP_UPDATE_UUID)
     {
         result->SetInt(APP_UPDATE);
     }
     else
     {
         result->SetInt(UNKNOWN);
     }
 }
开发者ID:fossamikom,项目名称:TideSDK,代码行数:28,代码来源:api_binding.cpp

示例10: TransformValue

 void ResultSetBinding::TransformValue(size_t index, KValueRef result)
 {
     MetaColumn::ColumnDataType type = rs->columnType(index);
     Poco::DynamicAny value = rs->value(index);
     
     if (value.isEmpty())
     {
         result->SetNull();
     }
     else if (type == MetaColumn::FDT_STRING)
     {
         std::string str;
         value.convert(str);
         result->SetString(str);
     }
     else if (type == MetaColumn::FDT_BOOL)
     {
         bool v = false;
         value.convert(v);
         result->SetBool(v);
     }
     else if (type == MetaColumn::FDT_FLOAT || type == MetaColumn::FDT_DOUBLE)
     {
         float f = 0;
         value.convert(f);
         result->SetDouble(f);
     }
     else if (type == MetaColumn::FDT_BLOB || type == MetaColumn::FDT_UNKNOWN)
     {
         std::string str;
         value.convert(str);
         result->SetString(str);
     }
     else
     {
         // the rest of these are ints:
         // FDT_INT8,
         // FDT_UINT8,
         // FDT_INT16,
         // FDT_UINT16,
         // FDT_INT32,
         // FDT_UINT32,
         // FDT_INT64,
         // FDT_UINT64,
         int i;
         value.convert(i);
         result->SetInt(i);
     }
 }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:49,代码来源:resultset_binding.cpp

示例11: _Write

	void Bytes::_Write(const ValueList& args, KValueRef result)
	{
		args.VerifyException("write", "s|o ?n");
		int offset = args.GetInt(1, 0);
		int bytesWritten;

		if (args.at(0)->IsString())
		{
			const char* str = args.at(0)->ToString();
			size_t length = strlen(str);
			bytesWritten = Write(str, length, offset);
		}
		else
		{
			BytesRef data(args.GetObject(0).cast<Bytes>());
			if (data.isNull())
			{
				throw ValueException::FromString("May only write strings or Bytes object");
			}
			bytesWritten = Write(data, offset);
		}

		result->SetInt(bytesWritten);
	}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:24,代码来源:bytes.cpp

示例12: _GetProcessorCount

void PlatformBinding::_GetProcessorCount(const ValueList& args, KValueRef result)
{
	result->SetInt(GetProcessorCountImpl());
}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:4,代码来源:platform_binding.cpp

示例13: GetMaxAge

	void HTTPCookie::GetMaxAge(const ValueList& args, KValueRef result)
	{
		result->SetInt(this->cookie.getMaxAge());
	}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:4,代码来源:http_cookie.cpp

示例14: _GetRequirement

 void DependencyBinding::_GetRequirement(const ValueList& args, KValueRef result)
 {
     result->SetInt(this->dependency->requirement);
 }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:4,代码来源:dependency_binding.cpp

示例15: _GetType

 void DependencyBinding::_GetType(const ValueList& args, KValueRef result)
 {
     result->SetInt((int) this->dependency->type);
 }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:4,代码来源:dependency_binding.cpp


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