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


C++ KListRef类代码示例

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


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

示例1: StaticBoundList

KListRef Win32UserWindow::SelectDirectory(
	bool multiple,
	std::string& title,
	std::string& path,
	std::string& defaultName)
{
	KListRef results = new StaticBoundList();

	BROWSEINFO bi = { 0 };
	std::wstring titleW = UTF8ToWide(title);
	bi.lpszTitle = titleW.c_str();
	bi.hwndOwner = this->windowHandle;
	bi.ulFlags = BIF_RETURNONLYFSDIRS;
	LPITEMIDLIST pidl = SHBrowseForFolder(&bi);

	if (pidl != 0)
	{
		wchar_t in_path[MAX_PATH];
		if (SHGetPathFromIDList(pidl, in_path))
		{
			std::wstring inPathW = in_path;
			std::string inPath = WideToUTF8(inPathW);
			results->Append(Value::NewString(inPath));
		}

		IMalloc * imalloc = 0;
		if (SUCCEEDED(SHGetMalloc(&imalloc)))
		{
			imalloc->Free(pidl);
			imalloc->Release();
		}
	}
	return results;
}
开发者ID:mital,项目名称:titanium_desktop,代码行数:34,代码来源:win32_user_window.cpp

示例2: ResolveFileName

	void FilesystemBinding::ResolveFileName(const ValueList& args, std::string& filename)
	{
		if (args.at(0)->IsList())
		{
			// you can pass in an array of parts to join
			KListRef list = args.at(0)->ToList();
			for (size_t c = 0; c < list->Size(); c++)
			{
				std::string arg = list->At(c)->ToString();
				filename = kroll::FileUtils::Join(filename.c_str(), arg.c_str(), NULL);
			}
		}
		else
		{
			// you can pass in vararg of strings which acts like  a join
			for (size_t c = 0; c < args.size(); c++)
			{
				std::string arg = FileSystemUtils::GetFileName(args.at(c))->c_str();
				filename = kroll::FileUtils::Join(filename.c_str(), arg.c_str(), NULL);
			}
		}
		if (filename.empty())
		{
			throw ValueException::FromString("invalid file type");
		}
	}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:26,代码来源:filesystem_binding.cpp

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

示例4: SetList

void Properties::SetList(const ValueList& args, KValueRef result)
{
    args.VerifyException("setList", "s l");

    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
        {
            logger->Warn("Skipping list entry %ui, not a string", i);
        }
    }
    config->setString(property, value);
    this->SaveConfig();
    
}
开发者ID:Defachko,项目名称:titanium_desktop,代码行数:28,代码来源:Properties.cpp

示例5: Minimum

void Calc::Minimum(const ValueList& args, KValueRef result)
{
	if (args.at(0)->IsList())
	{
		KListRef list = args.at(0)->ToList();

		double *arr = NULL;

		arr = new double[list->Size()];

		for (unsigned int c = 0; c < list->Size(); c++)
		{
			KValueRef d = list->At(c);
			arr[c] = d->ToDouble();
		}

		double low = Min(arr, list->Size());

		result->SetDouble(low);

		delete [] arr;

   } else {
		throw ValueException::FromString("Minimum takes an array");
   }

}
开发者ID:zcopley,项目名称:ti.Calc,代码行数:27,代码来源:Calc.cpp

示例6: StaticBoundList

	void UIBinding::_GetOpenWindows(const ValueList& args, KValueRef result)
	{
		KListRef list = new StaticBoundList();
		std::vector<AutoUserWindow>::iterator w = openWindows.begin();
		while (w != openWindows.end()) {
			list->Append(Value::NewObject(*w++));
		}
		result->SetList(list);
	}
开发者ID:ksmythe,项目名称:titanium_desktop,代码行数:9,代码来源:ui_binding.cpp

示例7: StaticBoundList

 KListRef APIBinding::DependencyVectorToKList(std::vector<SharedDependency>& deps)
 {
     KListRef dependencyList = new StaticBoundList();
     std::vector<SharedDependency>::iterator i = deps.begin();
     while (i != deps.end())
     {
         KValueRef dValue = Value::NewObject(new DependencyBinding(*i++));
         dependencyList->Append(dValue);
     }
     return dependencyList;
 }
开发者ID:fossamikom,项目名称:TideSDK,代码行数:11,代码来源:api_binding.cpp

