Beispiel #1
0
// entry point
int main(int argc, char** argv) {
    g.windowWidth = 600;
    g.windowHeight = 600;
    
    g.width = 10;
    g.height = 10;

    g.currentTiling = 0;
    g.displayTiling = 0;
    g.displayStar = 1;
    g.angle = 60.0f;
    g.interlace = 0;
    
    g.tile_stroke_color[0] = g.tile_stroke_color[1] = 0;
    g.tile_stroke_color[2] = 255;
    g.tile_fill_color.fill(255);
    g.tile_fill_transparent = 1;
    g.tile_stroke_width = 0.125f;

    g.bkgd_color.fill(255);

    g.star_stroke_color.fill(0);
    g.star_fill_color.fill(128);
    g.star_fill_transparent = 0;
    g.star_stroke_width = 0.1f;

    g.ribbon_color.fill(0);
    g.ribbon_color[0] = 255;
    g.ribbon_size = 0.075f;

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
    glutInitWindowSize(g.windowWidth, g.windowHeight);
    glutInitWindowPosition(30, 30);
    g.glutWindow = glutCreateWindow("tiling");

    glClearColor(0, 0, 0, 1);
    glMatrixMode(GL_PROJECTION | GL_MATRIX_MODE);
    glLoadIdentity();

    glOrtho(0, g.width, g.height, 0, 0, 1);

    glutDisplayFunc(displayFunc);
    glutKeyboardFunc(keyboardFunc);

    initGLUI();

    parseXML("tilings/archimedeans.tl");
    parseXML("tilings/hanbury.tl");

    glutMainLoop();
    return 0;
}
bool FormListAerodroms::openXML(const QString &fileName)
{
    bool openFile=false;
    QFile file(fileName);

    openFile=file.open(QIODevice::ReadOnly);
    if(openFile==true)
    {
        bool readXML=false;

        readXML=domAerodroms.setContent(&file,true);
        if(readXML==true)
        {
            QDomElement root=domAerodroms.documentElement();
            parseXML(root.toElement());
        }
        else
        {
            QMessageBox::warning(0,tr("Внимание"),
                                 tr("Ошибка в структуре XML файла \n = "))+QString(XML_AERODROMS);
            return false;
        }
    }
    /*else
    {
        QMessageBox::warning(0,tr("Внимание"),
                             tr("Файл не найден = "))+QString(VARIANT_FILE);
    }*/
    return openFile;
}
  void MOOSAppDocumentation::loadXML()
  {
    string repository_path = getRepositoryPath();
    string doc_path = repository_path + "/src/app/" + m_moosapp_name + "/" + m_moosapp_name + ".xml";

    // Test file existance with ifstream
    ifstream xmlfile(doc_path.c_str());
    if(!xmlfile)
    {
      red("  ERROR: unable to load " + m_moosapp_name + ".xml documentation file.");
      blk("  Please check file existance at:");
      blk("  " + doc_path + "\n");
      exit(0);
    }

    // Test XML validity
    string item_error = "";
    m_xml_doc = new XMLDocument();
    if(m_xml_doc->LoadFile(doc_path.c_str()) != XML_NO_ERROR || !parseXML(item_error))
    {
      red("  ERROR: unable to load " + m_moosapp_name + ".xml documentation file.");
      if(item_error != "")
        blk("  Unable to read <" + item_error + ">");
      blk("  Please check XML validity at:");
      blk("  " + doc_path + "\n");
      exit(0);
    }
  }
