/* <AuthorList CompleteYN="Y"> * <Author> * <LastName>Barondeau</LastName> * <ForeName>David P</ForeName> * ( or <FirstName>David P</FirstName> ) * <Initials>DP</Initials> * </Author> * <Author> * <CollectiveName>Organization</CollectiveName> * </Author> * </AuthorList> */ static int medin_author( xml *node, newstr *name ) { char *p; if ( xml_tagexact( node, "LastName" ) ) { if ( name->len ) { newstr_prepend( name, "|" ); newstr_prepend( name, xml_data( node ) ); } else newstr_strcat( name, xml_data( node ) ); } else if ( xml_tagexact( node, "ForeName" ) || xml_tagexact( node, "FirstName" ) ) { p = xml_data( node ); while ( p && *p ) { if ( name->len ) newstr_addchar( name, '|' ); while ( *p && *p==' ' ) p++; while ( *p && *p!=' ' ) newstr_addchar( name, *p++ ); } } else if ( xml_tagexact( node, "Initials" ) && !strchr( name->data, '|' )) { p = xml_data( node ); while ( p && *p ) { if ( name->len ) newstr_addchar( name, '|' ); if ( !is_ws(*p) ) newstr_addchar( name, *p++ ); } } if ( node->next ) medin_author( node->next, name ); return BIBL_OK; }
static int medin_doconvert( xml *node, fields *info, xml_convert *c, int nc, int *found ) { int i, fstatus; char *d; *found = 0; if ( !xml_hasdata( node ) ) return BIBL_OK; d = xml_data( node ); for ( i=0; i<nc && *found==0; ++i ) { if ( c[i].a==NULL ) { if ( xml_tagexact( node, c[i].in ) ) { *found = 1; fstatus = fields_add( info, c[i].out, d, c[i].level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } } else { if ( xml_tag_attrib( node, c[i].in, c[i].a, c[i].aval)){ *found = 1; fstatus = fields_add( info, c[i].out, d, c[i].level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } } } return BIBL_OK; }
static int medin_corpauthor( xml *node, newstr *name ) { if ( xml_tagexact( node, "CollectiveName" ) ) { newstr_strcpy( name, xml_data( node ) ); } else if ( node->next ) medin_corpauthor( node->next, name ); return BIBL_OK; }
/* <Abstract> * <AbstractText>ljwejrelr</AbstractText> * </Abstract> */ static int medin_abstract( xml *node, fields *info ) { int fstatus; if ( xml_tagwithdata( node, "AbstractText" ) ) { fstatus = fields_add( info, "ABSTRACT", xml_data( node ), 0 ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } else if ( node->next ) return medin_abstract( node->next, info ); return BIBL_OK; }
/* <ArticleTitle>Mechanism and.....</ArticleTitle> */ static int medin_articletitle( xml *node, fields *info ) { int fstatus, status = BIBL_OK; if ( xml_hasdata( node ) ) { fstatus = fields_add( info, "TITLE", xml_data( node ), 0 ); if ( fstatus!=FIELDS_OK ) status = BIBL_ERR_MEMERR; } return status; }
/* <MeshHeadingList> <MeshHeading> <DescriptorName MajorTopicYN="N">Biophysics</DescriptorName> </MeshHeading> <MeshHeading> <DescriptorName MajorTopicYN="N">Crystallography, X-Ray</DescriptorName> </MeshHeading> </MeshHeadingList> */ static int medin_meshheading( xml *node, fields *info ) { int fstatus, status = BIBL_OK; if ( xml_tagwithdata( node, "DescriptorName" ) ) { fstatus = fields_add( info, "KEYWORD", xml_data( node ), 0 ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } if ( node->next ) status = medin_meshheading( node->next, info ); return status; }
static int wordin_pages( xml *node, fields *info ) { int i, status, ret = BIBL_OK; newstr sp, ep; char *p; newstrs_init( &sp, &ep, NULL ); p = xml_data( node ); while ( *p && *p!='-' ) newstr_addchar( &sp, *p++ ); if ( newstr_memerr( &sp ) ) { ret = BIBL_ERR_MEMERR; goto out; } if ( *p=='-' ) p++; while ( *p ) newstr_addchar( &ep, *p++ ); if ( newstr_memerr( &ep ) ) { ret = BIBL_ERR_MEMERR; goto out; } if ( sp.len ) { status = fields_add( info, "PAGES:START", sp.data, 1 ); if ( status!=FIELDS_OK ) { ret = BIBL_ERR_MEMERR; goto out; } } if ( ep.len ) { if ( sp.len > ep.len ) { for ( i=sp.len-ep.len; i<sp.len; ++i ) sp.data[i] = ep.data[i-sp.len+ep.len]; status = fields_add( info, "PAGES:STOP", sp.data, 1 ); } else status = fields_add( info, "PAGES:STOP", ep.data, 1 ); if ( status!=FIELDS_OK ) { ret = BIBL_ERR_MEMERR; goto out; } } out: newstrs_free( &sp, &ep, NULL ); return ret; }
static int medin_journal2( xml *node, fields *info ) { int fstatus, status = BIBL_OK; if ( xml_tagwithdata( node, "MedlineTA" ) && fields_find( info, "TITLE", 1 )==-1 ) { fstatus = fields_add( info, "TITLE", xml_data( node ), 1 ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } if ( node->down ) { status = medin_journal2( node->down, info ); if ( status!=BIBL_OK ) return status; } if ( node->next ) status = medin_journal2( node->next, info ); return status; }
/* <Langauge>eng</Language> */ static int medin_language( xml *node, fields *info, int level ) { char *code, *language; int fstatus; code = xml_data( node ); if ( !code ) return BIBL_OK; language = iso639_2_from_code( code ); if ( language ) fstatus = fields_add( info, "LANGUAGE", language, level ); else fstatus = fields_add( info, "LANGUAGE", code, level ); if ( fstatus==FIELDS_OK ) return BIBL_OK; else return BIBL_ERR_MEMERR; }
/* <Journal> * <ISSN>0027-8424</ISSN> * <JournalIssue PrintYN="Y"> * <Volume>100</Volume> * <Issue>21</Issue> * <PubDate> * <Year>2003</Year> * <Month>Oct</Month> * <Day>14</Day> * </PubDate> * </Journal Issue> * </Journal> * * or.... * * <Journal> * <ISSN IssnType="Print">0735-0414</ISSN> * <JournalIssue CitedMedium="Print"> * <Volume>38</Volume> * <Issue>1</Issue> * <PubDate> * <MedlineDate>2003 Jan-Feb</MedlineDate> * </PubDate> * </JournalIssue> * <Title>Alcohol and alcoholism (Oxford, Oxfordshire) </Title> * <ISOAbbreviation>Alcohol Alcohol.</ISOAbbreviation> * </Journal> */ static int medin_journal1( xml *node, fields *info ) { xml_convert c[] = { { "Title", NULL, NULL, "TITLE", 1 }, { "ISOAbbreviation", NULL, NULL, "SHORTTITLE", 1 }, { "ISSN", NULL, NULL, "ISSN", 1 }, { "Volume", NULL, NULL, "VOLUME", 1 }, { "Issue", NULL, NULL, "ISSUE", 1 }, { "Year", NULL, NULL, "PARTYEAR", 1 }, { "Month", NULL, NULL, "PARTMONTH", 1 }, { "Day", NULL, NULL, "PARTDAY", 1 }, }; int nc = sizeof( c ) / sizeof( c[0] ), status, found; if ( xml_hasdata( node ) ) { status = medin_doconvert( node, info, c, nc, &found ); if ( status!=BIBL_OK ) return status; if ( !found ) { if ( xml_tagexact( node, "MedlineDate" ) ) { status = medin_medlinedate( info, xml_data( node ), 1 ); if ( status!=BIBL_OK ) return status; } if ( xml_tagexact( node, "Language" ) ) { status = medin_language( node, info, 1 ); if ( status!=BIBL_OK ) return status; } } } if ( node->down ) { status = medin_journal1( node->down, info ); if ( status!=BIBL_OK ) return status; } if ( node->next ) { status = medin_journal1( node->next, info ); if ( status!=BIBL_OK ) return status; } return BIBL_OK; }
/* <Pagination> * <MedlinePgn>12111-6</MedlinePgn> * </Pagination> */ static int medin_pagination( xml *node, fields *info ) { int i, fstatus, status; newstr sp, ep; char *p, *pp; if ( xml_tagexact( node, "MedlinePgn" ) && node->value ) { newstrs_init( &sp, &ep, NULL ); p = newstr_cpytodelim( &sp, xml_data( node ), "-", 1 ); if ( newstr_memerr( &sp ) ) return BIBL_ERR_MEMERR; if ( sp.len ) { fstatus = fields_add( info, "PAGESTART", sp.data, 1 ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } p = newstr_cpytodelim( &ep, p, "", 0 ); if ( newstr_memerr( &ep ) ) return BIBL_ERR_MEMERR; if ( ep.len ) { if ( sp.len > ep.len ) { for ( i=sp.len-ep.len; i<sp.len; ++i ) sp.data[i] = ep.data[i-sp.len+ep.len]; pp = sp.data; } else pp = ep.data; fstatus = fields_add( info, "PAGEEND", pp, 1 ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } newstrs_free( &sp, &ep, NULL ); } if ( node->down ) { status = medin_pagination( node->down, info ); if ( status!=BIBL_OK ) return status; } if ( node->next ) { status = medin_pagination( node->next, info ); if ( status!=BIBL_OK ) return status; } return BIBL_OK; }
static int medin_article( xml *node, fields *info ) { int fstatus, status = BIBL_OK; if ( xml_tagexact( node, "Journal" ) ) status = medin_journal1( node, info ); else if ( xml_tagexact( node, "ArticleTitle" ) ) status = medin_articletitle( node, info ); else if ( xml_tagexact( node, "Pagination" ) && node->down ) status = medin_pagination( node->down, info ); else if ( xml_tagexact( node, "Abstract" ) && node->down ) status = medin_abstract( node->down, info ); else if ( xml_tagexact( node, "AuthorList" ) ) status = medin_authorlist( node, info ); else if ( xml_tagexact( node, "Language" ) ) status = medin_language( node, info, 0 ); else if ( xml_tagexact( node, "Affiliation" ) ) { fstatus = fields_add( info, "ADDRESS", xml_data( node ), 0 ); if ( fstatus!=FIELDS_OK ) status = BIBL_ERR_MEMERR; } if ( status!=BIBL_OK ) return status; if ( node->next ) status = medin_article( node->next, info ); return BIBL_OK; }
static int wordin_reference( xml *node, fields *info ) { int status, ret = BIBL_OK; if ( xml_hasdata( node ) ) { if ( xml_tagexact( node, "b:Tag" ) ) { status = fields_add( info, "REFNUM", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:SourceType" ) ) { } else if ( xml_tagexact( node, "b:City" ) ) { status = fields_add( info, "ADDRESS", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Publisher" ) ) { status = fields_add( info, "PUBLISHER", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Title" ) ) { status = fields_add( info, "TITLE", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:JournalName" ) ) { status = fields_add( info, "TITLE", xml_data( node ), 1 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Volume" ) ) { status = fields_add( info, "VOLUME", xml_data( node ), 1 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Comments" ) ) { status = fields_add( info, "NOTES", xml_data( node ), 0 ); if ( status!=FIELDS_OK ) ret = BIBL_ERR_MEMERR; } else if ( xml_tagexact( node, "b:Pages" ) ) { ret = wordin_pages( node, info ); } else if ( xml_tagexact( node, "b:Author" ) && node->down ) { ret = wordin_people( node->down, info, "AUTHOR" ); } else if ( xml_tagexact( node, "b:Editor" ) && node->down ) { ret = wordin_people( node->down, info, "EDITOR" ); } } if ( ret==BIBL_OK && node->next ) wordin_reference( node->next, info ); return ret; }
QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node, const QString &path) { // object may be null QString xml_data(QLatin1String(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE)); xml_data += QLatin1String("<node>\n"); if (node.obj) { Q_ASSERT_X(QThread::currentThread() == node.obj->thread(), "QDBusConnection: internal threading error", "function called for an object that is in another thread!!"); if (node.flags & (QDBusConnection::ExportScriptableContents | QDBusConnection::ExportNonScriptableContents)) { // create XML for the object itself const QMetaObject *mo = node.obj->metaObject(); for ( ; mo != &QObject::staticMetaObject; mo = mo->superClass()) xml_data += qDBusGenerateMetaObjectXml(QString(), mo, mo->superClass(), node.flags); } // does this object have adaptors? QDBusAdaptorConnector *connector; if (node.flags & QDBusConnection::ExportAdaptors && (connector = qDBusFindAdaptorConnector(node.obj))) { // trasverse every adaptor in this object QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(); QDBusAdaptorConnector::AdaptorMap::ConstIterator end = connector->adaptors.constEnd(); for ( ; it != end; ++it) { // add the interface: QString ifaceXml = QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(it->adaptor); if (ifaceXml.isEmpty()) { // add the interface's contents: ifaceXml += qDBusGenerateMetaObjectXml(QString::fromLatin1(it->interface), it->adaptor->metaObject(), &QDBusAbstractAdaptor::staticMetaObject, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportNonScriptableContents); QDBusAbstractAdaptorPrivate::saveIntrospectionXml(it->adaptor, ifaceXml); } xml_data += ifaceXml; } } // is it a virtual node that handles introspection itself? if (node.flags & QDBusConnectionPrivate::VirtualObject) { xml_data += node.treeNode->introspect(path); } xml_data += QLatin1String( propertiesInterfaceXml ); } xml_data += QLatin1String( introspectableInterfaceXml ); xml_data += QLatin1String( peerInterfaceXml ); if (node.flags & QDBusConnection::ExportChildObjects) { xml_data += generateSubObjectXml(node.obj); } else { // generate from the object tree QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = node.children.constBegin(); QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end = node.children.constEnd(); for ( ; it != end; ++it) if (it->obj || !it->children.isEmpty()) xml_data += QString::fromLatin1(" <node name=\"%1\"/>\n") .arg(it->name); } xml_data += QLatin1String("</node>\n"); return xml_data; }
void UserSettings::save() { //initInputCodeMap(); TiXmlDocument doc; { TiXmlElement xml_version("Version"); { xml_version.SetAttribute("settingsVersion", VERSION_USERSETTINGS); } doc.InsertEndChild(xml_version); TiXmlElement xml_system("System"); { TiXmlElement xml_debugLog("DebugLog"); { xml_debugLog.SetAttribute("on", system.debugLogOn); } xml_system.InsertEndChild(xml_debugLog); TiXmlElement xml_locale("Locale"); { xml_locale.SetAttribute("name", system.locale); } xml_system.InsertEndChild(xml_locale); } doc.InsertEndChild(xml_system); TiXmlElement xml_audio("Audio"); { TiXmlElement xml_microphone("Mic"); { xml_microphone.SetAttribute("on", audio.micOn); xml_microphone.SetAttribute("octave", audio.octave); } xml_audio.InsertEndChild(xml_microphone); TiXmlElement xml_volume("Volume"); { xml_volume.SetDoubleAttribute("sfx", double(audio.sfxvol)); xml_volume.SetDoubleAttribute("vox", double(audio.voxvol)); xml_volume.SetDoubleAttribute("mus", double(audio.musvol)); xml_volume.SetAttribute("subs", audio.subtitles); } xml_audio.InsertEndChild(xml_volume); TiXmlElement xml_device("Device"); { xml_device.SetAttribute("name", audio.deviceName); } xml_audio.InsertEndChild(xml_device); TiXmlElement xml_prebuf("Prebuffer"); { xml_prebuf.SetAttribute("on", audio.prebuffer); } xml_audio.InsertEndChild(xml_prebuf); } doc.InsertEndChild(xml_audio); TiXmlElement xml_video("Video"); { TiXmlElement xml_shader("Shader"); { xml_shader.SetAttribute("num", video.shader); } xml_video.InsertEndChild(xml_shader); TiXmlElement xml_blur("Blur"); { xml_blur.SetAttribute("on", video.blur); } xml_video.InsertEndChild(xml_blur); TiXmlElement xml_noteEffects("NoteEffects"); { xml_noteEffects.SetAttribute("on", video.noteEffects); } xml_video.InsertEndChild(xml_noteEffects); TiXmlElement xml_fpsSmoothing("FpsSmoothing"); { xml_fpsSmoothing.SetAttribute("v", video.fpsSmoothing); } xml_video.InsertEndChild(xml_fpsSmoothing); TiXmlElement xml_parallax("Parallax"); std::ostringstream os; os << video.parallaxOn0 << " " << video.parallaxOn1 << " " << video.parallaxOn2; xml_parallax.SetAttribute("on", os.str()); xml_video.InsertEndChild(xml_parallax); TiXmlElement xml_numParticles("NumParticles"); xml_numParticles.SetAttribute("v", video.numParticles); xml_video.InsertEndChild(xml_numParticles); TiXmlElement xml_screenMode("ScreenMode"); { xml_screenMode.SetAttribute("resx", video.resx); xml_screenMode.SetAttribute("resy", video.resy); xml_screenMode.SetAttribute("bits", video.bits); xml_screenMode.SetAttribute("fbuffer", video.fbuffer); xml_screenMode.SetAttribute("full", video.full); xml_screenMode.SetAttribute("vsync", video.vsync); xml_screenMode.SetAttribute("darkfbuffer", video.darkfbuffer); xml_screenMode.SetAttribute("darkbuffersize", video.darkbuffersize); xml_screenMode.SetAttribute("displaylists", video.displaylists); } xml_video.InsertEndChild(xml_screenMode); TiXmlElement xml_saveSlotScreens("SaveSlotScreens"); { xml_saveSlotScreens.SetAttribute("on", video.saveSlotScreens); } xml_video.InsertEndChild(xml_saveSlotScreens); TiXmlElement xml_worldMap("WorldMap"); { xml_worldMap.SetAttribute("revealMethod", video.worldMapRevealMethod); } xml_video.InsertEndChild(xml_worldMap); } doc.InsertEndChild(xml_video); TiXmlElement xml_control("Control"); { TiXmlElement xml_toolTipsOn("ToolTipsOn"); { xml_toolTipsOn.SetAttribute("on", control.toolTipsOn); } xml_control.InsertEndChild(xml_toolTipsOn); TiXmlElement xml_joystickEnabled("JoystickEnabled"); { xml_joystickEnabled.SetAttribute("on", control.joystickEnabled); } xml_control.InsertEndChild(xml_joystickEnabled); TiXmlElement xml_autoAim("AutoAim"); { xml_autoAim.SetAttribute("on", control.autoAim); } xml_control.InsertEndChild(xml_autoAim); TiXmlElement xml_targeting("Targeting"); { xml_targeting.SetAttribute("on", control.targeting); } xml_control.InsertEndChild(xml_targeting); TiXmlElement xml_joyCursorSpeed("JoyCursorSpeed"); { xml_joyCursorSpeed.SetDoubleAttribute("v", double(control.joyCursorSpeed)); } xml_control.InsertEndChild(xml_joyCursorSpeed); TiXmlElement xml_joyAxes("JoyAxes"); { xml_joyAxes.SetAttribute("s1ax", control.s1ax); xml_joyAxes.SetAttribute("s1ay", control.s1ay); xml_joyAxes.SetAttribute("s2ax", control.s2ax); xml_joyAxes.SetAttribute("s2ay", control.s2ay); xml_joyAxes.SetDoubleAttribute("s1dead", double(control.s1dead)); xml_joyAxes.SetDoubleAttribute("s2dead", double(control.s2dead)); } xml_control.InsertEndChild(xml_joyAxes); TiXmlElement xml_actionSet("ActionSet"); { for (int i = 0; i < control.actionSet.inputSet.size(); i++) { TiXmlElement xml_action("Action"); ActionInput *actionInput = &control.actionSet.inputSet[i]; xml_action.SetAttribute("name", actionInput->name); xml_action.SetAttribute("input", actionInput->toString()); xml_actionSet.InsertEndChild(xml_action); } } xml_control.InsertEndChild(xml_actionSet); } doc.InsertEndChild(xml_control); TiXmlElement xml_demo("Demo"); { TiXmlElement xml_warpKeys("WarpKeys"); { xml_warpKeys.SetAttribute("on", demo.warpKeys); } xml_demo.InsertEndChild(xml_warpKeys); TiXmlElement xml_intro("Intro2"); { xml_intro.SetAttribute("on", demo.intro); } xml_demo.InsertEndChild(xml_intro); TiXmlElement xml_shortLogos("ShortLogos"); { xml_shortLogos.SetAttribute("on", demo.shortLogos); } xml_demo.InsertEndChild(xml_shortLogos); } doc.InsertEndChild(xml_demo); TiXmlElement xml_data("Data"); { xml_data.SetAttribute("savePage", data.savePage); xml_data.SetAttribute("saveSlot", data.saveSlot); std::ostringstream ss; for (std::set<std::string>::iterator it = dsq->activePatches.begin(); it != dsq->activePatches.end(); ++it) ss << *it << " "; xml_data.SetAttribute("activePatches", ss.str()); } doc.InsertEndChild(xml_data); TiXmlElement xml_net("Network"); { xml_net.SetAttribute("masterServer", network.masterServer); } doc.InsertEndChild(xml_net); } #if defined(BBGE_BUILD_UNIX) doc.SaveFile(dsq->getPreferencesFolder() + "/" + userSettingsFilename); #elif defined(BBGE_BUILD_WINDOWS) doc.SaveFile(userSettingsFilename); #endif //clearInputCodeMap(); }