//================================================================================ //convertPathL //================================================================================ void convertPathL(TDesC& aPath, TDesC& aPathName, RFs& aFs, TDesC& aTargetFile) { aFs.MkDirAll(aPathName); CDir* entryList = NULL; TInt error = aFs.GetDir(aPath,KEntryAttMatchMask,ESortByName,entryList); User::LeaveIfError(error); TInt numberOfFiles = entryList->Count(); for (TInt i=0; i<numberOfFiles; i++) { //get the source file HBufC* temp=HBufC::NewLC(((*entryList)[i].iName).Length()); TPtr sourceFileName(temp->Des()); sourceFileName.Copy((*entryList)[i].iName); HBufC* temp2=HBufC::NewLC(((*entryList)[i].iName).Length()+aPathName.Length()); TPtr sourceFile(temp2->Des()); sourceFile = aPathName; sourceFile.Append(sourceFileName); //do the conversion synchronousL(sourceFile, aTargetFile); //output result _LIT(KString,"%S"); test.Printf(KString,&(sourceFileName)); test.Printf(_L("\n")); CleanupStack::PopAndDestroy(2);//temp, temp2 } delete entryList; test.Printf(_L("\n%d files converted\n"),numberOfFiles); }
QStringList NewClassWidget::files() const { QStringList rc; const QDir dir = QDir(path()); rc.push_back(expandFileName(dir, headerFileName(), headerExtension())); rc.push_back(expandFileName(dir, sourceFileName(), sourceExtension())); if (isFormInputVisible()) rc.push_back(expandFileName(dir, formFileName(), formExtension())); return rc; }
Foam::error::operator dictionary() const { dictionary errDict; string oneLineMessage(message()); oneLineMessage.replaceAll('\n', ' '); errDict.add("type", word("Foam::error")); errDict.add("message", oneLineMessage); errDict.add("function", functionName()); errDict.add("sourceFile", sourceFileName()); errDict.add("sourceFileLineNumber", sourceFileLineNumber()); return errDict; }
TriaAction::CreateAstConsumerResultType TriaAction::CreateASTConsumer (clang::CompilerInstance &ci, llvm::StringRef fileName) { ci.getFrontendOpts().SkipFunctionBodies = true; ci.getPreprocessor().enableIncrementalProcessing (true); ci.getLangOpts().DelayedTemplateParsing = true; // Enable everything for code compatibility ci.getLangOpts().MicrosoftExt = true; ci.getLangOpts().DollarIdents = true; ci.getLangOpts().CPlusPlus11 = true; ci.getLangOpts().GNUMode = true; #if CLANG_VERSION_MINOR < 6 ci.getLangOpts().CPlusPlus1y = true; #else ci.getLangOpts().CPlusPlus14 = true; #endif if (argVerboseTimes) { UNIQUE_COMPAT(PreprocessorHooks, hook, new PreprocessorHooks (ci)); hook->timing ()->name = sourceFileName (this->m_definitions->sourceFiles ()); this->m_definitions->setTimingNode (hook->timing ()); ci.getPreprocessor ().addPPCallbacks (MOVE_COMPAT(hook)); } // QStringList whichInherit; for (const std::string &cur : argInspectBases) { whichInherit.append (QString::fromStdString (cur)); } // TriaASTConsumer *consumer = new TriaASTConsumer (ci, fileName, whichInherit, argInspectAll, argGlobalClass, this->m_definitions); #if CLANG_VERSION_MINOR < 6 return consumer; #else return std::unique_ptr< clang::ASTConsumer > (consumer); #endif }
void TeamWindow::_HandleResolveMissingSourceFile(entry_ref& locatedPath) { if (fActiveFunction != NULL) { LocatableFile* sourceFile = fActiveFunction->GetFunctionDebugInfo() ->SourceFile(); if (sourceFile != NULL) { BString sourcePath; sourceFile->GetPath(sourcePath); BString sourceFileName(sourcePath); int32 index = sourcePath.FindLast('/'); if (index >= 0) sourceFileName.Remove(0, index + 1); BPath targetFilePath(&locatedPath); if (targetFilePath.InitCheck() != B_OK) return; if (strcmp(sourceFileName.String(), targetFilePath.Leaf()) != 0) { BString message; message.SetToFormat("The names of source file '%s' and located" " file '%s' differ. Use file anyway?", sourceFileName.String(), targetFilePath.Leaf()); BAlert* alert = new(std::nothrow) BAlert( "Source path mismatch", message.String(), "Cancel", "Use"); if (alert == NULL) return; int32 choice = alert->Go(); if (choice <= 0) return; } fListener->SourceEntryLocateRequested(sourcePath, targetFilePath.Path()); fListener->FunctionSourceCodeRequested(fActiveFunction); } } }
//using namespace cl; int main(int argc, char ** argv) { try { cl_int err; cl::vector<cl::Platform> platforms; cl::Platform::get(&platforms); std::cout << "Number of platforms:\t" << platforms.size() << std::endl; for (cl::vector<cl::Platform>::iterator i = platforms.begin(); i != platforms.end(); ++i) { // pick a platform and do something std::cout << " Platform Name: " << (*i).getInfo<CL_PLATFORM_NAME>().c_str()<< std::endl; } float theta = 3.14159/6; int W ; int H ; const char* inputFile = "input.bmp"; const char* outputFile = "output.bmp"; // Homegrown function to read a BMP from file float* ip = readImage(inputFile, &W, &H); float * op = new float[W*H]; //Lets choose the first platform cl_context_properties cps[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[PLATFORM_TO_USE])(), 0}; // Select the default platform and create a context // using this platform for a GPU type device cl::Context context(DEVICE_TYPE_TO_USE, cps); cl::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>(); //Lets create a command queue on the first device cl::CommandQueue queue = cl::CommandQueue(context, devices[0], 0, &err); //[H3] Step2 – Declare Buffers and Move Data //We assume that the input image is the array “ip” //and the angle of rotation is theta float cos_theta = cos(theta); float sin_theta = sin(theta); cl::Buffer d_ip = cl::Buffer(context, CL_MEM_READ_ONLY, W*H* sizeof(float)); cl::Buffer d_op = cl::Buffer(context, CL_MEM_READ_WRITE, W*H* sizeof(float)); queue.enqueueWriteBuffer(d_ip, CL_TRUE, 0, W*H* sizeof(float), ip); //[H3]Step3 – Runtime kernel compilation std::ifstream sourceFileName("rotation.cl"); std::string sourceFile( std::istreambuf_iterator<char>( sourceFileName), (std::istreambuf_iterator<char>()) ); //std::cout<<sourceFile; cl::Program::Sources rotn_source(1, std::make_pair(sourceFile.c_str(), sourceFile.length() +1 ) ); cl::Program rotn_program(context, rotn_source); rotn_program.build(devices); cl::Kernel rotn_kernel(rotn_program, "img_rotate", &err); //[H3]Step4 – Run the program rotn_kernel.setArg(0, d_op); rotn_kernel.setArg(1, d_ip); rotn_kernel.setArg(2, W); rotn_kernel.setArg(3, H); rotn_kernel.setArg(4, sin_theta); rotn_kernel.setArg(5, cos_theta); // Run the kernel on specific ND range cl::NDRange globalws(W,H); //In this example the local work group size is not important because //there is no communication between local work items queue.enqueueNDRangeKernel(rotn_kernel, cl::NullRange, globalws, cl::NullRange); //[H3]Step5 – Read result back to host // Read buffer d_op into a local op array queue.enqueueReadBuffer(d_op, CL_TRUE, 0, W*H*sizeof(float), op); storeImage(op, outputFile, H, W, inputFile); } catch(cl::Error err) { std::cout << err.what() << "(" << err.err() << ")" << std::endl; } }
QString CachedImage::_path() const { return QString("%1/%2").arg(_man->path()).arg(sourceFileName()); }
QString VisualLog::MessageInfo::expand(const QString &pattern) const{ QString base = ""; QDateTime dt = stamp(); QString::const_iterator it = pattern.begin(); while ( it != pattern.end() ){ if ( *it == QChar('%') ){ ++it; if ( it != pattern.end() ){ char c = it->toLatin1(); switch(c){ case 'p': { if ( m_location && !m_location->remote.isEmpty() ) base += m_location->remote + "> "; base += QString().sprintf( "%0*d-%0*d-%0*d %0*d:%0*d:%0*d.%0*d %s %s@%d: ", 4, dt.date().year(), 2, dt.date().month(), 2, dt.date().day(), 2, dt.time().hour(), 2, dt.time().minute(), 2, dt.time().second(), 3, dt.time().msec(), qPrintable(levelToString(m_level).toLower()), qPrintable(sourceFunctionName()), sourceLineNumber() ); break; } case 'r': base += sourceRemoteLocation(); break; case 'F': base += sourceFileName(); break; case 'N': base += extractFileNameSegment(sourceFileName()); break; case 'U': base += sourceFunctionName(); break; case 'L': base += QString::number(sourceLineNumber()); break; case 'V': base += levelToString(m_level); break; case 'v': base += levelToString(m_level).toLower(); break; case 'w': base += QDate::shortDayName(dt.date().dayOfWeek()); break; case 'W': base += QDate::longDayName(dt.date().dayOfWeek()); break; case 'b': base += QDate::shortMonthName(dt.date().month()); break; case 'B': base += QDate::longMonthName(dt.date().month()); break; case 'd': base += QString().sprintf("%0*d", 2, dt.date().day() ); break; case 'e': base += QString().sprintf("%d", dt.date().day() ); break; case 'f': base += QString().sprintf("%*d", 2, dt.date().day() ); break; case 'm': base += QString().sprintf("%0*d", 2, dt.date().month() ); break; case 'n': base += QString().sprintf("%d", dt.date().month() ); break; case 'o': base += QString().sprintf("%*d", 2, dt.date().month() ); break; case 'y': base += QString().sprintf("%0*d", 2, dt.date().year() % 100 ); break; case 'Y': base += QString().sprintf("%0*d", 4, dt.date().year() ); break; case 'H': base += QString().sprintf("%0*d", 2, dt.time().hour() ); break; case 'I': { int hour = dt.time().hour(); base += QString().sprintf("%0*d", 2, (hour < 1 ? 12 : (hour > 12 ? hour - 12 : hour))); break; } case 'a': base += QString().sprintf(dt.time().hour() < 12 ? "am" : "pm" ); break; case 'A': base += QString().sprintf(dt.time().hour() < 12 ? "AM" : "PM" ); break; case 'M': base += QString().sprintf("%0*d", 2, dt.time().minute()); break; case 'S': base += QString().sprintf("%0*d", 2, dt.time().second() ); break; case 's': base += QString().sprintf("%0*d.%0*d", 2, dt.time().second(), 3, dt.time().msec() ); break; case 'i': base += QString().sprintf("%0*d", 3, dt.time().msec() ); break; case 'c': base += QString().sprintf("%d", dt.time().msec() / 100 ); break; default: base += *it; } } } else { base += *it; } ++it; } return base; }