示例8: ArgListToString

/*
    Inspired by python's os.list2cmdline, ported to C++ by Marshall Culpepper
    
    Translate a sequence of arguments into a command line
    string, using the same rules as the MS C runtime:

    1) Arguments are delimited by white space, which is either a
       space or a tab.

    2) A string surrounded by double quotation marks is
       interpreted as a single argument, regardless of white space
       contained within.  A quoted string can be embedded in an
       argument.

    3) A double quotation mark preceded by a backslash is
       interpreted as a literal double quotation mark.

    4) Backslashes are interpreted literally, unless they
       immediately precede a double quotation mark.

    5) If backslashes immediately precede a double quotation mark,
       every pair of backslashes is interpreted as a literal
       backslash.  If the number of backslashes is odd, the last
       backslash escapes the next double quotation mark as
       described in rule 3.
    See
    http://msdn.microsoft.com/library/en-us/vccelng/htm/progs_12.asp
*/
std::string ProcessWin::ArgListToString(KListRef argList)
{
    
    std::string result = "";
    bool needQuote = false;
    for (int i = 0; i < argList->Size(); i++)
    {
        std::string arg = argList->At(i)->ToString();
        std::string backspaceBuf = "";
        
        // Add a space to separate this argument from the others
        if (result.size() > 0) {
            result += ' ';
        }

        needQuote = (arg.find_first_of(" \t") != std::string::npos) || arg == "";
        if (needQuote) {
            result += '"';
        }

        for (int j = 0; j < arg.size(); j++)
        {
            char c = arg[j];
            if (c == '\\') {
                // Don't know if we need to double yet.
                backspaceBuf += c;
            }
            else if (c == '"') {
                // Double backspaces.
                result.append(backspaceBuf.size()*2, '\\');
                backspaceBuf = "";
                result.append("\\\"");
            }
            else {
                // Normal char
                if (backspaceBuf.size() > 0) {
                    result.append(backspaceBuf);
                    backspaceBuf = "";
                }
                result += c;
            }
        }
        // Add remaining backspaces, if any.
        if (backspaceBuf.size() > 0) {
            result.append(backspaceBuf);
        }

        if (needQuote) {
            result.append(backspaceBuf);
            result += '"';
        }
    }
    return result;
}
开发者ID:Defachko,项目名称:titanium_desktop,代码行数:82,代码来源:ProcessWin.cpp

示例9: StaticBoundList

void HostBinding::GetAliases(const ValueList& args, KValueRef result)
{
    KListRef list = new StaticBoundList();
    std::vector<std::string> aliases = this->host.aliases();
    std::vector<std::string>::iterator iter = aliases.begin();
    while (iter!=aliases.end())
    {
        std::string alias = (*iter++);
        list->Append(Value::NewString(alias));
    }
    result->SetList(list);
}
开发者ID:JohnOscarThomson,项目名称:TideSDK,代码行数:12,代码来源:host_binding.cpp

示例10: argList

	void AppBinding::GetArguments(const ValueList& args, KValueRef result)
	{
		static KListRef argList(0);
		if (argList.isNull())
		{
			// Skip the first argument which is the filename to the executable
			argList = new StaticBoundList();
			for (int i = 1; i < host->GetCommandLineArgCount(); i++)
				argList->Append(Value::NewString(host->GetCommandLineArg(i)));
		}

		result->SetList(argList);
	}
开发者ID:mital,项目名称:titanium_desktop,代码行数:13,代码来源:app_binding.cpp

示例11: argList

	void AppBinding::GetArguments(const ValueList& args, KValueRef result)
	{
		static KListRef argList(0);
		if (argList.isNull())
		{
			// Skip the first argument which is the filename of the executable.
			std::vector<std::string>& args = host->GetApplication()->GetArguments();
			argList = new StaticBoundList();
			for (size_t i = 1; i < args.size(); i++)
				argList->Append(Value::NewString(args.at(i)));
		}

		result->SetList(argList);
	}
开发者ID:Adimpression,项目名称:TideSDK,代码行数:14,代码来源:app_binding.cpp