Beispiel #4
0
bool XMLMetadata::initFromRaw(const unsigned char *raw, size_t len)
{
	char *_name = initDoc((const char *)raw, len);

	if (!_name) {
		fprintf(stderr, "Could not create document\n");
		if (doc)
			xmlFreeDoc(doc);
		doc = NULL;
		return false;
	}

        if (!parseXML(xmlDocGetRootElement(doc))) {
                fprintf(stderr, "Parse XML failed\n");
                xmlFreeDoc(doc);
		doc = NULL;
                return false;
        }

	name = _name;
        
        xmlChar *content = xmlNodeGetContent(xmlDocGetRootElement(doc));
        
	if (content) {
                setContent((char *)content);
		xmlFree(content);
	}

        xmlFreeDoc(doc);
	doc = NULL;

	return true;
}
std::vector<as_value>
ExternalInterface::parseArguments(const std::string &xml)
{
    // GNASH_REPORT_FUNCTION;

    std::vector<as_value> args;
    std::string::size_type start = 0;
    std::string::size_type end;

    std::string name;
    std::string data = xml;
    std::string tag = "<arguments>";
    start = data.find(tag);
    if (start != std::string::npos) {
        data.erase(0, tag.size());
    }
    while (!data.empty()) {
        // Extract the data
        start = data.find("<", 1); // start past the opening <
        end = data.find(">", start) + 1;
        std::string sub = data.substr(0, end);
        if (data == "</arguments>") {
            break;
        }
        args.push_back(parseXML(sub));
        data.erase(0, end);
    }

    return args;
}
TabDialog::TabDialog(QWidget *parent)
    : QDialog(parent)
{

    tabWidget = new QTabWidget;

    /*
     * TO DO: Populate tabWidget with tabs retrieved from parsed XML
     */

    parseXML();

    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
    mainLayout->addWidget(tabWidget);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);

    setWindowTitle(tr("FinTP Config GUI"));
}
Beispiel #7
0
void dl_tvpot(std::string url)
{
	streamInfo currentInfo;
	vidUrlInfo currentVidInfo;
	std::string url_xml;
	std::string url_json;
	std::string v_title;

	int list = 0;

	if (getStreamInfo(retrievePage((char *)url.c_str()), &currentInfo, NULL, TYPE_TVPOT) == RETRIEVE_FAIL)
		printLine(-1);
	else
	{
		printLine(2);
		url_json = "http://videofarm.daum.net/controller/api/closed/v1_2/IntegratedMovieData.json?vid=" + currentInfo.v_id + "&dte_type=WEB";
		parseJson(url_json, &currentVidInfo, &list, TYPE_TVPOT);
		url_xml = "http://videofarm.daum.net/controller/api/open/v1_2/MovieLocation.apixml?vid=" + currentInfo.v_id + "&profile=" + profile_list[currentVidInfo.profile];
		parseXML(url_xml, &currentVidInfo, TYPE_TVPOT);
		printLine(3);
		getline(cin, v_title);
		printLine(4);
		retrieveFileFromUrl(currentVidInfo.url[0], v_title, TYPE_TVPOT, 1, NULL);
		cout << v_title;
		printLine(0);
	}
}
Beispiel #8
0
    void XMLParser::parseXMLFile(XMLHandler& handler, const String& filename, const String& schemaName, const String& resourceGroup)
    {
        // Acquire resource using CEGUI ResourceProvider
        RawDataContainer rawXMLData;
        System::getSingleton().getResourceProvider()->loadRawDataContainer(filename, rawXMLData, resourceGroup);

        try
        {
            // The actual parsing action (this is overridden and depends on the specific parser)
            parseXML(handler, rawXMLData, schemaName);
        }
        catch (const Exception&)
        {
            // hint the related file name in the log
            Logger::getSingleton().logEvent("The last thrown exception was related to XML file '" +
                                            filename + "' from resource group '" + resourceGroup + "'.", Errors);

            // exception safety
            System::getSingleton().getResourceProvider()->unloadRawDataContainer(rawXMLData);

            CEGUI_RETHROW;
        }

        // Release resource
        System::getSingleton().getResourceProvider()->unloadRawDataContainer(rawXMLData);
    }
Beispiel #9
0
    void XMLParser::parseXMLString(XMLHandler& handler, const String& source, const String& schemaName)
    {
        // Put the source string into a RawDataContainer
        RawDataContainer rawXMLData;

        const char* c_str = source.c_str();
        rawXMLData.setData((uint8*)c_str);
        rawXMLData.setSize(strlen(c_str));

        try
        {
        	// The actual parsing action (this is overridden and depends on the specific parser)
        	parseXML(handler, rawXMLData, schemaName);
        }
        catch(...)
        {
        	// make sure we don't allow rawXMLData to release String owned data no matter what!
        	rawXMLData.setData(0);
			rawXMLData.setSize(0);

			CEGUI_RETHROW;
        }

        // !!! We must not allow DataContainer to delete String owned data,
        //     therefore, we set it's data to 0 to avoid double-deletion
        rawXMLData.setData(0);
        rawXMLData.setSize(0);
    }
