void addNewParser(std::string name, ParserSettings *ps) { parsers.emplace_back(); Parser *p = &parsers[parsers.size() - 1]; p->lang_type = L_USER; p->lang = toWideString(name); p->language_name = toWideString(name); p->external = true; if(ps == nullptr) { // Fill in default values p->ps.doc_start = "/**"; p->ps.doc_line = " * "; p->ps.doc_end = " */"; p->ps.command_prefix = "\\"; p->ps.file_format = default_file_format; p->ps.function_format = default_internal_function_format; p->ps.align = false; // not used } else { p->ps = *ps; } }
void addNewParser(std::string name, ParserDefinition *pd) { Parser *p = new Parser(); p->lang_type = L_USER; p->lang = toWideString(name); p->language_name = toWideString(name); p->external = true; p->initializer = NULL; p->cleanup = NULL; p->parse = NULL; if(pd == NULL) { // Fill in default values p->pd.doc_start = "/**"; p->pd.doc_line = " * "; p->pd.doc_end = " */"; p->pd.command_prefix = "\\"; p->pd.file_format = default_file_format; p->pd.function_format = default_internal_function_format; p->pd.align = false; // not used } else { p->pd = *pd; } parsers.push_back(p); }
bool FileDialog::onEvent(const Event &event) { if(event.type == Event::escape) { close(0); } else if(event.type == Event::button_clicked) { close(event.value); } else if(event.type == Event::element_selected) { if(event.value >= 0 && event.value < m_list_box->size()) { FilePath file_path = m_dir_path / FilePath((*m_list_box)[event.value].text.c_str()); file_path = file_path.absolute(); if(file_path.isDirectory()) { m_dir_path = file_path; updateList(); } else if(file_path.isRegularFile()) { m_edit_box->setText(toWideString(file_path.fileName())); } } updateButtons(); } else if(event.type == Event::text_modified) { auto file_name = fromWideString(m_edit_box->text()); m_list_box->selectEntry(m_list_box->findEntry(file_name.c_str())); updateButtons(); } else return false; return true; }
void TMacroFx::compatibilityTranslatePort(int major, int minor, std::string &portName) { // Reroute translation to the actual fx associated to the port const std::string &fxId = portName.substr(portName.find_last_of('_') + 1, std::string::npos); if (TFx *fx = getFxById(toWideString(fxId))) { size_t opnEnd = portName.find_first_of('_'); std::string originalPortName = portName.substr(0, opnEnd); fx->compatibilityTranslatePort(major, minor, originalPortName); portName.replace(0, opnEnd, originalPortName); } // Seems that at a certain point, the port name got extended... if (VersionNumber(major, minor) == VersionNumber(1, 16)) { for (int i = 0; i < getInputPortCount(); ++i) { const std::string &name = getInputPortName(i); if (name.find(portName) != string::npos) { portName = name; break; } } } }
void sky::InitSky(const std::wstring& envmapFilename, float skyRadius) { mRadius = skyRadius; HR(D3DXCreateSphere(g_app->m_pD3DDev, skyRadius, 30, 30, &mSphere, 0),L"sky::sky: Failed to create sky sphere: "); HR(D3DXCreateCubeTextureFromFile(g_app->m_pD3DDev, envmapFilename.c_str(), &mEnvMap), L"sky::sky: Failed to create sky texture from file: "); LPCWSTR shaderFile; switch(g_renderer->m_shaderVersion) { case 2: shaderFile = L"Shaders/sky_2_0.fx"; break; case 3: shaderFile = L"Shaders/sky_3_0.fx"; break; default: throw std::runtime_error("buildFX: m_shaderVersion must be 2 or 3."); break; } ID3DXBuffer* errors = 0; HR(D3DXCreateEffectFromFileEx(g_app->m_pD3DDev, shaderFile, 0, 0, 0, 0, 0, &m_FX, &errors), L"sky::sky: Failed to create sky effects: "); if( errors ) { MessageBox(0, toWideString((char*)errors->GetBufferPointer(),-1).c_str(), 0, 0); throw std::runtime_error("sky::sky: errors exist in initializing sky"); } mhTech = m_FX->GetTechniqueByName("SkyTech"); mhWVP = m_FX->GetParameterByName(0, "gWVP"); mhEnvMap = m_FX->GetParameterByName(0, "gEnvMap"); // Set effect parameters that do not vary. HR(m_FX->SetTechnique(mhTech),L"sky::sky: Failed to set sky technique: "); HR(m_FX->SetTexture(mhEnvMap, mEnvMap),L"sky::sky: Failed to set sky texture: "); }
TCHAR* PlatformString::toPlatformString() { #ifdef _UNICODE return toWideString(); #else return c_str(); #endif //_UNICODE }
static std::string getFullyQualifiedPathName(const std::string& filename) { const DWORD bufferSize = 0x200; wchar_t buffer[bufferSize]; GetFullPathNameW(toWideString(filename).c_str(), bufferSize, buffer, nullptr); return toUtf8(buffer); }
void hud::display() { // Make static so memory is not allocated every frame. // POTENTIAL FOR BUFFER OVERFLOW IF STRING IS MORE THAN 1023 CHARS LONG static char buffer[512]; sprintf(buffer, "Frames Per Second = %.2f\n" "Milliseconds Per Frame = %.4f\n" "Triangle Count = %d\n" "Vertex Count = %d\n\n" "Q,ESC -> quit\n" "WASD -> Move Camera\n" "shift -> Run\n" "C -> Convex Hull Rendering ON/OFF\n" "O -> OBBTree Rendering ON/OFF\n" "M -> Model Rendering ON/OFF\n" "P -> pause physics\n" "L -> Rendering to parent\n" "< -> Rendering to Left-Child\n" "> -> Rendering to Right-Child\n" "N -> Next OBB pair in OBBDebugMode\n" "F1 -> Fullscreen ON/OFF\n", mFPS, mMilliSecPerFrame, mNumTris, mNumVertices); RECT R = {5, 5, 0, 0}; HR(mFont->DrawText(0, toWideString(buffer,511).c_str(), -1, &R, DT_NOCLIP, D3DCOLOR_XRGB(0,0,0)),L"hud::display(): DrawText failed: "); }
bool Scope::execFile(const string& filename, bool printResult, bool reportError, int timeoutMs) { #ifdef _WIN32 boost::filesystem::path p(toWideString(filename.c_str())); #else boost::filesystem::path p(filename); #endif if (!exists(p)) { log() << "file [" << filename << "] doesn't exist" << endl; return false; } // iterate directories and recurse using all *.js files in the directory if (boost::filesystem::is_directory(p)) { boost::filesystem::directory_iterator end; bool empty = true; for (boost::filesystem::directory_iterator it (p); it != end; it++) { empty = false; boost::filesystem::path sub(*it); if (!endsWith(sub.string().c_str(), ".js")) continue; if (!execFile(sub.string(), printResult, reportError, timeoutMs)) return false; } if (empty) { log() << "directory [" << filename << "] doesn't have any *.js files" << endl; return false; } return true; } File f; f.open(filename.c_str(), true); fileofs fo = f.len(); if (fo > kMaxJsFileLength) { warning() << "attempted to execute javascript file larger than 2GB" << endl; return false; } unsigned len = static_cast<unsigned>(fo); boost::scoped_array<char> data (new char[len+1]); data[len] = 0; f.read(0, data.get(), len); int offset = 0; if (data[0] == '#' && data[1] == '!') { const char* newline = strchr(data.get(), '\n'); if (!newline) return true; // file of just shebang treated same as empty file offset = newline - data.get(); } StringData code(data.get() + offset, len - offset); return exec(code, filename, printResult, reportError, timeoutMs); }
void setCurrentUnits(std::string measureName, std::string units) { TMeasure *m = TMeasureManager::instance()->get(measureName); if (!m) return; TUnit *u = m->getUnit(toWideString(units)); if (!u) return; m->setCurrentUnit(u); }
std::wstring PlatformString::toUnicodeString() { std::wstring result; wchar_t* data = toWideString(); if (FLength != 0 && data != NULL) { // NOTE: Cleanup of result is handled by PlatformString destructor. result = data; } return result; }
void FileDialog::setPath(const FilePath &path) { if(path.isDirectory()) { m_dir_path = path; m_edit_box->setText(L""); } else { m_dir_path = path.parent(); m_edit_box->setText(toWideString(path.fileName())); } updateList(); updateButtons(); }
bool fileExists(const std::string& file) { try { #ifdef _WIN32 boost::filesystem::path p(toWideString(file.c_str())); #else boost::filesystem::path p(file); #endif return boost::filesystem::exists(p); } catch (...) { return false; } }
/** Set process wide current working directory. */ BSONObj cd(const BSONObj& args, void* data) { #if defined(_WIN32) std::wstring dir = toWideString( args.firstElement().String().c_str() ); if( SetCurrentDirectory(dir.c_str()) ) return BSONObj(); #else string dir = args.firstElement().String(); if( chdir( dir.c_str() ) == 0 ) return BSONObj(); #endif return BSON( "" << "change directory failed" ); }
intmax_t File::freeSpace(const std::string& path) { ULARGE_INTEGER avail; if (GetDiskFreeSpaceExW(toWideString(path.c_str()).c_str(), &avail, // bytes available to caller NULL, // ptr to returned total size NULL)) { // ptr to returned total free return avail.QuadPart; } DWORD dosError = GetLastError(); log() << "In File::freeSpace(), GetDiskFreeSpaceEx for '" << path << "' failed with " << errnoWithDescription(dosError) << std::endl; return -1; }
BSONObj cd(const BSONObj& args) { #if defined(_WIN32) std::wstring dir = toWideString( args.firstElement().String().c_str() ); if( SetCurrentDirectory(dir.c_str()) ) return BSONObj(); #else string dir = args.firstElement().String(); /* if( chdir(dir.c_str) ) == 0 ) return BSONObj(); */ if( 1 ) return BSON(""<<"implementation not done for posix"); #endif return BSON( "" << "change directory failed" ); }
int main( int argc, char *argv[] ) { // check to see if we have a federate name std::wstring federateName = L"exampleFederate"; if( argc > 1 ) federateName = toWideString( std::string(argv[1]) ); // create and run the federate ExampleCPPFederate *federate; federate = new ExampleCPPFederate(); federate->runFederate( federateName ); // clean up delete federate; return 0; }
QMap<std::wstring, bool> AviCodecRestrictions::getUsableCodecs(const TDimension &resolution) { QMap<std::wstring, bool> codecs; HIC hic = 0; ICINFO icinfo; memset(&icinfo, 0, sizeof(ICINFO)); char descr[2048], name[2048]; DWORD fccType = 0; BITMAPINFO inFmt; memset(&inFmt, 0, sizeof(BITMAPINFO)); inFmt.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); inFmt.bmiHeader.biWidth = inFmt.bmiHeader.biHeight = 100; inFmt.bmiHeader.biPlanes = 1; inFmt.bmiHeader.biCompression = BI_RGB; int bpp; for (bpp = 32; (bpp >= 24); bpp -= 8) { //find the codec. inFmt.bmiHeader.biBitCount = bpp; for (int i = 0; ICInfo(fccType, i, &icinfo); i++) { hic = ICOpen(icinfo.fccType, icinfo.fccHandler, ICMODE_COMPRESS); ICGetInfo(hic, &icinfo, sizeof(ICINFO)); // Find out the compressor name WideCharToMultiByte(CP_ACP, 0, icinfo.szDescription, -1, descr, sizeof(descr), 0, 0); WideCharToMultiByte(CP_ACP, 0, icinfo.szName, -1, name, sizeof(name), 0, 0); std::wstring compressorName; compressorName = toWideString(std::string(name) + " '" + toString(bpp) + "' " + std::string(descr)); if (hic) { if (ICCompressQuery(hic, &inFmt, NULL) != ICERR_OK) { ICClose(hic); continue; // Skip this compressor if it can't handle the format. } codecs[compressorName] = canWork(hic, resolution, bpp); ICClose(hic); } } } return codecs; }
void configSave() { wchar_t iniPath[MAX_PATH]; std::wstring ws; getIniFilePath(iniPath, MAX_PATH); // Completely delete the file DeleteFile(iniPath); // [DoxyIt] WritePrivateProfileString(NPP_PLUGIN_NAME, TEXT("active_commenting"), BOOLTOSTR(do_active_commenting), iniPath); WritePrivateProfileString(NPP_PLUGIN_NAME, TEXT("version"), VERSION_LINEAR_TEXT, iniPath); WritePrivateProfileString(NPP_PLUGIN_NAME, TEXT("version_stage"), VERSION_STAGE, iniPath); for(auto const &p : parsers) { const ParserSettings *ps = &(p.ps); // Wrap everything in quotes to preserve whitespace ws = TEXT("\"") + toWideString(ps->doc_start) + TEXT("\""); WritePrivateProfileString(p.lang.c_str(), TEXT("doc_start"), ws.c_str(), iniPath); ws = TEXT("\"") + toWideString(ps->doc_line) + TEXT("\""); WritePrivateProfileString(p.lang.c_str(), TEXT("doc_line_"), ws.c_str(), iniPath); ws = TEXT("\"") + toWideString(ps->doc_end) + TEXT("\""); WritePrivateProfileString(p.lang.c_str(), TEXT("doc_end__"), ws.c_str(), iniPath); ws = TEXT("\"") + toWideString(ps->command_prefix) + TEXT("\""); WritePrivateProfileString(p.lang.c_str(), TEXT("command_prefix"), ws.c_str(), iniPath); // Encode \r\n as literal "\r\n" in the ini file ws = TEXT("\"") + toWideString(stringReplace(std::string(ps->file_format), "\r\n", "\\r\\n")) + TEXT("\""); WritePrivateProfileString(p.lang.c_str(), TEXT("file_format"), ws.c_str(), iniPath); // Encode \r\n as literal "\r\n" in the ini file ws = TEXT("\"") + toWideString(stringReplace(std::string(ps->function_format), "\r\n", "\\r\\n")) + TEXT("\""); WritePrivateProfileString(p.lang.c_str(), TEXT("function_format"), ws.c_str(), iniPath); // Write out interal parser attributes if(!p.external) { WritePrivateProfileString(p.lang.c_str(), TEXT("align"), BOOLTOSTR(ps->align), iniPath); } else // add it to the list of external settings { WritePrivateProfileString(TEXT("External"), p.language_name.c_str(), TEXT(""), iniPath); } } }
void hud::RenderProgressText(int curObbox, int totalObboxes ) { // Make static so memory is not allocated every frame. // POTENTIAL FOR BUFFER OVERFLOW static char buffer[256]; sprintf(buffer, "Rebuilding ObbTree, node %d of %d\n",curObbox,totalObboxes); HR(g_app->m_pD3DDev->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0),L"renderer::drawShadowMap: Failed to clear device: "); HR(g_app->m_pD3DDev->BeginScene(),L"renderer::RenderFrame: BeginScene failed: "); // DRAW ALL OBJECTS HERE RECT R = {5, 5, 0, 0}; HR(mFont->DrawText(0, toWideString(buffer,255).c_str(), -1, &R, DT_NOCLIP, D3DCOLOR_XRGB(0,0,0)),L"hud::display(): DrawText failed: "); // FINISH DRAWING OBJECTS HERE HR(g_app->m_pD3DDev->EndScene(),L"renderer::RenderFrame: EndScene failed: "); // Present the backbuffer. HR(g_app->m_pD3DDev->Present(0, 0, 0, 0),L"renderer::RenderFrame: Present failed: "); }
/** Set process wide current working directory. */ BSONObj cd(const BSONObj& args, void* data) { uassert(16830, "cd requires one argument -- cd(directory)", args.nFields() == 1); uassert(16831, "cd requires a string argument -- cd(directory)", args.firstElement().type() == String); #if defined(_WIN32) std::wstring dir = toWideString(args.firstElement().String().c_str()); if (SetCurrentDirectoryW(dir.c_str())) { return BSONObj(); } #else std::string dir = args.firstElement().String(); if (chdir(dir.c_str()) == 0) { return BSONObj(); } #endif uasserted(16832, mongoutils::str::stream() << "cd command failed: " << errnoWithDescription()); return BSONObj(); }
void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) { verify( fd == 0 && len == 0 ); // can't open more than once setFilename(filenameIn); FileAllocator::get()->allocateAsap( filenameIn, length ); /* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */ char filename[256]; strncpy(filename, filenameIn, 255); filename[255] = 0; { size_t len = strlen( filename ); for ( size_t i=len-1; i>=0; i-- ) { if ( filename[i] == '/' || filename[i] == '\\' ) break; if ( filename[i] == ':' ) filename[i] = '_'; } } updateLength( filename, length ); { DWORD createOptions = FILE_ATTRIBUTE_NORMAL; if ( options & SEQUENTIAL ) createOptions |= FILE_FLAG_SEQUENTIAL_SCAN; DWORD rw = GENERIC_READ | GENERIC_WRITE; fd = CreateFileW( toWideString(filename).c_str(), rw, // desired access FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode NULL, // security OPEN_ALWAYS, // create disposition createOptions , // flags NULL); // hTempl if ( fd == INVALID_HANDLE_VALUE ) { DWORD dosError = GetLastError(); log() << "CreateFileW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; return 0; } } mapped += length; { DWORD flProtect = PAGE_READWRITE; //(options & READONLY)?PAGE_READONLY:PAGE_READWRITE; maphandle = CreateFileMappingW(fd, NULL, flProtect, length >> 32 /*maxsizehigh*/, (unsigned) length /*maxsizelow*/, NULL/*lpName*/); if ( maphandle == NULL ) { DWORD dosError = GetLastError(); log() << "CreateFileMappingW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed( 16225 ); } } void *view = 0; { scoped_lock lk(mapViewMutex); DWORD access = ( options & READONLY ) ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS; LPVOID thisAddress = getNextMemoryMappedFileLocation( length ); view = MapViewOfFileEx( maphandle, // file mapping handle access, // access 0, 0, // file offset, high and low 0, // bytes to map, 0 == all thisAddress ); // address to place file if ( view == 0 ) { DWORD dosError = GetLastError(); log() << "MapViewOfFileEx for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed( 16166 ); } } views.push_back(view); memconcept::is(view, memconcept::concept::memorymappedfile, this->filename(), (unsigned) length); len = length; return view; }
//!Specialized render invocation for multimedia rendering. Flash rendering //!is currently not supported in this mode. void RenderCommand::multimediaRender() { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); string ext = m_fp.getType(); #ifdef WIN32 if (ext == "avi") { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); MsgBox(WARNING, msg); return; } } #endif; TOutputProperties *prop = scene->getProperties()->getOutputProperties(); //Build thread count int index = prop->getThreadIndex(); const int procCount = TSystem::getProcessorCount(); const int threadCounts[3] = {1, procCount / 2, procCount}; int threadCount = threadCounts[index]; //Build raster granularity size index = prop->getMaxTileSizeIndex(); const int maxTileSizes[4] = { (std::numeric_limits<int>::max)(), TOutputProperties::LargeVal, TOutputProperties::MediumVal, TOutputProperties::SmallVal}; TRenderSettings rs = prop->getRenderSettings(); rs.m_maxTileSize = maxTileSizes[index]; MultimediaRenderer multimediaRenderer(scene, m_fp, prop->getMultimediaRendering(), threadCount); multimediaRenderer.setRenderSettings(rs); #ifdef BRAVODEMO rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes()); #endif TPointD cameraDpi = scene->getCurrentCamera()->getDpi(); multimediaRenderer.setDpi(cameraDpi.x, cameraDpi.y); multimediaRenderer.enablePrecomputing(true); for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) multimediaRenderer.addFrame(m_r); MultimediaProgressBar *listener = new MultimediaProgressBar(&multimediaRenderer); QObject::connect(listener, SIGNAL(canceled()), &multimediaRenderer, SLOT(onCanceled())); multimediaRenderer.addListener(listener); multimediaRenderer.start(); }
void RenderCommand::rasterRender(bool isPreview) { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); if (isPreview) { //Let the PreviewFxManager own the rest. Just pass him the current output node. PreviewFxManager::instance()->showNewPreview((TFx *)scene->getXsheet()->getFxDag()->getCurrentOutputFx()); return; } string ext = m_fp.getType(); #ifdef WIN32 if (ext == "avi" && !isPreview) { TPropertyGroup *props = scene->getProperties()->getOutputProperties()->getFileFormatProperties(ext); string codecName = props->getProperty(0)->getValueAsString(); TDimension res = scene->getCurrentCamera()->getRes(); if (!AviCodecRestrictions::canWriteMovie(toWideString(codecName), res)) { QString msg(QObject::tr("The resolution of the output camera does not fit with the options chosen for the output file format.")); MsgBox(WARNING, msg); return; } } #endif; //Extract output properties TOutputProperties *prop = isPreview ? scene->getProperties()->getPreviewProperties() : scene->getProperties()->getOutputProperties(); //Build thread count /*-- Dedicated CPUs のコンボボックス (Single, Half, All) --*/ int index = prop->getThreadIndex(); const int procCount = TSystem::getProcessorCount(); const int threadCounts[3] = {1, procCount / 2, procCount}; int threadCount = threadCounts[index]; /*-- MovieRendererを作る。Previewの場合はファイルパスは空 --*/ MovieRenderer movieRenderer(scene, isPreview ? TFilePath() : m_fp, threadCount, isPreview); TRenderSettings rs = prop->getRenderSettings(); //Build raster granularity size index = prop->getMaxTileSizeIndex(); const int maxTileSizes[4] = { (std::numeric_limits<int>::max)(), TOutputProperties::LargeVal, TOutputProperties::MediumVal, TOutputProperties::SmallVal}; rs.m_maxTileSize = maxTileSizes[index]; //Build #ifdef BRAVODEMO rs.m_mark = loadBravo(scene->getCurrentCamera()->getRes()); #endif /*-- RenderSettingsをセット --*/ movieRenderer.setRenderSettings(rs); /*-- カメラDPIの取得、セット --*/ TPointD cameraDpi = isPreview ? scene->getCurrentPreviewCamera()->getDpi() : scene->getCurrentCamera()->getDpi(); movieRenderer.setDpi(cameraDpi.x, cameraDpi.y); movieRenderer.enablePrecomputing(true); /*-- プログレス ダイアログの作成 --*/ RenderListener *listener = new RenderListener(movieRenderer.getTRenderer(), m_fp, ((m_numFrames - 1) / m_step) + 1, isPreview); QObject::connect(listener, SIGNAL(canceled()), &movieRenderer, SLOT(onCanceled())); movieRenderer.addListener(listener); bool fieldRendering = rs.m_fieldPrevalence != TRenderSettings::NoField; /*-- buildSceneFxの進行状況を表示するプログレスバー --*/ QProgressBar *buildSceneProgressBar = new QProgressBar(TApp::instance()->getMainWindow()); buildSceneProgressBar->setAttribute(Qt::WA_DeleteOnClose); buildSceneProgressBar->setWindowFlags(Qt::SubWindow | Qt::Dialog | Qt::WindowStaysOnTopHint); buildSceneProgressBar->setMinimum(0); buildSceneProgressBar->setMaximum(m_numFrames - 1); buildSceneProgressBar->setValue(0); buildSceneProgressBar->move(600, 500); buildSceneProgressBar->setWindowTitle("Building Schematic..."); buildSceneProgressBar->show(); for (int i = 0; i < m_numFrames; ++i, m_r += m_stepd) { buildSceneProgressBar->setValue(i); if (rs.m_stereoscopic) scene->shiftCameraX(-rs.m_stereoscopicShift / 2); TFxPair fx; fx.m_frameA = buildSceneFx(scene, m_r, rs.m_shrinkX, isPreview); if (fieldRendering && !isPreview) fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); else if (rs.m_stereoscopic) { scene->shiftCameraX(rs.m_stereoscopicShift); fx.m_frameB = buildSceneFx(scene, m_r + 0.5 / m_timeStretchFactor, rs.m_shrinkX, isPreview); scene->shiftCameraX(-rs.m_stereoscopicShift / 2); } else fx.m_frameB = TRasterFxP(); /*-- movieRendererにフレーム毎のFxを登録 --*/ movieRenderer.addFrame(m_r, fx); } /*-- プログレスバーを閉じる --*/ buildSceneProgressBar->close(); //resetViewer(); //TODO cancella le immagini dell'eventuale render precedente //FileViewerPopupPool::instance()->getCurrent()->onClose(); movieRenderer.start(); }
String::operator std::wstring() const { return toWideString(); }
void CasmSubmitPage::Data::submit() { if (m_filepathTextField->getText() == toWideString("")) { TMessage::error("You must load a file"); return; } CasmTask *casm = m_configPanel->getTask(); TFarmController *controller = Application::instance()->getController(); string nativeCmdLine("runcasm "); nativeCmdLine += casm->m_casmFile; nativeCmdLine += " "; if (casm->m_setupFile != "") { nativeCmdLine += "-setup "; nativeCmdLine += casm->m_setupFile; nativeCmdLine += " "; } nativeCmdLine += casm->getCommandLine(); string casmName = TFilePath(casm->m_casmFile).getName(); int stepCount = casm->m_end - casm->m_start + 1; TFarmTaskGroup task( casmName, nativeCmdLine, TSystem::getUserName(), TSystem::getHostName(), stepCount); int ra = casm->m_start; for (;;) { CasmTask subcasm(*casm); string cmdLine("runcasm "); int rb = tmin(ra + casm->m_taskChunksize - 1, casm->m_end); subcasm.m_start = ra; subcasm.m_end = rb; cmdLine += subcasm.m_casmFile; cmdLine += " "; if (subcasm.m_setupFile != "") { cmdLine += "-setup "; cmdLine += subcasm.m_setupFile; cmdLine += " "; } cmdLine += subcasm.getCommandLine(); cmdLine += " -nowait "; try { string name = casmName + " " + toString(ra) + "-" + toString(rb); stepCount = rb - ra + 1; task.addTask(new TFarmTask( name, cmdLine, TSystem::getUserName(), TSystem::getHostName(), stepCount)); } catch (TException &e) { TMessage::error(toString(e.getMessage())); } if (rb == casm->m_end) break; ra = rb + 1; } try { controller->addTask(task, m_submitAsSuspended->isSelected()); } catch (TException &e) { TMessage::error(toString(e.getMessage())); } }
String NativeString::toUtf8String() const { return StringUtils::wideString2utf8String(toWideString()); }
void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) { verify( fd == 0 && len == 0 ); // can't open more than once setFilename(filenameIn); FileAllocator::get()->allocateAsap( filenameIn, length ); /* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */ char filename[256]; strncpy(filename, filenameIn, 255); filename[255] = 0; { size_t len = strlen( filename ); for ( size_t i=len-1; i>=0; i-- ) { if ( filename[i] == '/' || filename[i] == '\\' ) break; if ( filename[i] == ':' ) filename[i] = '_'; } } updateLength( filename, length ); { DWORD createOptions = FILE_ATTRIBUTE_NORMAL; if ( options & SEQUENTIAL ) createOptions |= FILE_FLAG_SEQUENTIAL_SCAN; DWORD rw = GENERIC_READ | GENERIC_WRITE; fd = CreateFileW( toWideString(filename).c_str(), rw, // desired access FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode NULL, // security OPEN_ALWAYS, // create disposition createOptions , // flags NULL); // hTempl if ( fd == INVALID_HANDLE_VALUE ) { DWORD dosError = GetLastError(); log() << "CreateFileW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; return 0; } } mapped += length; { DWORD flProtect = PAGE_READWRITE; //(options & READONLY)?PAGE_READONLY:PAGE_READWRITE; maphandle = CreateFileMappingW(fd, NULL, flProtect, length >> 32 /*maxsizehigh*/, (unsigned) length /*maxsizelow*/, NULL/*lpName*/); if ( maphandle == NULL ) { DWORD dosError = GetLastError(); log() << "CreateFileMappingW for " << filename << " failed with " << errnoWithDescription( dosError ) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed( 16225 ); } } void *view = 0; { stdx::lock_guard<stdx::mutex> lk(mapViewMutex); DWORD access = ( options & READONLY ) ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS; int current_retry = 0; while (true) { LPVOID thisAddress = getNextMemoryMappedFileLocation(length); view = MapViewOfFileEx( maphandle, // file mapping handle access, // access 0, 0, // file offset, high and low 0, // bytes to map, 0 == all thisAddress); // address to place file if (view == 0) { DWORD dosError = GetLastError(); ++current_retry; // If we failed to allocate a memory mapped file, try again in case we picked // an address that Windows is also trying to use for some other VM allocations if (dosError == ERROR_INVALID_ADDRESS && current_retry < 5) { continue; } #ifndef _WIN64 // Warn user that if they are running a 32-bit app on 64-bit Windows if (dosError == ERROR_NOT_ENOUGH_MEMORY) { BOOL wow64Process; BOOL retWow64 = IsWow64Process(GetCurrentProcess(), &wow64Process); if (retWow64 && wow64Process) { log() << "This is a 32-bit MongoDB binary running on a 64-bit" " operating system that has run out of virtual memory for" " databases. Switch to a 64-bit build of MongoDB to open" " the databases."; } } #endif log() << "MapViewOfFileEx for " << filename << " at address " << thisAddress << " failed with " << errnoWithDescription(dosError) << " (file size is " << length << ")" << " in MemoryMappedFile::map" << endl; close(); fassertFailed(16166); } break; } } views.push_back(view); len = length; return view; }
TTextData::TTextData(std::string text) : m_text(toWideString(text)) { }
void visitAtoms(const QTAtomContainer &atoms, const QTAtom &parent, TPropertyGroup &pg) { QTAtom curr = 0; do { if (QTNextChildAnyType(atoms, parent, curr, &curr) != noErr) assert(false); if (curr == 0) break; QTAtomType atomType; QTAtomID id; QTGetAtomTypeAndID(atoms, curr, &atomType, &id); int sonCount = QTCountChildrenOfType(atoms, curr, 0); char buffer[1024]; sprintf(buffer, "%d %d %d", (int)atomType, (int)id, sonCount); string str(buffer); if (sonCount > 0) { pg.add(new TStringProperty(str, TString())); visitAtoms(atoms, curr, pg); } else { long size; UCHAR *atomData; if (QTGetAtomDataPtr(atoms, curr, &size, (char **)&atomData) != noErr) assert(false); string strapp; for (int i = 0; i < size; i++) { string num; if (atomData[i] == 0) { int count = 1; while ((i + 1) < size && atomData[i + 1] == 0) i++, count++; if (count > 1) { num = toString(count); strapp = strapp + "z " + num + " "; continue; } } num = toString(atomData[i]); strapp = strapp + string(num) + " "; } //unsigned short*buffer = new unsigned short[size]; //buffer[size]=0; //for (i=0; i<size; i++) // buffer[i] = atomData[i]+1; wstring data = toWideString(strapp); pg.add(new TStringProperty(str, data)); } } while (curr != 0); }