static void parsePoem (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { cur = cur->children; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"title")) { parseTitle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"epigraph")) { parseEpigraph(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"p")) { parseP(doc, cur, 1, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"empty-line")) { bufferAppend("\n", 1, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"stanza")) { bufferAppend("\n", 1, fb); parseStanza(doc, cur, fb); } cur = cur->next; } bufferAppend("\n", 1, fb); return; }
void TrackInfoObject::parseFilename() { // If the file name has the following form: "Artist - Title.type", extract // Artist, Title and type fields parseArtist(); parseTitle(); // Add no comment m_sComment.clear(); // Find the type QString filename = m_fileInfo.fileName(); m_sType = filename.section(".",-1).toLower().trimmed(); setDirty(true); }
static void parseSection (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { FB2Mark *mark; mark = getLink(cur, fb); cur = cur->children; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"title")) { parseTitle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"section")) { parseSection(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"poem")) { parsePoem(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"cite")) { parseCite(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"epigraph")) { parseEpigraph(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"p")) { parseP(doc, cur, 1, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"subtitle")) { int start = fb->utf8_current_index; parseP(doc, cur, 0, fb); addMark(start, fb->utf8_current_index, BOOKMARK_TYPE, NULL, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"empty-line")) { bufferAppend("\n", 1, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) { parseImage(doc, cur, fb); } cur = cur->next; } if (mark) mark->link_end = fb->text_current_index; return; }
static void parseBody (xmlDocPtr doc, xmlNodePtr cur, FB2Content *fb) { xmlChar *prop; prop = xmlGetProp(cur, (const xmlChar *)"name"); if (prop) { int start = fb->utf8_current_index; bufferAppend("\n\n", 2, fb); bufferAppend(prop, xmlStrlen(prop), fb); bufferAppend("\n\n", 2, fb); addMark(start, fb->utf8_current_index, BOOKMARK_TYPE, NULL, fb); xmlFree(prop); } cur = cur->children; while (cur != NULL) { if (!xmlStrcmp(cur->name, (const xmlChar *)"section")) { parseSection(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"title")) { parseTitle(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"image")) { parseImage(doc, cur, fb); } else if (!xmlStrcmp(cur->name, (const xmlChar *)"epigraph")) { parseEpigraph(doc, cur, fb); } cur = cur->next; } return; }
sp<Retval> MonPacket::readData(){ sp<Retval> retval; String sContents; String sLine; if( DFW_RET(retval, File::contents(sContents, source_path())) ) return DFW_RETVAL_D(retval); if( sContents.length()==0 ) return DFW_RETVAL_NEW_MSG(DFW_ERROR, 0 ,"Has not contents at %s", source_path()); unsigned len; const char* lp; const char* p = sContents.toChars(); int round = 0; do{ if( p == NULL ) break; if( (lp = strstr(p, "\n")) == NULL ) break; if( (len = lp - p) == 0 ) break; sLine.set(p, len); p += len + 1; if( round == 0 ){ }else if( round == 1 && DFW_RET(retval, parseTitle(sLine)) ){ return DFW_RETVAL_D(retval); }else if( round > 1 && DFW_RET(retval, parseLine(sLine)) ){ return DFW_RETVAL_D(retval); } round++; }while(true); return NULL; }
void AlbumTrack::setSound(FMOD::Sound* sound) { this->sound = sound; this->title = parseTitle(sound); calculateDuration(); }
void TrackInfoObject::parse() { // Log parsing of header information in developer mode. This is useful for // tracking down corrupt files. const QString& canonicalLocation = m_fileInfo.canonicalFilePath(); if (CmdlineArgs::Instance().getDeveloper()) { qDebug() << "TrackInfoObject::parse()" << canonicalLocation; } // Parse the information stored in the sound file. SoundSourceProxy proxy(canonicalLocation, m_pSecurityToken); Mixxx::SoundSource* pProxiedSoundSource = proxy.getProxiedSoundSource(); if (pProxiedSoundSource != NULL && proxy.parseHeader() == OK) { // Dump the metadata extracted from the file into the track. // TODO(XXX): This involves locking the mutex for every setXXX // method. We should figure out an optimization where there are private // setters that don't lock the mutex. // If Artist, Title and Type fields are not blank, modify them. // Otherwise, keep their current values. // TODO(rryan): Should we re-visit this decision? if (!(pProxiedSoundSource->getArtist().isEmpty())) { setArtist(pProxiedSoundSource->getArtist()); } else { parseArtist(); } if (!(pProxiedSoundSource->getTitle().isEmpty())) { setTitle(pProxiedSoundSource->getTitle()); } else { parseTitle(); } if (!(pProxiedSoundSource->getType().isEmpty())) { setType(pProxiedSoundSource->getType()); } setAlbum(pProxiedSoundSource->getAlbum()); setAlbumArtist(pProxiedSoundSource->getAlbumArtist()); setYear(pProxiedSoundSource->getYear()); setGenre(pProxiedSoundSource->getGenre()); setComposer(pProxiedSoundSource->getComposer()); setGrouping(pProxiedSoundSource->getGrouping()); setComment(pProxiedSoundSource->getComment()); setTrackNumber(pProxiedSoundSource->getTrackNumber()); float replayGain = pProxiedSoundSource->getReplayGain(); if (replayGain != 0) { setReplayGain(replayGain); } float bpm = pProxiedSoundSource->getBPM(); if (bpm > 0) { // do not delete beat grid if bpm is not set in file setBpm(bpm); } setDuration(pProxiedSoundSource->getDuration()); setBitrate(pProxiedSoundSource->getBitrate()); setSampleRate(pProxiedSoundSource->getSampleRate()); setChannels(pProxiedSoundSource->getChannels()); QString key = pProxiedSoundSource->getKey(); if (!key.isEmpty()) { setKeyText(key, mixxx::track::io::key::FILE_METADATA); } setHeaderParsed(true); } else { qDebug() << "TrackInfoObject::parse() error at file" << canonicalLocation; setHeaderParsed(false); // Add basic information derived from the filename: parseFilename(); } }
void Importer::parse() { QFile file(inputFile); if (!file.open(QFile::ReadOnly)) return; QTextStream in(&file); in.setCodec("IBM 866"); numberDoc = 1; while (!in.atEnd()) { QString line; in.readLine(); // шапка in.readLine(); // in.readLine(); in.readLine(); // Код формы по КНД 1151078 parsePriznak(in.readLine()); // Признак parseTitle(in.readLine()); // Строка с датой и номером справки in.readLine(); // in.readLine(); // п. 1 parseINNCPP(in.readLine()); // п. 1.1 parseOrgname(in.readLine()); // п. 1.2 if (params[QString::number(numberDoc) + "_Orgname"].isEmpty()) parseOrgname(in.readLine(), 1); in.readLine(); parseOKATOTEL(in.readLine()); // п. 1.3 п. 1.4 in.readLine(); // п. 2 parseINN(in.readLine()); // п. 2.1 in.readLine(); parseFIOTBN(in.readLine()); // п. 2.2 parseStatusDrGr(in.readLine()); // п. 2.3 - п. 2.5 parseCodeDocSeriesNum(in.readLine()); // п. 2.6 - п. 2.7 in.readLine(); // п. 2.8 parseIndexRegCode(in.readLine()); fillAddress(); line = in.readLine(); while (!line.contains(WINtoUnicode("Дом"))) { if (line.contains(WINtoUnicode("Город"))) parseCity(line); else if (line.contains(WINtoUnicode("Улица"))) parseStreet(line); else if (line.contains(WINtoUnicode("Населенный пункт"))) parseLocality(line); line = in.readLine(); } parseHomeFlat(line); in.readLine(); fillPara29(); line = in.readLine(); if (line.left(3) == "2.9") { parseCoutryCode(line); parseAddress(in.readLine()); in.readLine(); line = in.readLine(); } parseTax(line); // п. 3 in.readLine(); in.readLine(); in.readLine(); in.readLine(); in.readLine(); line = in.readLine(); QChar sym(0x2514); int incomeTableRowsCount = 1; while (line[0] != sym) { parseIncomeTable(QString::number(incomeTableRowsCount++), line); line = in.readLine(); } addParametr("incomeTableRowsCount", QString::number(incomeTableRowsCount)); in.readLine(); fillPara4(); line = in.readLine(); // п. 4 while (line.left(3) != " 5.") { QString para = line.left(3); if (para == "") { } else if (para == "4. ") { } else if (para == "4.1") { in.readLine(); line = in.readLine(); parseTaxDeductions(line); } else if (para == "4.2") { parsePara42(line); } else if ((para == "4.3") || (para == "4.4")) { parsePara43_44(line); } else if (para == "4.5") { parsePara45(line); } else if (para == "4.6") { parsePara46(line); } line = in.readLine(); } //in.readLine(); // п. 5 fillPara5(); line = in.readLine(); while (line[0] != sym) { QString para = line.mid(1, 4); if (para == "5.1.") parseAmountIncome(line); // п. 5.1 else if (para == "5.2.") parseTaxableAmountIncome(line); // п. 5.2 else if (para == "5.3.") parseAmountOfTaxCalculated(line); // п. 5.3 else if (para == "5.4.") parseAmountOfTaxWithheld(line); // п. 5.4 else if (para == "5.5.") parsePara55Sum(line); // п. 5.5 else if (para == "5.6.") parsePara56Sum(line); // п. 5.6 else if (para == "5.7.") parsePara57Sum(line); // п. 5.7 else if (para == "5.8.") parsePara58Sum(line); // п. 5.8 else if (para == "5.9.") parsePara59Sum(line); // п. 5.9 else if (para == "5.10") parsePara510Sum(line); // п. 5.10 line = in.readLine(); } in.readLine(); in.readLine(); parseBottom(in.readLine()); QChar pageBreak(0x0C); line = in.readLine(); while (!in.atEnd() && line != pageBreak) line = in.readLine(); numberDoc++; } file.close(); }
block::block(ofTag & cur,ofColor col):ofInterObj(-200,-200,150,TITLE_HEIGHT) { //********* This is the method by which all of the blocks are first generated from the xml files in the data root. //-------- TODO: get rid of the garbage with the color triples. blech. //-------- load the font for the arialHeader, at 10 pt. origTag=cur; arialHeader.loadFont(defaultFont); arialHeader.setMode(OF_FONT_MID); arialHeader.setSize(14); insertSpace=0; bGrabbed=false; //-------- color initialization if(cur.getAttribute("color").length()) color=ofColor(strtol(cur.getAttribute("color").c_str(),NULL,0)); else color=col; //-------- load name from the name of the xmlNode title=cur.getAttribute("name"); ttlSize.x=w; ttlSize.y=TITLE_HEIGHT; ddSelected=false; //cout << title << endl; //-------- init some variables, to prevent garbage from happening ddOpen=false; titlePos.x=10; type=BLK_DEFAULT; placeHolder=false; //-------- declare the map used for the switch map<string,int> list; list["seq"]=0; list["bracket"]=1; list["action"]=4; list["file"]=5; list["sibling"]=6; list["num"]=7; list["dropdown"]=8; list["blocksIn"]=9; list["blocksOn"]=10; for(int i=0;i<cur.size();i++){ string node[2]={cur[i].getLabel(),cur[i].getValue()}; //-- node[0] is the label, node[1] is the value if(list.find(node[0])!=list.end()){ switch (list.find(node[0])->second) { case 1: //-- bracket //-------- set type to bracket, and change size type=BLK_BRACKET; h=105; w=200; titlePos.x=30; break; case 5: // file //-- definitely not deprecated, used to store value of which file to write from filename=node[1]; break; case 6: // sibling //-- stores the name of the complement blocks sibling.push_back(node[1]); break; case 7: // num //-- set the statement block flag type=BLK_VAL; titlePos.x=0; ttlSize.x=w=90; ttlSize.y=h=20; break; case 8: // dropdown //-- add a new dropdown menu to the block ddGroup.push_back(dallasDrop(cur[i])); break; case 9: for (unsigned int j=0; j<cur[i].size(); j++) { if (cur[i][j].getLabel()=="block") { blocksIn.push_back(block(cur[i][j],color)); } } break; case 10: for (unsigned int j=0; j<cur[i].size(); j++) { if (cur[i][j].getLabel()=="block") { blocksOn.push_back(block(cur[i][j],color)); } } break; default: break; } } } parseTitle(); }