Beispiel #10
0
/* load XML from token stream */
Ref<XML> parseXML(Ref<Stream<int> > chars, std::string id, bool hasHeader = true, bool hasTail = false)
{
    /* create lexer for XML file */
    std::vector<std::string> symbols;
    symbols.push_back("<!--");
    symbols.push_back("-->");
    symbols.push_back("<?");
    symbols.push_back("?>");
    symbols.push_back("</");
    symbols.push_back("/>");
    symbols.push_back("<");
    symbols.push_back(">");
    symbols.push_back("=");
    Ref<Stream<Token> > cin = new TokenStream(chars,TokenStream::alpha + TokenStream::ALPHA + "_" + id, TokenStream::separators, symbols);

    if (hasHeader) parseHeader(cin);
    parseComments(cin);
    Ref<XML> xml = parseXML(cin);
    parseComments(cin);

    if (!hasTail)
        if (cin->peek() != Token::Eof()) THROW_RUNTIME_ERROR(cin->peek().Location().str()+": end of file expected");

    return xml;
}
Beispiel #11
0
const char* ieee1888_parseXML_transport(const char* strbuf, int len, ieee1888_transport* transport){
  
  const char* p;
  const char* q;
  p=strbuf;

  XMLNode node;
  while((q=parseXML(p,len,&node))!=NULL){
    switch(node.type){
    case XML_ELEMENT_BEGIN:

      if(strcmp(node.name,"header")==0){
         // call ieee1888_parseXML_header(...);
	 ieee1888_header* header=ieee1888_mk_header();
	 if((q=ieee1888_parseXML_header(p,len,header))==NULL){
           ieee1888_destroy_objects((ieee1888_object*)header);
	   free(header);
	   return NULL;
	 }
	 transport->header=header;

      }else if(strcmp(node.name,"body")==0){
         // call ieee1888_parseXML_body(...);
	 ieee1888_body* body=ieee1888_mk_body();
	 if((q=ieee1888_parseXML_body(p,len,body))==NULL){
	   ieee1888_destroy_objects((ieee1888_object*)body);
	   free(body);
	   return NULL;
	 }
	 transport->body=body;
      }else if(strcmp(node.name,"transport")!=0){
        // error
        fprintf(stderr,"Fatal error: unknown object \"%s\" appeared in \"transport\"\n", node.name);
	return NULL;
      }
      break;

    case XML_ATTRIBUTE:
      // error if node.name!="xmlns"
      if(strcmp(node.name,"xmlns")!=0){
        fprintf(stderr,"Fatal error: unknown attribute \"%s\" in transport object \n",node.name);
	return NULL;
      }
      break;

    case XML_TEXT:
      break;

    case XML_ELEMENT_END:
      return q;
    
    }
    len-=(q-p);
    p=q;
  }

  return NULL;
}
bool UpdateThreadOld::pollUpdates()
{
	if (!m_pWebCore || !m_pUser)
		return false;

	updateBuildVer();

	std::map<std::string, std::string> post;

#ifdef DESURA_NONGPL_BUILD
	post["appid"] = gcString("{0}", m_iAppId);
	post["build"] = gcString("{0}", m_iAppVersion);
#endif

	for (uint32 x=0; x< m_pUser->getItemManager()->getCount(); x++)
	{
		UserCore::Item::ItemInfoI* item = m_pUser->getItemManager()->getItemInfo(x);

		if (!item)
			continue;

		if (!(item->getStatus() & UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER) || (item->getStatus()&UserCore::Item::ItemInfoI::STATUS_ONACCOUNT))
			continue;

		DesuraId id = item->getId();

		if (id.getType() == DesuraId::TYPE_LINK)
			continue;

		gcString key("updates[{0}][{1}]", id.getTypeString().c_str(), id.getItem());
		post[key] = "1";
	}

	TiXmlDocument doc;

	try
	{
		m_pWebCore->getUpdatePoll(doc, post);
	}
	catch (gcException &e)
	{
		Warning(gcString("Update poll failed: {0}\n", e));
		return false;
	}

	parseXML(doc);

#ifdef WIN32
	checkFreeSpace();
#endif

	m_hHttpHandle->cleanPostInfo();
	m_hHttpHandle->cleanUp();
	m_hHttpHandle->clearCookies();

	return true;
}
Beispiel #13
0
bool 
CControlObject::getDataFromServer( void )
{
	//int nRetCode = 0;
	//DWORD errorCode = 0;
	bool rv = true;

	char szURL[ 256 ];
	//char wrkbuf[ 25 ];
	
	strcpy( szURL, m_szServerURL );
	strcat( szURL, _T("/lrfobjects.php?cmd=list1" ) );

	
	// Max distance
	//if ( 0 != m_maxDistance ) {
	//	wcscat( szURL, _T("&max=") );
	//	swprintf( wrkbuf, _T("%i"), m_maxDistance * 1000 );
	//	wcscat( szURL, wrkbuf );
	//}

	// Max items to display 
	//wcscat( szURL, _T("&limit=") );
	//swprintf( wrkbuf, _T("%d"), MAX_ITEMS_LISTED );
	//wcscat( szURL, wrkbuf );

	// Maximum number of objects to display m_maxDisplayItems
	//wcscat( szURL, _T("&limit=") );
	//swprintf( wrkbuf, _T("%d"), m_maxDisplayItems );
	//wcscat( szURL, wrkbuf );

 
	char* szXMLPage = new char[ MAX_WEBPAGE_SIZE + 1 ];
	DWORD cnt = 0;
	
	if ( NULL != szXMLPage ) { 
		
		if ( 0 < ( cnt = doHtmlPageFetch( szURL, szXMLPage, MAX_WEBPAGE_SIZE ) ) ) {

			// Initialize the parse object
			m_bObjectTag = false;
			m_bStartTag = false;
			m_depth = 0;
			memset (m_xmlbuf, 0, sizeof( m_xmlbuf ) );
			*m_curtagname = 0;

			parseXML( (char *)szXMLPage, cnt );		 

		} // Fetchpage
		
		delete [] szXMLPage;
	}

	return rv;

}
int main(int argc, char** argv) {

    FILE* fp = openFile("input.xml");

    XMLNode* root = parseXML(fp);

    printXML(root);

    return (EXIT_SUCCESS);
}
Beispiel #15
0
void mainLoop(void) {
	DIR*	inpDir;
	struct dirent	*cdEntry;
	struct itimerval	tm_alarm;
	struct sigaction sa;

	/* if everything went ok, we should have a pointer in input_dir with the input directory name */
	if (!input_dir) {
		input_dir=(char*)malloc(sizeof(char)*PATH_MAX);
		getcwd(input_dir, PATH_MAX);
	}
	if ( ( inpDir = opendir(input_dir)) == NULL) {
		fprintf (stderr, "Cannot open %s, system error:%s\n", input_dir, strerror(errno));
		exit ( EXIT_FAILURE );
	}
	printD ("Opened %s successfully\n", input_dir);
	printD ("Scanning Directory...\n");
	/* mainly it seems everything ok, so initialize datastructs for our data */
	curMovie = (struct ST_movie*)malloc(sizeof(struct ST_movie));
	curMovie->actors = NULL;
	curMovie->plot = NULL;
	curMovie->tagline = NULL;
	curTV = (struct ST_tv*)malloc(sizeof(struct ST_tv));
	curTV->actors = NULL;
	curTV->plot = NULL;
	curTV->tagline = NULL;
	printD ("Setting up timer...\n");
	tm_alarm.it_value.tv_sec = display_alarm_wait;
	tm_alarm.it_value.tv_usec = 0L;
	tm_alarm.it_interval.tv_sec = display_alarm_wait;
	tm_alarm.it_interval.tv_usec = 0L;
	memset (&sa, 0, sizeof(struct sigaction));
	sa.sa_handler = &printStat;
	sigaction (SIGALRM, &sa, NULL);
	setitimer (ITIMER_REAL, &tm_alarm, NULL);
	printf ("Starting my work in directory: %s\n", input_dir);
	while (( cdEntry = readdir(inpDir)) != NULL) 	{
		/* is it a .xml File ? */
		if (strncasecmp(".xml", &cdEntry->d_name[strlen(&cdEntry->d_name[0])-4], 4) == 0 ) {
			if (parseXML(input_dir, &cdEntry->d_name[0])) {
				printD ("Successfully parsed: %s\n", &cdEntry->d_name[0]);
			}
			else {
				printD ("Parsing of XML failed:%s\n", &cdEntry->d_name[0]);
			}
		}
	}
	printf ("\nTV Episodes written:%li, ", TVCntr);
	printf ("Movies written:%li, ", movieCntr);
	printf ("Total entries written:%li", mediaCntr);
	if (db_newstable)
		createNews();
	closedir(inpDir);
}
Beispiel #16
0
int loadAgents(void) {

    struct controlData data;

    /* initialise data */
    data.index = 0;
    data.state = TAG_OUTSIDE;

    return parseXML(INPUT_FILE, startElemCallback,
                    endElemCallback, charDataCallback, &data);
}
  Ref<SceneGraph::Node> CoronaLoader::loadMaterialLibrary(const FileName& fileName) 
  {
    Ref<XML> xml = parseXML(path+fileName,"/.-",false);
    if (xml->name != "mtlLib") 
      THROW_RUNTIME_ERROR(xml->loc.str()+": invalid material library");
    
    for (auto child : xml->children)
    {
      if (child->name == "materialDefinition") {
        loadMaterialDefinition(child);
      }
      else if (child->name == "mapDefinition")
        loadMapDefinition(child);
    }

    return nullptr;
  }
