/** * @brief Verify the the formatName function correctly replace spaces by underscores. */ void verifyFormatName() { /*Verify that spaces in the name are replaced by underscores.*/ char* name = "grille 1"; char* wellFormatedName = formatName(name); CU_ASSERT(strcmp(wellFormatedName, "grille_1") == 0); name = "special ! ? ; :"; wellFormatedName = formatName(name); CU_ASSERT(strcmp(wellFormatedName, "special_!_?_;_:") == 0); name = NULL; wellFormatedName = formatName(NULL); CU_ASSERT(wellFormatedName == NULL); }
QString BaseObject::getName(bool format) { if(format) { QString aux_name; aux_name=formatName(this->obj_name, (obj_type==OBJ_OPERATOR)); if(this->schema) aux_name=formatName(this->schema->getName()) + "." + aux_name; return(aux_name); } else return(this->obj_name); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QStringList MimeDataWithIndexes::formats() const { QStringList supportedFormats = QMimeData::formats(); supportedFormats << formatName(); return supportedFormats; }
QMap<QString, TLMethod> GeneratorNG::readMethods(const QJsonDocument &document) { const QJsonArray methods = document.object().value("methods").toArray(); QMap<QString, TLMethod> result; for (int i = 0; i < methods.count(); ++i) { const QJsonObject obj = methods.at(i).toObject(); const QString methodName = formatName(obj.value("method").toString()); const quint32 methodId = obj.value("id").toString().toInt(); TLMethod tlMethod; tlMethod.name = methodName; tlMethod.id = methodId; const QJsonArray params = obj.value("params").toArray(); foreach (const QJsonValue ¶mValue, params) { const QJsonObject ¶mObj = paramValue.toObject(); const QString paramName = formatMember(paramObj.value("name").toString()); const QString paramType = paramObj.value("type").toString(); tlMethod.params.append(TLParam(paramName, formatType(paramType))); } result.insert(methodName, tlMethod); // quint32 id = obj.value("id").toString().toInt(); // qDebug() << name << QString::number(id, 0x10); } return result; }
QString GeneratorNG::formatMember(QString name) { if (badNames.contains(name)) { name = badNamesReplacers.at(badNames.indexOf(name)); } return formatName(name); }
void QtHistory::replayItem(int id) { if (id != 0){ HistoryMementoCollection * collection = _cHistory.getHistory().getHistoryMementoCollection(); HistoryMemento* memento = collection->getMemento(id); QString data = QString::fromStdString(memento->getData()); QtWengoPhone * qtWengoPhone = (QtWengoPhone *) _cHistory.getCWengoPhone().getPresentation(); //VOXOX - CJC - 2009.06.10 QtVoxMessageBox box(_historyWidget->getWidget()); box.setWindowTitle("VoxOx - Call History"); box.setText(tr("Do you want to call %1?").arg(formatName(memento->getPeer(), _isWengoAccountConnected))); box.setStandardButtons(QMessageBox::Yes | QMessageBox::No ); /*QMessageBox mb(tr("@product@ - Call History"), tr("Do you want to call %1?").arg(formatName(memento->getPeer(), _isWengoAccountConnected)), QMessageBox::Question, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, QMessageBox::NoButton, _historyWidget->getWidget());*/ switch (memento->getState()) { case HistoryMemento::OutgoingSmsOk: case HistoryMemento::OutgoingSmsNok: { //Retrieve info & configure the Sms widget std::string data = _cHistory.getMementoData(id); QString text = QString::fromUtf8(data.c_str(), data.size()); QString phoneNumber = QString::fromStdString(_cHistory.getMementoPeer(id)); //Test existance of Sms (available only if a WengoAccount has been created) QtSms * sms = qtWengoPhone->getQtSms(); if (sms) { sms->setText(text); sms->setPhoneNumber(phoneNumber); sms->getWidget()->show(); } break; } case HistoryMemento::OutgoingCall: case HistoryMemento::IncomingCall: case HistoryMemento::MissedCall: case HistoryMemento::RejectedCall: if (box.exec() == QMessageBox::Yes) { _cHistory.replay(id); } break; case HistoryMemento::ChatSession: _chatLogViewer = new QtChatLogViewer(NULL, *qtWengoPhone, data ); _chatLogViewer->restartChat(); break; default: break; } } }
QString GeneratorNG::formatName1stCapital(QString name) { if (name.isEmpty()) { return QString(); } name[0] = name.at(0).toUpper(); return formatName(name); }
QString BaseObject::getName(bool format, bool prepend_schema) { if(format) { QString aux_name; aux_name=formatName(this->obj_name, (obj_type==OBJ_OPERATOR)); if(this->schema && prepend_schema) aux_name=formatName(this->schema->getName(format)) + QString(".") + aux_name; if(!aux_name.isEmpty()) return(aux_name); else return(this->obj_name); } else return(this->obj_name); }
CString CInputFilter::CMouseButtonAction::format() const { const char* type = formatName(); CString key = CKeyMap::formatKey(kKeyNone, m_buttonInfo->m_mask); return CStringUtil::print("%s(%s%s%d)", type, key.c_str(), key.empty() ? "" : "+", m_buttonInfo->m_button); }
void SelectionBar::OnUpdate(wxCommandEvent &evt) { int index = evt.GetInt(); wxWindow *w = FindFocus(); bool leftFocus = (w == mLeftTime); bool rightFocus = (w == mRightTime); bool audioFocus = (w == mAudioTime); evt.Skip(false); /* we don't actually need a TimeTextCtrl, but need it's * translations which are done at runtime */ TimeTextCtrl *ttc = new TimeTextCtrl(this, wxID_ANY, wxT(""), 0.0, mRate); wxString formatName(ttc->GetBuiltinName(index)); gPrefs->Write(wxT("/SelectionFormat"), formatName); gPrefs->Flush(); #if wxUSE_TOOLTIPS mSnapTo->SetToolTip(wxString::Format(_("Snap Clicks/Selections to %s"), formatName.c_str())); #endif delete ttc; // ToolBar::ReCreateButtons() will get rid of our sizers and controls // so reset pointers first. mLeftTime = mRightTime = mAudioTime = NULL; mRightEndButton = mRightLengthButton = NULL; mRateBox = NULL; mRateText = NULL; ToolBar::ReCreateButtons(); ValuesToControls(); wxString formatString = mLeftTime->GetBuiltinFormat(index); mLeftTime->SetFormatString(formatString); mRightTime->SetFormatString(formatString); mAudioTime->SetFormatString(formatString); if (leftFocus) { mLeftTime->SetFocus(); } else if (rightFocus) { mRightTime->SetFocus(); } else if (audioFocus) { mAudioTime->SetFocus(); } Updated(); }
QString QOption::help() const { QString message = formatName(); if (type()==QOption::SingleToken) message.append(" value"); else if (type()==QOption::MultiToken) message.append(" value1 ... valueN"); message = QString("%1").arg(message, -33); message.append(mDescription); if (mDefaultValue.isValid() && !mDefaultValue.toString().isEmpty()) message.append(" (default: " + mDefaultValue.toString() + ")"); return message; }
QString GeneratorNG::formatType(QString type) { if (plainTypes.contains(type)) { return nativeTypes.at(plainTypes.indexOf(type)); } else if (type.startsWith(QLatin1String("Vector<"))) { int firstIndex = type.indexOf(QLatin1Char('<')) + 1; int lastIndex = type.indexOf(QLatin1Char('>')); QString subType = type.mid(firstIndex, lastIndex - firstIndex); return QString("%1<%2>").arg(tlVectorType).arg(formatType(subType)); } else { type[0] = type.at(0).toUpper(); return tlPrefix + formatName(type); } }
QVariant QtHistory::data(const QModelIndex& index, int role) const { if (index.row() < 0 || index.row() >= _mementoIdList.size()) { return QVariant(); } int id = _mementoIdList[index.row()]; HistoryMementoCollection * collection = _cHistory.getHistory().getHistoryMementoCollection(); HistoryMemento* memento = collection->getMemento(id); if (!memento) { LOG_ERROR("Couldn't get memento for id " + String::fromNumber(id)); return QVariant(); } if (role == Qt::DisplayRole) { switch (index.column()) { case 0: return textForMementoState(memento->getState()); case 1: return QVariant(formatName(memento->getPeer(), _isWengoAccountConnected)); case 2: return QVariant(formatDate(qDateTimeForMemento(memento))); case 3: //VOXOX - CJC - 2009.05.31 Only show duration for calls if(memento->getState() == HistoryMemento::OutgoingCall || memento->getState()== HistoryMemento::IncomingCall ||memento->getState() == HistoryMemento::MissedCall || memento->getState() == HistoryMemento::RejectedCall){ return QVariant(formatDuration(qTimeForDuration(memento->getDuration()))); }else{ return QVariant(""); } default: return QVariant(); } } else if (role == Qt::DecorationRole) { if (index.column() == 0) { return QVariant(iconForMementoState(memento->getState())); } else { return QVariant(); } } else if (role == Qt::UserRole) { return QVariant(id); } return QVariant(); }
/* listStudents print a list of all students in global students[] array in: none out: none */ void listStudents() { // declarations struct STUDENT *s; // pointer to "current" student int i; // loop counter // print headers printf("LIST ALL STUDENTS\n\n"); printf( " # Student Name\t\t\tEnrolled Credits\n" "=== ============\t\t\t========== =======\n"); // loop through all students for (i = 0; i < numStudents; i++) { s = &students[i]; // set pointer to "current" student // print the student's data printf("%3d " // ### "%-34.34s " // last, first "%10s " // mm/dd/yyyy "%7d\n", // ### i+1, formatName(s->firstName, s->lastName, 1), formatDate(s->enrollmentDate), s->completedCredits); } printf("\n"); // ask user whether to view/edit the details i = inputInteger("Type # to view/edit, or blank to return to menu. "); // if not, return if (i < 1 || i > numStudents) return; // print the student's details // (if we had more fields, they would be displayed now) printf("\n"); printStudent(&students[i-1]); printf("\n"); // edit student if user wishes to do so if (confirm("Edit this student (y/n) ? ")) editStudent(&students[i-1]); }
CString CInputFilter::CKeystrokeAction::format() const { const char* type = formatName(); if (m_keyInfo->m_screens[0] == '\0') { return CStringUtil::print("%s(%s)", type, CKeyMap::formatKey(m_keyInfo->m_key, m_keyInfo->m_mask).c_str()); } else if (m_keyInfo->m_screens[0] == '*') { return CStringUtil::print("%s(%s,*)", type, CKeyMap::formatKey(m_keyInfo->m_key, m_keyInfo->m_mask).c_str()); } else { return CStringUtil::print("%s(%s,%.*s)", type, CKeyMap::formatKey(m_keyInfo->m_key, m_keyInfo->m_mask).c_str(), strlen(m_keyInfo->m_screens + 1) - 1, m_keyInfo->m_screens + 1); } }
void run() { ofPixels pixels; const int w = 320; const int h = 240; for(ofPixelFormat pixelFormat=OF_PIXELS_GRAY; pixelFormat<OF_PIXELS_NUM_FORMATS; pixelFormat = (ofPixelFormat)(pixelFormat+1)) { pixels.allocate(w,h,pixelFormat); int bpp = bitsPerPixel(pixelFormat); string format = formatName(pixelFormat); test_eq(pixels.getBitsPerChannel(),8,"getBitsPerChannel() " + format); test_eq(pixels.getBitsPerPixel(),bpp,"getBitsPerPixel() " + format); test_eq(pixels.getBytesPerChannel(),1,"getBytesPerChannel() " + format); test_eq(pixels.getBytesPerPixel(),bpp/8,"getBytesPerPixel() " + format); test_eq(pixels.getBytesStride(),w*bpp/8,"getBytesStride() " + format); test_eq(pixels.getWidth(),w,"getWidth() " + format); test_eq(pixels.getHeight(),h,"getHeight() " + format); if(hasImageFormat(pixelFormat)) { test_eq(pixels.getImageType(),imageType(pixelFormat),"getImageType() " + format); } if(hasChannels(pixelFormat)) { test_eq(pixels.getNumChannels(),numChannels(pixelFormat),"getNumChannels() " + format); } test_eq(pixels.getNumPlanes(),getNumPlanes(pixelFormat),"getNumPlanes() " + format); test_eq(pixels.getPixelFormat(),pixelFormat,"getPixelFormat() " + format); test_eq((uint64_t)pixels.getPlane(0).getData(), (uint64_t)pixels.getData(),"getPlane(0)==getData() " + format); test_eq(pixels.getTotalBytes(),w*h*bpp/8,"getTotalBytes() " + format); if(hasWorkingIterators(pixelFormat)) { test_eq((uint64_t)pixels.getLine(0).begin(), (uint64_t)pixels.getData(),"getLine(0).begin()==getData() " + format); test_eq((uint64_t)pixels.getLine(0).end(), (uint64_t)pixels.getData()+(w*bpp/8),"getLine(0).end()==getData()+(w*3) " + format); test_eq((uint64_t)pixels.getLine(h-1).begin(), (uint64_t)pixels.getData()+(w*bpp/8*(h-1)),"getLine(h-1).begin()==getData()+(w*bpp/8*(h-1)) " + format); test_eq((uint64_t)pixels.getLine(h-1).end(), (uint64_t)pixels.end(),"getLine(h-1).end()==end() " + format); test_eq((uint64_t)&pixels.getLine(0).getPixel(10)[0], (uint64_t)pixels.getData()+(10*bpp/8),"getLine(0).getPixel(10)[0]==pixels.getData()+(10*bpp/8)"); } } }
int decompTest(char *filename) { FILE *file=NULL; tjhandle handle=NULL; unsigned char **jpegbuf=NULL, *srcbuf=NULL; unsigned long *jpegsize=NULL, srcsize, totaljpegsize; tjtransform *t=NULL; int w=0, h=0, subsamp=-1, cs=-1, _w, _h, _tilew, _tileh, _ntilesw, _ntilesh, _subsamp; char *temp=NULL, tempstr[80], tempstr2[80]; int row, col, i, iter, tilew, tileh, ntilesw=1, ntilesh=1, retval=0; double start, elapsed; int ps=tjPixelSize[pf], tile; if((file=fopen(filename, "rb"))==NULL) _throwunix("opening file"); if(fseek(file, 0, SEEK_END)<0 || (srcsize=ftell(file))==(unsigned long)-1) _throwunix("determining file size"); if((srcbuf=(unsigned char *)malloc(srcsize))==NULL) _throwunix("allocating memory"); if(fseek(file, 0, SEEK_SET)<0) _throwunix("setting file position"); if(fread(srcbuf, srcsize, 1, file)<1) _throwunix("reading JPEG data"); fclose(file); file=NULL; temp=strrchr(filename, '.'); if(temp!=NULL) *temp='\0'; if((handle=tjInitTransform())==NULL) _throwtj("executing tjInitTransform()"); if(tjDecompressHeader3(handle, srcbuf, srcsize, &w, &h, &subsamp, &cs)==-1) _throwtj("executing tjDecompressHeader3()"); if(cs==TJCS_YCCK || cs==TJCS_CMYK) { pf=TJPF_CMYK; ps=tjPixelSize[pf]; } if(quiet==1) { printf("All performance values in Mpixels/sec\n\n"); printf("Bitmap JPEG JPEG %s %s Xform Comp Decomp ", dotile? "Tile ":"Image", dotile? "Tile ":"Image"); if(doyuv) printf("Decode"); printf("\n"); printf("Format CS Subsamp Width Height Perf Ratio Perf "); if(doyuv) printf("Perf"); printf("\n\n"); } else if(!quiet) printf(">>>>> JPEG %s --> %s (%s) <<<<<\n", formatName(subsamp, cs, tempstr), pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "Bottom-up":"Top-down"); for(tilew=dotile? 16:w, tileh=dotile? 16:h; ; tilew*=2, tileh*=2) { if(tilew>w) tilew=w; if(tileh>h) tileh=h; ntilesw=(w+tilew-1)/tilew; ntilesh=(h+tileh-1)/tileh; if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) *ntilesw*ntilesh))==NULL) _throwunix("allocating JPEG tile array"); memset(jpegbuf, 0, sizeof(unsigned char *)*ntilesw*ntilesh); if((jpegsize=(unsigned long *)malloc(sizeof(unsigned long) *ntilesw*ntilesh))==NULL) _throwunix("allocating JPEG size array"); memset(jpegsize, 0, sizeof(unsigned long)*ntilesw*ntilesh); if((flags&TJFLAG_NOREALLOC)!=0 || !dotile) for(i=0; i<ntilesw*ntilesh; i++) { if((jpegbuf[i]=(unsigned char *)tjAlloc(tjBufSize(tilew, tileh, subsamp)))==NULL) _throwunix("allocating JPEG tiles"); } _w=w; _h=h; _tilew=tilew; _tileh=tileh; if(!quiet) { printf("\n%s size: %d x %d", dotile? "Tile":"Image", _tilew, _tileh); if(sf.num!=1 || sf.denom!=1) printf(" --> %d x %d", TJSCALED(_w, sf), TJSCALED(_h, sf)); printf("\n"); } else if(quiet==1) { printf("%-4s (%s) %-5s %-5s ", pixFormatStr[pf], (flags&TJFLAG_BOTTOMUP)? "BU":"TD", csName[cs], subNameLong[subsamp]); printf("%-5d %-5d ", tilew, tileh); } _subsamp=subsamp; if(dotile || xformop!=TJXOP_NONE || xformopt!=0 || customFilter) { if((t=(tjtransform *)malloc(sizeof(tjtransform)*ntilesw*ntilesh)) ==NULL) _throwunix("allocating image transform array"); if(xformop==TJXOP_TRANSPOSE || xformop==TJXOP_TRANSVERSE || xformop==TJXOP_ROT90 || xformop==TJXOP_ROT270) { _w=h; _h=w; _tilew=tileh; _tileh=tilew; } if(xformopt&TJXOPT_GRAY) _subsamp=TJ_GRAYSCALE; if(xformop==TJXOP_HFLIP || xformop==TJXOP_ROT180) _w=_w-(_w%tjMCUWidth[_subsamp]); if(xformop==TJXOP_VFLIP || xformop==TJXOP_ROT180) _h=_h-(_h%tjMCUHeight[_subsamp]); if(xformop==TJXOP_TRANSVERSE || xformop==TJXOP_ROT90) _w=_w-(_w%tjMCUHeight[_subsamp]); if(xformop==TJXOP_TRANSVERSE || xformop==TJXOP_ROT270) _h=_h-(_h%tjMCUWidth[_subsamp]); _ntilesw=(_w+_tilew-1)/_tilew; _ntilesh=(_h+_tileh-1)/_tileh; if(xformop==TJXOP_TRANSPOSE || xformop==TJXOP_TRANSVERSE || xformop==TJXOP_ROT90 || xformop==TJXOP_ROT270) { if(_subsamp==TJSAMP_422) _subsamp=TJSAMP_440; else if(_subsamp==TJSAMP_440) _subsamp=TJSAMP_422; } for(row=0, tile=0; row<_ntilesh; row++) { for(col=0; col<_ntilesw; col++, tile++) { t[tile].r.w=min(_tilew, _w-col*_tilew); t[tile].r.h=min(_tileh, _h-row*_tileh); t[tile].r.x=col*_tilew; t[tile].r.y=row*_tileh; t[tile].op=xformop; t[tile].options=xformopt|TJXOPT_TRIM; t[tile].customFilter=customFilter; if(t[tile].options&TJXOPT_NOOUTPUT && jpegbuf[tile]) { tjFree(jpegbuf[tile]); jpegbuf[tile]=NULL; } } } iter=-warmup; elapsed=0.; while(1) { start=gettime(); if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntilesh, jpegbuf, jpegsize, t, flags)==-1) _throwtj("executing tjTransform()"); iter++; if(iter>=1) { elapsed+=gettime()-start; if(elapsed>=benchtime) break; } } free(t); t=NULL; for(tile=0, totaljpegsize=0; tile<_ntilesw*_ntilesh; tile++) totaljpegsize+=jpegsize[tile]; if(quiet) { printf("%-6s%s%-6s%s", sigfig((double)(w*h)/1000000./elapsed, 4, tempstr, 80), quiet==2? "\n":" ", sigfig((double)(w*h*ps)/(double)totaljpegsize, 4, tempstr2, 80), quiet==2? "\n":" "); } else if(!quiet) { printf("Transform --> Frame rate: %f fps\n", 1.0/elapsed); printf(" Output image size: %lu bytes\n", totaljpegsize); printf(" Compression ratio: %f:1\n", (double)(w*h*ps)/(double)totaljpegsize); printf(" Throughput: %f Megapixels/sec\n", (double)(w*h)/1000000./elapsed); printf(" Output bit stream: %f Megabits/sec\n", (double)totaljpegsize*8./1000000./elapsed); } } else { if(quiet==1) printf("N/A N/A "); jpegsize[0]=srcsize; memcpy(jpegbuf[0], srcbuf, srcsize); } if(w==tilew) _tilew=_w; if(h==tileh) _tileh=_h; if(!(xformopt&TJXOPT_NOOUTPUT)) { if(decomp(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0, filename, _tilew, _tileh)==-1) goto bailout; } else if(quiet==1) printf("N/A\n"); for(i=0; i<ntilesw*ntilesh; i++) { tjFree(jpegbuf[i]); jpegbuf[i]=NULL; } free(jpegbuf); jpegbuf=NULL; if(jpegsize) {free(jpegsize); jpegsize=NULL;} if(tilew==w && tileh==h) break; } bailout: if(file) {fclose(file); file=NULL;} if(jpegbuf) { for(i=0; i<ntilesw*ntilesh; i++) { if(jpegbuf[i]) tjFree(jpegbuf[i]); jpegbuf[i]=NULL; } free(jpegbuf); jpegbuf=NULL; } if(jpegsize) {free(jpegsize); jpegsize=NULL;} if(srcbuf) {free(srcbuf); srcbuf=NULL;} if(t) {free(t); t=NULL;} if(handle) {tjDestroy(handle); handle=NULL;} return retval; }
QString AVDemuxer::videoFormatName() const { return formatName(format_context, false); }
QString AVInfo::videoFormatName() const { return formatName(_format_context, false); }
QString AVInfo::videoFormatLongName() const { return formatName(_format_context, true); }
QString QFImageWriterLibTIFF::filter() const { return QString("%1 (*.tif *.tiff)").arg(formatName()); }
QString AVDemuxer::videoFormatLongName() const { return formatName(format_context, true); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool MimeDataWithIndexes::hasFormat(const QString &mimetype) const { return (mimetype == formatName()); }