void MainWindow::hanldeInput(QObject* ptr) {
    // QLineEdit * pedit = (QLineEdit*)ptr;
    // lab->setText(pedit->text());

    if (mp_ldtInputfile->text().isEmpty()) {
        std::string curPath(QDir::currentPath().toStdString() + "/log");
        mp_ldtInputfile->setText(curPath.c_str());
    }
    if (mp_ldtOutputfile->text().isEmpty()) {
        QFileInfo fi(mp_ldtInputfile->text());
        if (fi.isDir()) {
            mp_ldtOutputfile->setText((mp_ldtInputfile->text().toStdString() + "/../" + "tmp_result.txt").c_str());
        }
        else {
            fi.makeAbsolute();
            mp_ldtOutputfile->setText((fi.path().toStdString() + "/../" + "tmp_result.txt").c_str());
        }
    }
    if (mp_ldtRoomid->text().isEmpty()) {
        mp_ldtRoomid->setText("roomid:46807");
    }
    if (mp_ldtInterval->text().isEmpty()) {
        mp_ldtInterval->setText("1");
    }


    ProcessingInfo *prInfo = new ProcessingInfo(mp_ldtInputfile->text().toStdString(),
                                                mp_ldtOutputfile->text().toStdString(),
                                                mp_ldtRoomid->text().toStdString(),
                                                atoi(mp_ldtInterval->text().toStdString().c_str()));

    prInfo->startProcess(mp_pttConsole);
    return;
}
Beispiel #2
0
 int minimumTotal(vector<vector<int>>& triangle) {
     if( triangle.empty() ) return 0;
     vector<int> curPath(triangle.size(), 0);
     curPath = triangle[triangle.size() - 1];
     for(int i = triangle.size() - 2; i >= 0; --i){
         for(int j = 0; j < i+1; j++){
             curPath[j] = std::min(curPath[j],curPath[j+1]) + triangle[i][j];
         }
     }
     return curPath[0];
 }
		const Path Instance::GetFullPath(const GenericString relPath)
		{
			Path curPath( "." );
			curPath.MakeAbsolute( true );

			const BOOL succeeded = ::SetCurrentDirectory( global.paths.wrkPath.Ptr() );

			Path wrkPath( relPath );
			wrkPath.MakeAbsolute();

			if (succeeded)
				::SetCurrentDirectory( curPath.Ptr() );

			return wrkPath;
		}
bool ProcessHelper::GetProcessID(QString path, quint32& dwPID) {

    path.replace("/", "\\");

    HANDLE hProcessSnap;
    HANDLE hProcess;
    PROCESSENTRY32 pe32;
    DWORD dwPriorityClass;

    // Take a snapshot of all processes in the system.
    hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hProcessSnap == INVALID_HANDLE_VALUE)
        return false;

    pe32.dwSize = sizeof(PROCESSENTRY32 );
    if (!Process32First(hProcessSnap, &pe32)) {
        CloseHandle(hProcessSnap);          // clean the snapshot object
        return(FALSE);
    }

    bool bRes = false;
    do {
        // Retrieve the priority class.
        dwPriorityClass = 0;
        hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
        if (hProcess)
        {
            CHAR lpPath[MAX_PATH];//will hold .exe path to be returned
            DWORD charsCarried = MAX_PATH; // holds size of path[], will then hold amount of characters returned by QueryFullProcessImageName
            QueryFullProcessImageNameA(hProcess, 0, lpPath, &charsCarried);
            CloseHandle(hProcess);

            QString curPath(lpPath);
            if (curPath.compare(path, Qt::CaseInsensitive) == 0) {
                bRes = true;
                dwPID = pe32.th32ProcessID;
                break;
            }
        }
    } while(Process32Next(hProcessSnap, &pe32));
    CloseHandle(hProcessSnap);
    return bRes;
}
Beispiel #5
0
void MltRuntime::add_runtime_entry(const JsonPath& path,
		json_t* script_serialed, int give) throw(Exception)
{
	if ( path.path.size() == 0) {
		throw_error_v(ErrorRuntimeUuidPathInvalid, "root path not allowed for add entry");
	}

	JsonPath parentPath(path);
	parentPath.path.pop_back();

	json_t* parent_je = json_serialize;
	JsonPath::PathCompIter it = parentPath.path.begin();

	for (; it != parentPath.path.end(); it++)
	{
		json_t* je = json_object_get(parent_je, it->name.c_str());
		if (!je) {
			throw_error_v(ErrorRuntimeUuidPathInvalid, "parent path invalid for add entry");
		}
		if ( it->type == JsonPathComponent::PathObject ) {
			if ( !json_is_object(je) ) {
				throw_error_v(ErrorRuntimeUuidPathInvalid, "parent path invalid for add entry");
			}
			parent_je = je;
		}
		else if (it->type == JsonPathComponent::PathArray ) {
			if (!json_is_array(je)) {
				throw_error_v(ErrorRuntimeUuidPathInvalid, "parent path invalid for add entry");
			}
			int sz = json_array_size(je);
			if (sz == 0) {
				throw_error_v(ErrorRuntimeUuidPathInvalid, "parent path invalid for add entry");
			}

			int idx = it->arr_idx;
			if (idx < 0) idx = sz + idx;
			if (idx < 0 || idx >= sz ) {
				throw_error_v(ErrorRuntimeUuidPathInvalid, "parent path invalid for add entry");
			}

			parent_je = json_array_get(je, idx);
		}
	}

	if (!json_is_object(parent_je)) {
		throw_error_v(ErrorRuntimeUuidPathInvalid, "parent path invalid for add entry");
	}

	const JsonPathComponent& lastPath = *(path.path.rbegin());
	if (lastPath.type == JsonPathComponent::PathArray) {
		json_t* cur = json_object_get(parent_je, lastPath.name.c_str());
		if ( !cur ) {
			cur = json_array();
			json_object_set_new(parent_je, lastPath.name.c_str(), cur);
		}

		if (!json_is_array(cur)) {
			throw_error_v(ErrorRuntimeUuidPathInvalid, " path invalid for add entry");
		}
		else {
			int idx = lastPath.arr_idx;
			int sz = json_array_size(cur);

			if (idx < 0) {
				idx = sz + idx + 1;
			}

			if (idx > sz) idx = sz;
			if (idx < 0) idx = 0;

			if ( idx == sz ) {
				JsonPath curPath(parentPath);
				curPath.push_back(lastPath.name.c_str(), idx);
				parse_struct(script_serialed, curPath, uuid_pathmap);
				if (give)
					json_array_append_new(cur, script_serialed);
				else
					json_array_append(cur, script_serialed);
			}
			else {
				JsonPath curPath(parentPath);
				curPath.push_back(lastPath.name.c_str(), idx);
				parse_struct(script_serialed, curPath, uuid_pathmap);
				if (give)
					json_array_insert_new(cur, idx, script_serialed);
				else
					json_array_insert(cur, idx, script_serialed);
			}
		}
	}
	else if (lastPath.type == JsonPathComponent::PathObject) {
		json_t* cur = json_object_get(parent_je, lastPath.name.c_str());
		if (cur) {
			throw_error_v(ErrorRuntimeUuidPathInvalid, " path invalid for add entry");
		}

		JsonPath curPath(parentPath);
		curPath.push_back(lastPath.name.c_str());
		parse_struct(script_serialed, curPath, uuid_pathmap);
		if (give) {
			json_object_set_new(parent_je, lastPath.name.c_str(), script_serialed);
		}
		else {
			json_object_set(parent_je, lastPath.name.c_str(), script_serialed);
		}
	}

	json_version++;
	return;
}