Beispiel #18
0
const char* ieee1888_parseXML_value(const char* strbuf, int len, ieee1888_value* value){
  
  const char* p;
  const char* q;
  p=strbuf;

  XMLNode node;
  while((q=parseXML(p,len,&node))!=NULL){
    switch(node.type){
    case XML_ELEMENT_BEGIN:
      if(strcmp(node.name,"value")!=0){
         // error
        fprintf(stderr,"Fatal error: unknown object \"%s\" appeared in \"value\"\n", node.name);
	return NULL;
      }
      break;

    case XML_ATTRIBUTE:
      if(strcmp(node.name,"time")==0){
        value->time=ieee1888_mk_time_from_string(node.value);

      }else{
        // error
        fprintf(stderr,"Fatal error: unknown attribute \"%s\" in value object \n",node.name);
	return NULL;
      }
      break;

    case XML_TEXT:
      value->content=ieee1888_mk_string(node.value);
      break;

    case XML_ELEMENT_END:
      return q;

    default: 
      // error
      fprintf(stderr,"Fatal error: unknown error, maybe the XML is broken.");
      q++;
    }
    len-=(q-p);
    p=q;
  }

  return NULL;
}
Beispiel #19
0
QVector<Entry*> *RSS::fetch(){
	QXmlStreamReader *xml = new QXmlStreamReader();
	QString wget = "wget \"" + url + "\" -q -O rss.xml";
	system(wget.toStdString().c_str());

	QFile file("rss.xml");
	if (!file.open(QIODevice::ReadOnly)){
		std::cerr << "Error opening file " << file.fileName().toStdString() << std::endl;
		return new QVector<Entry*>();
	}
	QTextStream stream(&file);
	QString data = stream.readAll();
	file.close();

	xml->addData(data);
	return parseXML(xml);
}
Beispiel #20
0
Datei: xml.c Projekt: BIllli/mget
void mget_xml_parse_buffer(
	const char *buf,
	mget_xml_callback_t *callback,
	void *user_ctx,
	int hints)
{
	XML_CONTEXT context;

	context.token = NULL;
	context.token_size = 0;
	context.token_len = 0;
	context.buf = buf;
	context.p = buf;
	context.user_ctx = user_ctx;
	context.callback = callback;
	context.hints = hints;

	parseXML("/", &context);
}
Beispiel #21
0
/*! parse XML tag */
Ref<XML> parseXML(Ref<Stream<Token> >& cin)
{
    Ref<XML> xml = new XML;
    xml->loc = cin->peek().Location();

    /* parse tag opening */
    if (cin->get() != Token::Sym("<")) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": tag expected");

    xml->name = cin->get().Identifier();
    parseComments(cin);
    while (cin->peek() != Token::Sym("/>") && cin->peek() != Token::Sym(">")) {
        parseParm(cin,xml->parms);
        parseComments(cin);
    }
    if (cin->peek() == Token::Sym("/>")) {
        cin->drop();
        return xml;
    }
    cin->drop();

    /* parse body token list */
    parseComments(cin);
    while (cin->peek() != Token::Sym("<") && cin->peek() != Token::Sym("</")) {
        xml->body.push_back(cin->get());
        parseComments(cin);
    }

    /* the body also contains children */
    if (cin->peek() == Token::Sym("<")) {
        while (cin->peek() != Token::Sym("</")) {
            xml->children.push_back(parseXML(cin));
            parseComments(cin);
        }
    }

    /* parse tag closing */
    if (cin->get() != Token::Sym("</")    ) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": symbol \"</\" expected");
    if (cin->get() != Token::Id(xml->name)) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": closing "+xml->name+" expected");
    if (cin->get() != Token::Sym(">")     ) THROW_RUNTIME_ERROR(cin->unget().Location().str()+": symbol \">\" expected");

    return xml;
}
  CoronaLoader::CoronaLoader(const FileName& fileName, const AffineSpace3fa& space)
  {
    path = fileName.path();
    Ref<XML> xml = parseXML(fileName,"/.-",false);
    if (xml->name == "scene") 
    {
      Ref<SceneGraph::GroupNode> group = new SceneGraph::GroupNode;
      for (size_t i=0; i<xml->children.size(); i++) { 
        group->add(loadNode(xml->children[i]));
      }
      root = group.cast<SceneGraph::Node>();
    }
    else 
      THROW_RUNTIME_ERROR(xml->loc.str()+": invalid scene tag");

    if (space == AffineSpace3fa(one)) 
      return;
    
    root = new SceneGraph::TransformNode(space,root);
  }