示例12: StaticBoundList

	void Bytes::_Split(const ValueList& args, KValueRef result)
	{
		// This method now follows the spec located at:
		// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/split
		// Except support for regular expressions
		args.VerifyException("Bytes.split", "?s,i");

		KListRef list = new StaticBoundList();
		result->SetList(list);

		std::string target = "";
		if (this->size > 0)
		{
			target = this->buffer;
		}
		else
		{
			list->Append(Value::NewString(target));
			return;
		}

		if (args.size() <= 0)
		{
			list->Append(Value::NewString(target));
			return;
		}

		std::string separator = args.GetString(0);

		int limit = args.GetInt(1, INT_MAX);

		// We could use Poco's tokenizer here, but it doesn't split strings
		// like "abc,def,," -> ['abc', 'def', '', ''] correctly. It produces
		// ['abc', 'def', ''] which is a different behavior than the JS split.
		// So we roll our own for now -- it's not very efficient right now, but
		// it should be correct.
		size_t next = target.find(separator);
		while (target.size() > 0 && next != std::string::npos)
		{
			std::string token;
			if (separator.size() == 0)
			{
				token = target.substr(0, 1);
			}
			else
			{
				token = target.substr(0, next);
			}
			target = target.substr(next + 1);
			next = target.find(separator);

			if ((int) list->Size() >= limit)
				return;

			list->Append(Value::NewString(token));
		}

		if ((int) list->Size() < limit && separator.size() != 0)
			list->Append(Value::NewString(target));
	}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:60,代码来源:bytes.cpp

示例13: if

	void FilesystemBinding::ExecuteAsyncCopy(const ValueList& args, KValueRef result)
	{
		if (args.size()!=3)
		{
			throw ValueException::FromString("invalid arguments - this method takes 3 arguments");
		}
		std::vector<std::string> files;
		if (args.at(0)->IsString())
		{
			files.push_back(args.at(0)->ToString());
		}
		else if (args.at(0)->IsList())
		{
			KListRef list = args.at(0)->ToList();
			for (unsigned int c = 0; c < list->Size(); c++)
			{
				KValueRef v = list->At(c);
				files.push_back(FileSystemUtils::GetFileName(v)->c_str());
			}
		}
		else
		{
			files.push_back(FileSystemUtils::GetFileName(args.at(0))->c_str());
		}
		KValueRef v = args.at(1);
		std::string destination(FileSystemUtils::GetFileName(v)->c_str());
		KMethodRef method = args.at(2)->ToMethod();
		KObjectRef copier = new ti::AsyncCopy(this,host,files,destination,method);
		result->SetObject(copier);
		asyncOperations.push_back(copier);
		// we need to create a timer thread that can cleanup operations
		if (timer==NULL)
		{
			this->SetMethod("_invoke",&FilesystemBinding::DeletePendingOperations);
			timer = new Poco::Timer(100,100);
			Poco::TimerCallback<FilesystemBinding> cb(*this, &FilesystemBinding::OnAsyncOperationTimer);
			timer->start(cb);
		}
		else
		{
			this->timer->restart(100);
		}
	}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:43,代码来源:filesystem_binding.cpp

示例14: GetStringList

void KObject::GetStringList(const char *name, std::vector<std::string> &list)
{
    KValueRef prop = this->Get(name);
    if(!prop->IsUndefined() && prop->IsList())
    {
        KListRef values = prop->ToList();
        if (values->Size() > 0)
        {
            for (unsigned int c = 0; c < values->Size(); c++)
            {
                KValueRef v = values->At(c);
                if (v->IsString())
                {
                    const char *s = v->ToString();
                    list.push_back(s);
                }
            }
        }
    }
}
开发者ID:toisoftware,项目名称:TideSDK,代码行数:20,代码来源:kobject.cpp

示例15: GetString

	void PropertiesBinding::GetList(const ValueList& args, KValueRef result)
	{
		KValueRef stringValue = Value::Null;
		GetString(args, stringValue);

		if (!stringValue->IsNull())
		{
			KListRef list = new StaticBoundList();
			std::string string = stringValue->ToString();
			Poco::StringTokenizer t(string, ",", Poco::StringTokenizer::TOK_TRIM);
			for (size_t i = 0; i < t.count(); i++)
			{
				KValueRef token = Value::NewString(t[i].c_str());
				list->Append(token);
			}

			KListRef list2 = list;
			result->SetList(list2);
		}
	}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:20,代码来源:properties_binding.cpp


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