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


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

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


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

示例1: SetList

	void PropertiesBinding::SetList(const ValueList& args, KValueRef result)
	{
		if (args.size() >= 2 && args.at(0)->IsString() && args.at(1)->IsList())
		{
			std::string property = args.at(0)->ToString();
			KListRef list = args.at(1)->ToList();

			std::string value = "";
			for (unsigned int i = 0; i < list->Size(); i++)
			{
				KValueRef arg = list->At(i);
				if (arg->IsString())
				{
					value += list->At(i)->ToString();
					if (i < list->Size() - 1)
					{
						value += ",";
					}
				}
				else
				{
					std::cerr << "skipping object: " << arg->GetType() << std::endl;
				}
			}
			config->setString(property, value);
			if (file_path.size() > 0)
			{
				config->save(file_path);
			}
		}
	}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:31,代码来源:properties_binding.cpp

示例2: SetNS

void KObject::SetNS(const char *name, KValueRef value)
{
    std::vector<std::string> tokens;
    FileUtils::Tokenize(std::string(name), tokens, ".");

    KObject *scope = this;
    for (size_t i = 0; i < tokens.size() - 1; i++)
    {
        const char* token = tokens[i].c_str();
        StaticBoundObject *next;
        KValueRef next_val = scope->Get(token);

        if (next_val->IsUndefined())
        {
            next = new StaticBoundObject();
            KObjectRef so = next;
            next_val = Value::NewObject(so);
            scope->Set(token, next_val);
            scope = next;
        }
        else if (!next_val->IsObject()
                 && !next_val->IsMethod()
                 && !next_val->IsList())
        {
            std::cerr << "invalid namespace for " << name << ", token: " << token << " was " << next_val->GetType() << std::endl;
            throw Value::NewString("Invalid namespace on setNS");
        }
        else
        {
            scope = next_val->ToObject().get();
        }
    }

    const char *prop_name = tokens[tokens.size()-1].c_str();
    scope->Set(prop_name, value);

#ifdef DEBUG_BINDING
    std::cout << "BOUND: " << value->GetType() << " to: " << name << std::endl;
#endif
}
开发者ID:toisoftware,项目名称:TideSDK,代码行数:40,代码来源:kobject.cpp

示例3: convert

 void convert (Statement &select, KValueRef arg)
 {
     if (arg->IsString())
     {
         std::string *s = new std::string(arg->ToString()); 
         select , use(*s);
         strings.push_back(s);
     }
     else if (arg->IsInt())
     {
         int *i = new int(arg->ToInt());
         select , use(*i);
         ints.push_back(i);
     }
     else if (arg->IsDouble())
     {
         double *d = new double(arg->ToDouble());
         select , use(*d);
         doubles.push_back(d);
     }
     else if (arg->IsBool())
     {
         bool *b = new bool(arg->ToBool());
         select , use(*b);
         bools.push_back(b);
     }
     else if (arg->IsNull() || arg->IsUndefined())
     {
         // in this case, we bind a null string (dequoted)
         std::string *s = new std::string("null");
         select , use(s);
         strings.push_back(s);
     }
     else
     {
         throw ValueException::FromFormat("Unsupport type for argument: %s",
             arg->GetType().c_str());
     }
 } 
开发者ID:Defachko,项目名称:titanium_desktop,代码行数:39,代码来源:Database.cpp


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