/** \brief Export the results of a query set to an XML file.

  Run all of the queries in the given Query Set in the given order and write
  the results to an XML file. The XML file is constructed very simply:
  \verbatim
  <tablename>
    <column1name>columnvalue</column1name>
    <column2name>columnvalue</column2name>
    ...
  </tablename>
  \endverbatim

  If the caller passes in an XSLT map id, the simple XML will be processed
  using the export XSLT.

  \param qryheadid   The internal ID of the query set (qryhead record) to run.
  \param params      A list of parameters and values to use when building SQL
                     statements from MetaSQL statements.
  \param[in,out] filename The name of the file to create. If passed in empty,
                          a file named after the query set will be created
                          in the current directory (context-dependent) and
                          this filename will be passed back out.
  \param[out]    errmsg An message describing why the processing failed if there
                        was a problem.
  \param xsltmapid   An optional parameter. If this is set, it should be
                     the internal ID of an xsltmap record. The xsltmap_export
                     field of this record and the XSLTDefaultDir will be used
                     to find the XSLT script to run on the generated XML.
  */
bool ExportHelper::exportXML(const int qryheadid, ParameterList &params, QString &filename, QString &errmsg, const int xsltmapid)
{
  if (DEBUG)
    qDebug("ExportHelper::exportXML(%d, %d params, %s, errmsg, %d) entered",
           qryheadid, params.size(), qPrintable(filename), xsltmapid);
  bool returnVal = false;

  XSqlQuery setq;
  setq.prepare("SELECT * FROM qryhead WHERE qryhead_id=:id;");
  setq.bindValue(":id", qryheadid);
  setq.exec();
  if (setq.first())
  {
    if (filename.isEmpty())
    {
      QFileInfo fileinfo(setq.value("qryhead_name").toString());
      filename = fileinfo.absoluteFilePath();
    }

    QFile exportfile(filename);
    if (! exportfile.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text))
      errmsg = tr("Could not open %1 (%2).").arg(filename,exportfile.error());
    else
    {
      exportfile.write(generateXML(qryheadid, params, errmsg, xsltmapid).toUtf8());
      exportfile.close();
    }
  }
  else if (setq.lastError().type() != QSqlError::NoError)
    errmsg = setq.lastError().text();
  else
    errmsg = tr("<p>Cannot export data because the query set with "
                "id %1 was not found.").arg(qryheadid);

  if (DEBUG)
    qDebug("ExportHelper::exportXML returning %d, filename %s, and errmsg %s",
           returnVal, qPrintable(filename), qPrintable(errmsg));

  returnVal = errmsg.isEmpty();
  return returnVal;
}
Example #2
0
int main (int argc, char** argv){
	// Initialisierung
	if (argc == 1){
		initialize(inifile);
	} else if (argc > 1){
		initialize(argv[1]);
	}

	// Objekterkennung - Shi Tomasi
	Mat src = imread(inputPicture.c_str(), CV_LOAD_IMAGE_GRAYSCALE);
	vector<Point2f> corners;

	goodFeaturesToTrack(src, corners, maxCorners, qualityLevel, 
			minDistance, Mat(), blockSize, useHarrisDetector, k);
	cout << "Erkannte Ecken :" << corners.size() << endl;

	// sortieren der Eckpunkte nach der Entfernung zum Ursprung
	vector<Point2f> sortCorners = sortVectorPoints(corners);

	
	// exportieren der Eckpunkte
	ofstream exportfile(exportFile, ios::trunc);
	if (exportfile.is_open()){
		for (int i = 0; i < sortCorners.size(); i++){
			string line = to_string(sortCorners[i].x) + ";" + to_string(sortCorners[i].y);
			exportfile << line << endl;
		}
		exportfile.close();
	}

	
	// exportieren eines Bildes mit erkannten Ecken
	Mat copy;
	copy = src.clone();

	for( int i = 0; i < sortCorners.size(); i++ )
		{ circle( copy, sortCorners[i], circle_radius, Scalar(0),
					2, 8, 0 ); }
	imwrite(exportPicFile, copy);
}
Example #3
0
void processcommand( char *command, char *P1, char *P2, char *P3 ) {

    if( strcmp(command, "createvfs") == 0 ) {
        int size = atoi(P2);
        if( (0 == strcmp(P1,"")) || 0 == P2 ) {
            printf("createvfs_FAILURE %s \n",ERR_VFS_CREATE_00);
        } else {
            createvfs (P1,size);
        }
    }
    else if( strcmp(command, "mountvfs") == 0 ) {
        if( (0 == strcmp(P1,"")) ) {
            printf("mountvfs_FAILURE %s \n",ERR_VFS_MOUNT_05);
        } else {
            if( 1 == ui_mountFlag ) {
                printf("mountvfs_FAILURE %s \n",ERR_VFS_MOUNT_04);
            } else {
                mountvfs (P1);
            }
        }
    }
    else if( strcmp(command, "unmountvfs") == 0 ) {
        if( (0 == strcmp(P1,"")) ) {
            printf("unmountvfs_FAILURE %s \n",ERR_VFS_UNMOUNT_00);
        } else {
            if( 0 == ui_mountFlag ) {
                printf("unmountvfs_FAILURE %s \n",ERR_VFS_UNMOUNT_04);
            } else {
                unmountvfs (P1);
            }
        }
    }
    else if( strcmp(command, "makedir") == 0 ) {
        if( (0 == strcmp(P1,"")) || (0 == strcmp(P2,"")) ) {
            printf("makedir_FAILURE %s \n",ERR_VFS_MAKEDIR_00);
        } else {
            if( 0 == ui_mountFlag ) {
                printf("makedir_FAILURE %s \n",ERR_VFS_MAKEDIR_05);
            } else {
                makedir (P1,P2);
            }
        }
    }
    else if( strcmp(command, "deletedir") == 0 )
        deletedir (P1);
    else if( strcmp(command, "movedir") == 0 )
        movedir (P1,P2);
    else if( strcmp(command, "listdir") == 0 ) {
        int flag = atoi(P2);
        listdir (P1,flag,P3);
    }
    else if( strcmp(command, "addfile") == 0 )
        addfile (P1,P2,P3);
    else if( strcmp(command, "listfile") == 0 )
        listfile (P1,P2);
    else if( strcmp(command, "updatefile") == 0 )
        updatefile (P1,P2);
    else if( strcmp(command, "removefile") == 0 )
        removefile (P1);
    else if( strcmp(command, "movefile") == 0 )
        movefile (P1,P2);
    else if( strcmp(command, "copyfile") == 0 )
        copyfile (P1,P2);
    else if( strcmp(command, "exportfile") == 0 )
        exportfile (P1,P2);
    else if( strcmp(command, "searchfile") == 0 )
        searchfile (P1,P2);
    else
        printf("Ignoring invalid command %s\n", command);
}
Example #4
0
int shell(int *g) {
	char command[BUFFER_SIZE];
	char func[BUFFER_SIZE],arg1[BUFFER_SIZE],arg2[BUFFER_SIZE];
	int i;

	minifile_cd("/"); //cd to root (will also initialize the system if necessary)
	printf("%s\n", IDstring);

	while(1) {
		memset(command,'\0',BUFFER_SIZE);
		memset(func,'\0',BUFFER_SIZE);
		memset(arg1,'\0',BUFFER_SIZE);
		memset(arg2,'\0',BUFFER_SIZE);
		put_prompt();
		gets(command);
		//extract first three strings in command (delimited by spaces)
		sscanf(command,"%s %s %s",func,arg1,arg2);
		if(strcmp(func,"help") == 0)
			help_screen();
		else if(strcmp(func,"cd") == 0)
			minifile_cd(arg1);
		else if(strcmp(func,"ls") == 0 || strcmp(func,"dir") == 0) {
		  char **files = minifile_ls(arg1);
		  printf("File listing for %s\n", arg1);
		  for(i = 0; files != NULL && files[i] != NULL; ++i) {
		    printf("\t%s\n",files[i]);
		    free(files[i]);
		  }
		  if(files != NULL)
		    free(files);
		} else if(strcmp(func,"pwd") == 0)
		        printf("%s\n", minifile_pwd());
		else if(strcmp(func,"mkdir") == 0)
		        minifile_mkdir(arg1);
		else if(strcmp(func,"rmdir") == 0)
			minifile_rmdir(arg1);
		else if(strcmp(func,"rm") == 0 || strcmp(func,"del") == 0)
			minifile_unlink(arg1);
		else if(strcmp(func,"import") == 0)
			importfile(arg1,arg2);
		else if(strcmp(func,"export") == 0)
			exportfile(arg1,arg2);
		else if(strcmp(func,"type") == 0)
			typefile(arg1);
		else if(strcmp(func,"input") == 0)
			inputfile(arg1);
		else if(strcmp(func,"cp") == 0 || strcmp(func,"copy") == 0)
			copy(arg1,arg2);
		else if(strcmp(func,"mv") == 0 || strcmp(func,"move") == 0)
			move(arg1,arg2);
		else if(strcmp(func,"whoami") == 0)
			printf("You are minithread %d, running our shell\n",minithread_id());
		else if(strcmp(func,"exit") == 0)
			break;
		else if(strcmp(func,"doscmd") == 0)
			system(command+7);
		else if(strcmp(func,"exec") == 0) { //this is not efficient -- just for fun!!!
			char cmdline[BUFFER_SIZE];
			memset(cmdline,'\0',BUFFER_SIZE);
			strcpy(cmdline,"tmp0000~.exe ");
			strcpy(cmdline+13,command+5+strlen(arg1));
			exportfile(arg1,"tmp0000~.exe");
			system(cmdline);
			system("rm tmp0000~.exe");
		}
		else printf("%s: Command not found\n",func);
	}
	printf("Good-bye :-)\n");
	return 0;
}