Beispiel #23
0
void ScriptsModel::downloadFinished() {
    QNetworkReply* reply = static_cast<QNetworkReply*>(sender());
    bool finished = true;

    if (reply->error() == QNetworkReply::NoError) {
        QByteArray data = reply->readAll();

        if (!data.isEmpty()) {
            finished = parseXML(data);
        } else {
            qDebug() << "Error: Received no data when loading remote scripts";
        }
    }

    reply->deleteLater();
    sender()->deleteLater();

    if (finished) {
        _loadingScripts = false;
    }
}
Beispiel #24
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{

    ui->setupUi(this);
    ui->stackedWidget->setCurrentIndex(2);
    ui->stackedWidget->setCurrentIndex(0);

    tool = new ToolsBar();
    ui->graphicsView->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    ui->graphicsView_2->setAlignment(Qt::AlignTop | Qt::AlignLeft);

    QGraphicsScene *leftScene = new QGraphicsScene();
    scene = new paintScene(ui->graphicsView_2->rect(), ui->graphicsView_2);
    scene->setBrush(tool);
    ui->graphicsView->setScene(leftScene);
    ui->graphicsView_2->setScene(scene);

    QDomDocument domDoc;
    QFile        file(qApp->applicationDirPath()+"/levels.xml");
    levels = new  QMap<QString, QMap<QString, QList<QString>* >* >();
    if(file.open(QIODevice::ReadOnly)) {
        if(domDoc.setContent(&file)) {
            QDomElement domElement= domDoc.documentElement();
            parseXML(domElement);
        }
        file.close();
    }

    connect(ui->btnColor, SIGNAL(clicked()),
            this, SLOT(selectColor()));
    connect(ui->cmbWidth, SIGNAL(currentIndexChanged(int)),
            tool, SLOT(changeWidth(int)));
    connect(ui->btnSetBrush, SIGNAL(clicked()),
            tool, SLOT(setBrush()));
    connect(ui->btnSetRuber, SIGNAL(clicked()),
            tool, SLOT(setRuber()));

}
Beispiel #25
0
void Widget::parseXML(const QDomNode node)
{
    QString theme, complex;
    QDomNode domNode = node.firstChild();
    while(!domNode.isNull()) {
        if(domNode.isElement()) {
           QDomElement domElement = domNode.toElement();
           if(!domElement.isNull()) {
               if( domElement.tagName() == "theme")
               {
                   theme = domElement.attribute("title");
                   ui->listWidget->addItem(theme);
               }
               if( domElement.tagName() == "complexity")
               {
                   complex = domElement.attribute("id");

                   QMap<QString, QList<QString>* > *map;
                   if(levels->value(domElement.parentNode().toElement().attribute("title")) == NULL)
                   {
                       map = new QMap<QString, QList<QString>* >() ;
                   }
                   else
                   {
                       map = levels->value(domElement.parentNode().toElement().attribute("title"));
                   }
                   map->insert(complex, new QList<QString>() );
                   levels->insert(domElement.parentNode().toElement().attribute("title"), map);
               }
               if(domElement.tagName() == "level")
               {
                   levels->value(domElement.parentNode().toElement().parentNode().toElement().attribute("title"))->value(domElement.parentNode().toElement().attribute("id"))->push_back(domElement.attribute("file"));
               }
           }
        }
        parseXML(domNode);
        domNode = domNode.nextSibling();
     }
}
Beispiel #26
0
const char* ieee1888_parseXML_OK(const char* strbuf, int len, ieee1888_OK* ok){
  
  const char* p;
  const char* q;
  p=strbuf;

  XMLNode node;
  while((q=parseXML(p, len, &node))!=NULL){
    switch(node.type){
    case XML_ELEMENT_BEGIN:
      if(strcmp(node.name,"OK")!=0){
        // error
        fprintf(stderr,"Fatal error: unknown object \"%s\" appeared in \"OK\"\n", node.name);
	return NULL;
      }
      break;

    case XML_ATTRIBUTE:
      // error
      fprintf(stderr,"Fatal error: unknown attribute \"%s\" in OK object \n",node.name);
      return NULL;
      break;

    case XML_ELEMENT_END:
      return q;
    
    default: 
      // error
      fprintf(stderr,"Fatal error: unknown error, maybe the XML is broken.");
      q++;
    }
    len-=(q-p);
    p=q;
  }

  // unreachable (if XML is well-formed)
  return NULL;
}
Beispiel #27
0
bool Web::parseXMLFile(string xmlFileName)
{
	ifstream xmlFile;
	char in;
	string xmlString;
	int fileLen;
	
	xmlFile.open(xmlFileName.c_str(), ifstream::in);

	while(xmlFile.get(in))
	{
		xmlString += in;
	}

	if(!xmlFile.eof())
	{
		fprintf(outFile, "reading stopped before end of file\n");
		return false;
	}

	xmlFile.close();
	
	return parseXML(string(xmlString));
}
Beispiel #28
0
SceneXMLParser::SceneXMLParser(string xmlFile) : IXMLParser(xmlFile){
	load();
	parseXML();
}
Beispiel #29
0
JNIEXPORT jobjectArray JNICALL Java_com_ireeed_XPathApplier_xmlEvalXPaths(JNIEnv *env, jobject jobj, jstring page, jobjectArray xpaths){
    jboolean isCopy;
    const char *data = env->GetStringUTFChars(page,&isCopy);

    xmlDocPtr doc = parseXML(data,strlen(data));
    //inform jvm to release the allocated data, no matter copied is true or false
    env->ReleaseStringUTFChars(page,data);

    xmlXPathObjectPtr result;
    xmlNodeSetPtr nodeset;
    std::vector<std::vector<std::string> > ret;

    jsize xpathNum = env->GetArrayLength(xpaths);


    if(doc){
	for(int index = 0; index < xpathNum; index++){

	    jstring string = (jstring)env->GetObjectArrayElement(xpaths,index);

	    const char* xpath = env->GetStringUTFChars(string, &isCopy);

	    std::vector<std::string> output;
	    if(xpath){
		result = getNodeSet(doc,xpath);
		if(result){
		    nodeset = result->nodesetval;
		    for(int i = 0; i < nodeset->nodeNr; i++){
			xmlNodePtr nodePtr = nodeset->nodeTab[i];
			std::string record;
			getTextInNode(nodePtr,record);
		
			output.push_back(record);
		    }
		    xmlXPathFreeObject(result);
		}
		//inform jvm to release the allocated data, no matter copied is true or false
		env->ReleaseStringUTFChars(string,xpath);
	    }
	    ret.push_back(output);

	}
    
	xmlFreeDoc(doc);
    }


    /*
      construct std::vector<std::vector<std::string> > back to java type(array of array)
      construct the final result in order according to the order of given xpaths
    */
    jclass stringArrayCls = env->FindClass("java/lang/Object");
    jobjectArray elemObj = env->NewObjectArray(0,env->FindClass("java/lang/String"),env->NewStringUTF(""));

    jobjectArray retVal = env->NewObjectArray(ret.size(),stringArrayCls,elemObj);
    for(int i = 0; i < ret.size(); i++){
	std::vector<std::string> &elem = ret[i];
	elemObj = env->NewObjectArray(elem.size(),env->FindClass("java/lang/String"),env->NewStringUTF(""));
	for(int j = 0; j < elem.size(); j++){
	    std::string &elemField = elem[j];
	    //create java string
	    env->SetObjectArrayElement(elemObj,j,env->NewStringUTF(elemField.c_str()));
	}
	env->SetObjectArrayElement(retVal,i,elemObj);
    }

    return retVal;  
}
//Open XML file clicked
void TaskList_Main::openClickAction(QString inName, bool clearLists){
    if(inName.trimmed().isEmpty())
        inName = QFileDialog::getOpenFileName(this, tr("Open List File"),
                                                  QDir::currentPath(),
                                                  tr("LIST Files (*.xml)"));
    if(inName.isEmpty())
        return;

    //Open file stream
    QFile in(inName);
    if(!in.open(QFile::ReadOnly| QFile::Text)){
        QMessageBox::warning(this, tr("Open List"),
                             tr("Cannot open file %1:\n%2")
                             .arg(inName).arg(in.errorString()));
        return;
    }

    //If not a template, clear listing
    if(clearLists){
        while(listPane->mainList->count() != 0)
            delListClick();
    }

    //Create the XML document to read in
    QDomDocument doc;
    QString errorMsg;
    int errorLine, errorColumn;
    if(doc.setContent(&in, &errorMsg, &errorLine, &errorColumn)){
        if(parseXML(doc) < 0){
            while(listPane->mainList->count() != 0)
                delListClick();
        }
    }
    else{
        errorMsg.append(" line ");
        errorMsg.append(QString::number(errorLine));
        errorMsg.append(" col ");
        errorMsg.append(QString::number(errorColumn));

        QMessageBox msgBox;
        msgBox.setText(errorMsg.toAscii().data());
        msgBox.setWindowTitle("Erorr parsing XML");
        msgBox.exec();
    }

    //Handle whether it came from template rsc. or from
    //actual user file
    qDebug(inName.toAscii().data());
    if(!inName.contains(":/tmp/xml/"))
        myFileName = inName;
    //If task_week item, sync up next dates for tasks
    else if(inName.contains(":/tmp/xml/task_groceries.xml")){
        QDate currDate = QDate::currentDate();
        qDebug(currDate.toString().toAscii().data());

        QListWidgetItem *listPtr = listPane->mainList->currentItem();
        my_listwidget *taskPtr = notePane->listMap[listPtr];

        for(int task = 0; task < taskPtr->count(); ++task){
            taskPtr->item(task)->setData(34, QVariant(currDate));
            optionPane->itemSelectDataIn(*taskPtr->item(task));
        }

    }
    else if(inName.contains(":/tmp/xml/task_week.xml")){
        QDate currDate = QDate::currentDate();
        qDebug(currDate.toString().toAscii().data());
        while(currDate.dayOfWeek() != 1){
            qDebug("add day");
            currDate = currDate.addDays(1);
            qDebug(currDate.toString().toAscii().data());
        }
        for(int day = listPane->mainList->count()-7; day < listPane->mainList->count(); ++day){
            QListWidgetItem *listPtr = listPane->mainList->item(day);
            my_listwidget *dayPtr = notePane->listMap[listPtr];

            QString newTitle = currDate.toString();
            listPtr->setText(newTitle);

            for(int task = 0; task < dayPtr->count(); ++task){
                dayPtr->item(task)->setData(34, QVariant(currDate));
                optionPane->itemSelectDataIn(*dayPtr->item(task));
            }
            currDate = currDate.addDays(1);
        }
    }
}