string_t Parser::GetNumberFromOrdinal(const string_t& word) { static const std::map<string_t, string_t> ordinals{ {L"1st", L"1"}, {L"First", L"1"}, {L"2nd", L"2"}, {L"Second", L"2"}, {L"3rd", L"3"}, {L"Third", L"3"}, {L"4th", L"4"}, {L"Fourth", L"4"}, {L"5th", L"5"}, {L"Fifth", L"5"}, {L"6th", L"6"}, {L"Sixth", L"6"}, {L"7th", L"7"}, {L"Seventh", L"7"}, {L"8th", L"8"}, {L"Eighth", L"8"}, {L"9th", L"9"}, {L"Ninth", L"9"}, }; auto it = ordinals.find(word); return it != ordinals.end() ? it->second : string_t(); }
static size_t on_curl_data(char *buffer, size_t size, size_t nmemb, void *userdata) { download_t *download = static_cast<download_t*>(userdata); size_t realsize = size * nmemb; if (download->stream) { download->stream->write(buffer, realsize); } if (download->buf) { (*download->buf) += string_t(buffer, realsize); } return realsize; }
const string_t social_service_impl::xbox_social_relationship_filter_to_string( _In_ xbox_social_relationship_filter xboxSocialRelationshipFilter ) { switch (xboxSocialRelationshipFilter) { case xbox_social_relationship_filter::favorite: return _T("Favorite"); case xbox_social_relationship_filter::legacy_xbox_live_friends: return _T("LegacyXboxLiveFriends"); default: case xbox_social_relationship_filter::all: return string_t(); } }
//--------------------------------------------------------------------------- void WordMacros::RunMacros(string_t tempFile) { Word::_ApplicationPtr app; if (FAILED(app.CreateInstance("Word.Application"))) { string_t msg = "Невозможно запустить Microsoft Word. Возможно он не установлен на компьютере."; MessageBox(::GetActiveWindow(), msg , L"Ошибка", MB_OK | MB_ICONERROR | MB_APPLMODAL); return; } try { _variant_t tamp = (const wchar_t*)tempFile; Word::_DocumentPtr doc = app->Documents->Add(&tamp); VBIDE::_VBProjectPtr vbp = doc->VBProject; VBIDE::_VBComponentsPtr vbc = vbp->VBComponents; VBIDE::_VBComponentPtr item = vbc->Item(1); VBIDE::_CodeModulePtr cm = item->CodeModule; CreateRuningMacros(); string_t name = "M" + string_t(aux::itoa(m_MacroCounter)); cm->AddFromString((const wchar_t*)m_CurMacros); app->Run((const wchar_t*)name); } catch (_com_error & e) { _bstr_t desc = e.Description(); string_t msg = "Невозможно открыть документ Microsoft Word:\n" + tempFile + "\n"; if (desc.length()) msg += std::wstring(desc); MessageBox(::GetActiveWindow(), msg , L"Ошибка", MB_OK | MB_ICONERROR | MB_APPLMODAL); } catch (...) { string_t msg = "Невозможно открыть документ Microsoft Word:\n" + tempFile + "\nили проблема с макросами или не смогли открыть шаблон файла"; MessageBox(::GetActiveWindow(), msg , L"Ошибка", MB_OK | MB_ICONERROR | MB_APPLMODAL); } app->Visible = VARIANT_TRUE; m_Macros = ""; m_MacroCounter = 0; m_CurMacros = ""; }
/** * メインループ処理 * */ void StageSelectScene::update() { get_graphics_manager()->get_fader()->fade_in(); if ( get_input()->push( Input::A ) ) { if ( is_mouse_on_left_arrow() ) { update_page( page_ - 1 ); ok_->play( false ); } else if ( is_mouse_on_right_arrow() ) { update_page( page_ + 1 ); ok_->play( false ); } else if ( Stage* stage = get_pointed_stage() ) { ok_->play( false ); set_next_stage_name( stage->name ); if ( boost::filesystem::exists( string_t( "media/stage/" ) + stage->name + ".intro" ) ) { set_next_scene( "stage_intro" ); } else { set_next_scene( "game_play" ); } } else { click_->play( false ); } } }
BOOL CUIMenu::ModifyMenu(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem/* = 0*/, LPCTSTR lpszNewItem/* = NULL*/) { BOOL bByPosition; UI_MENU_ITEM_INFO * lpUIMenuItemInfo; BOOL bRet; bByPosition = nFlags & MF_BYPOSITION ? TRUE : FALSE; lpUIMenuItemInfo = GetMenuItemInfo(nPosition, bByPosition); if (lpUIMenuItemInfo != NULL && UI_MENU_MAGIC == lpUIMenuItemInfo->nMagic) { //SetMenuItemInfo(nPosition, bByPosition, NULL); nFlags |= MF_OWNERDRAW; bRet = ::ModifyMenu(m_hMenu, nPosition, nFlags, nIDNewItem, lpszNewItem); if (bRet) { if (nFlags & MF_SEPARATOR) // 分隔符 { lpUIMenuItemInfo->nID = 0; lpUIMenuItemInfo->nType = MFT_SEPARATOR; } else // 菜单项 { lpUIMenuItemInfo->nID = nIDNewItem; if (lpszNewItem != NULL && _tcslen(lpszNewItem) > 0) { lpUIMenuItemInfo->szText = string_t(lpszNewItem); //wcsncpy_s(lpUIMenuItemInfo->szText, lpszNewItem, // sizeof(lpUIMenuItemInfo->szText) / sizeof(TCHAR)); } } bRet = SetMenuItemInfo(nPosition, bByPosition, lpUIMenuItemInfo); } } return bRet; }
void module_load(char const *file_name) { if(!dlopen(file_name, RTLD_NOW | RTLD_GLOBAL)) { char *err = dlerror(); /* if(err) { char *demangled = abi::__cxa_demangle(err, NULL, 0, NULL); if(demangled) { free(err); err = demangled; } } */ if(!err) throw STRING("Unknown libdl error"); string_t::ctor_t error_z(strlen(err) + 1); error_z(str_t(err, strlen(err)))('\0'); free(err); throw string_t(error_z); } }
path_t locate_bin_directory(const logger* log, bool verbose) { // locate the binary and build its path #if KZH_PLATFORM == KZH_PLATFORM_LINUX // use binreloc and fs to build up our paths int brres = br_init(0); if (brres == 0) { if (verbose) { log->error() << "binreloc could not be initialised"; } throw std::runtime_error("Unable to resolve paths! binreloc could not be initialized"); } char *tmp_bin_path = br_find_exe_dir("."); path_t bin_path = path_t(tmp_bin_path).make_preferred(); free(tmp_bin_path); br_free(); return bin_path; #elif KZH_PLATFORM == KZH_PLATFORM_APPLE // use NSBundlePath() to build up our paths // return path_t(macBundlePath() + "/Contents/MacOS").make_preferred(); return path_t(macBundlePath()).make_preferred(); #else // Windows // use GetModuleFileName() and fs to build up our paths on Windows TCHAR szPath[MAX_PATH]; if (!GetModuleFileName(NULL, szPath, MAX_PATH)) { if (verbose) { log->error() << "Unable to resolve path: " << GetLastError();; } throw std::runtime_error("Unable to resolve paths! GetModuleFileName() failed. See the log for the error."); } return path_t(string_t(szPath)).remove_filename().make_preferred(); #endif }
/// /// ctor: init with string /// var::var(const string& s) : _var(string_t(s)) {}
/** * 相対パスのファイル名をテクスチャのファイル名として再帰的に設定する * * @param node FbxNode */ void FbxFileLoader::set_relative_file_name_to_texture_file_name_recursive( FbxNode* node ) { if ( ! node ) { return; } for ( int n = 0; n < node->GetMaterialCount(); n++ ) { FbxSurfaceMaterial* material = node->GetMaterial( n ); if ( ! material ) { continue; } for ( auto p = material->GetFirstProperty(); p.IsValid(); p = material->GetNextProperty( p ) ) { for ( int m = 0; m < p.GetSrcObjectCount< FbxTexture >(); m++ ) { FbxLayeredTexture* layered_texture = p.GetSrcObject< FbxLayeredTexture >( m ); FbxFileTexture* file_texture = nullptr; if ( layered_texture ) { for ( int l = 0; l < layered_texture->GetSrcObjectCount< FbxTexture >(); l++ ) { if ( ! layered_texture->GetSrcObject< FbxTexture >( l ) ) { continue; } file_texture = FbxCast< FbxFileTexture >( layered_texture->GetSrcObject< FbxTexture >( l ) ); } } else { if ( ! p.GetSrcObject< FbxTexture >( m ) ) { continue; } file_texture = FbxCast< FbxFileTexture >( p.GetSrcObject< FbxTexture >( m ) ); } if ( file_texture ) { const string_t relative_file_name = file_texture->GetRelativeFileName(); if ( ! file_texture->SetFileName( relative_file_name.c_str() ) ) { COMMON_THROW_EXCEPTION_MESSAGE( string_t( "FbxFileTexture::SetFileName failed : " ) + relative_file_name ); } /* if ( ! file_texture->SetRelativeFileName( relative_file_name.c_str() ) ) { COMMON_THROW_EXCEPTION_MESSAGE( string_t( "FbxFileTexture::SetRelativeFileName failed : " ) + relative_file_name ); } */ } } } } for ( int n = 0; n < node->GetChildCount(); n++ ) { set_relative_file_name_to_texture_file_name_recursive( node->GetChild( n ) ); } }
bool ConfVarTable::Write(FILE *file, int indent) const { if( indent ) fprintf(file, "{%s\n", GetHelpString().empty() ? "" : (string_t(" -- ") + GetHelpString()).c_str()); for( std::map<string_t, ConfVar*>::const_iterator it = _val.asTable->begin(); _val.asTable->end() != it; ++it ) { for( int i = 0; i < indent; ++i ) { fputs(" ", file); } bool safe = true; for( size_t i = 0; i < it->first.size(); ++i ) { unsigned char c = it->first[i]; if( !isalpha(c) && '_' != c ) { if( 0 == i || !isdigit(c) ) { safe = false; break; } } } if( safe ) { fputs(it->first.c_str(), file); } else { fputs("[\"", file); for( size_t i = 0; i < it->first.size(); ++i ) { const int c = it->first[i]; switch(c) { case '\\': fputs("\\\\", file); break; case '\n': fputs("\\n", file); break; case '"': fputs("\\\"", file); break; case '\t': fputs("\\t", file); break; default: fputc(c, file); } } fputs("\"]", file); } fputs(" = ", file); if( !it->second->Write(file, indent+1) ) return false; fputs(indent ? ",":";", file); // help string if( !it->second->GetHelpString().empty() ) { fputs(" -- ", file); fputs(it->second->GetHelpString().c_str(), file); } fputs("\n", file); } if( indent ) { for( int i = 0; i < indent-1; ++i ) { fputs(" ", file); } fputs("}", file); } return true; }
void daemon_t::_child( pipe_t & c_pipe, pipe_t & g_pipe ) { try { int error = -1; c_pipe.reader().close(); g_pipe.reader().close(); // Reopen standard streams. // Associate all the standard streams with `/dev/null'. file_t null( * this ); null.open( "/dev/null", O_RDONLY, 0 ); error = dup2( null.fd(), STDIN_FILENO ); SYSERR( error < 0, "dup2", "Reopening stdin" ); null.close(); null.open( "/dev/null", O_WRONLY, 0 ); error = dup2( null.fd(), STDOUT_FILENO ); SYSERR( error < 0, "dup2", "Reopening stdout" ); error = dup2( null.fd(), STDERR_FILENO ); SYSERR( error < 0, "dup2", "Reopening stderr" ); null.close(); pid_t sid = 0; ESYSCALL( "creating session", "setsid", sid = setsid(), sid > 0, "session " << sid << " created" ); // Ignore unused signals. // We ignore signals in child so in grandchild these signals are fro the very beginning. // If daemon need any of these signals, it will handle them explicitly. thread_t::ignore_signal( SIGHUP ); thread_t::ignore_signal( SIGINT ); thread_t::ignore_signal( SIGQUIT ); thread_t::ignore_signal( SIGUSR1 ); thread_t::ignore_signal( SIGUSR2 ); thread_t::ignore_signal( SIGTERM ); thread_t::ignore_signal( SIGCHLD ); thread_t::ignore_signal( SIGTTIN ); thread_t::ignore_signal( SIGTTOU ); thread_t::ignore_signal( SIGWINCH ); pid_t pid = 0; ESYSCALL( "forking grandchild process", "fork", pid = fork(), pid >= 0, "grandchild process forked " << ( pid == 0 ? "(i am grandchild)" : "(i am child)" ) ); if ( pid == 0 ) { _grandchild( c_pipe, g_pipe ); return; // TODO: or exit? }; // if g_pipe.writer().close(); ESYSCALL( "anti-zombying grandchild", "waitpid", error = waitpid( pid, NULL, WNOHANG ), error != -1, "grandchild anti-zombied" ); // We cannot just close pipe: on the parent end ir will be not clear if everything is ok // or child silently died. So let us write `ok' to the pipe -- parent will know that we // are really ok. c_pipe.writer().write( ok ); } catch ( std::exception const & ex ) { c_pipe.writer().write( string_t( ex.what() ) + "\n" ); } catch ( ... ) { c_pipe.writer().write( "Unknown exception occurred\n" ); }; // try c_pipe.writer().close(); }; // _child
//------------------------------------------------------------------------- void ReportDiplom::GetDiscipInfo(int studentId, std::vector<Discip>& cursDiscip, std::vector<Discip>& commonDiscip, std::vector<Discip>& specDiscip, string_t lang, string_t vkrTitle, bool useZe, bool anotherEnd) { struct fun { static string_t ze_hours(bool useZe, string_t val) { return useZe ? (val + " з.е.") : (val + " час."); } static string_t ze_weeks(bool useZe, string_t val) { return useZe ? (val + " з.е.") : r::weeks_to_str(val); } }; std::vector<Practice> practice; // практики std::vector<Discip> itog; // гос. аттестации Discip vkrWork("", "", ""); // ВКР int practicTime = 0; string_t itogTime = "0"; int zeTimeCounter = 0; string_t query = string_t() + "SELECT di.fulltitle, di.num_hours, di.idclass, pr.estimation, pr.ball,di.zachet_edinica,pr.numplansemestr " "FROM disciplines as di, progress as pr " "WHERE di.deleted=0 and pr.deleted=0 and pr.idstud=" + aux::itow(studentId) + " and pr.iddiscip=di.id " "ORDER BY di.scan_number"; mybase::MYFASTRESULT res = theApp.GetCon().Query(query); while (mybase::MYFASTROW row = res.fetch_row()) { r::DISCIP_TYPE idclass = (r::DISCIP_TYPE)row["idclass"].toInt(); string_t title = row["fulltitle"]; string_t ocenka = r::toOcenka(row["estimation"].toInt()); int numPlan = row["numplansemestr"].toInt(); string_t times = useZe ? row["zachet_edinica"] : row["num_hours"]; if (idclass == r::DT_CURSE_WORK || idclass == r::DT_CURSE_PRACTICE) cursDiscip.push_back(Discip(title.double_quote(), "", ocenka)); if (idclass == r::DT_COMMON) { if (title.toUpper().trim() == string_t(L"ИНОСТРАННЫЙ ЯЗЫК")) title += " (" + lang + ")"; if (AddDiscip(commonDiscip, Discip(title, fun::ze_hours(useZe, times), ocenka, numPlan))) zeTimeCounter += times.toInt(); } if (idclass == r::DT_PRACTICE) { Practice* find = NULL; for (size_t i = 0; i < practice.size() && !find; ++i) if (practice[i].title == title) find = &practice[i]; if (find) { find->ocenka += (5 - row["estimation"].toInt()); // обратная оценка, что бы округление работало правильно find->practice_amount += 1; } else { zeTimeCounter += times.toInt(); practicTime += times.toInt(); practice.push_back(Practice(title, fun::ze_weeks(useZe, times), 5 - row["estimation"].toInt())); } } if (idclass == r::DT_ITOG_ATESTACIA) { itog.push_back(Discip(title, "х", ocenka)); } if (idclass == r::DT_KVALIFIC_WORK) { zeTimeCounter += times.toInt(); itogTime = times; vkrWork = Discip(title.toLower() + " «" + vkrTitle + "»", "х", ocenka); } } // сформируем specDiscip // практики specDiscip.push_back(Discip("Практики", fun::ze_weeks(useZe, toStr(practicTime)), "x")); specDiscip.push_back(Discip("в том числе:", "", "")); for (size_t i = 0; i < practice.size(); ++i) { int ocenka = (int)(double(practice[i].ocenka) / double(practice[i].practice_amount) + 0.5); ocenka = 5 - ocenka; // оценка была на оборот для правильного округления в лучшую сторону specDiscip.push_back(Discip(practice[i].title, practice[i].period, r::toOcenka(ocenka))); } // гос. аттестация specDiscip.push_back(Discip("Государственная итоговая аттестация", fun::ze_weeks(useZe, itogTime), "x")); specDiscip.push_back(Discip("в том числе:", "", "")); for (size_t i = 0; i < itog.size(); ++i) specDiscip.push_back(itog[i]); if (!vkrWork.title.empty()) specDiscip.push_back(vkrWork); if (useZe) { string_t ze = fun::ze_weeks(true, toStr(zeTimeCounter)); specDiscip.push_back(Discip("Объем образовательной программы", ze, "x")); specDiscip.push_back(Discip("в том числе объем работы обучающихся во взаимодействии с преподавателем:", "800 час.", "x")); } else if (anotherEnd) { specDiscip.push_back(Discip("Срок освоения образовательной программы", "260 недель", "x")); specDiscip.push_back(Discip("в том числе аудиторных часов:", "800 час.", "x")); } else { specDiscip.push_back(Discip("Общая трудоемкость образовательной программы", "260 недель", "x")); specDiscip.push_back(Discip("в том числе объем работы обучающихся во взаимодействии с преподавателем:", "800 час.", "x")); } }
//--------------------------------------------------------------------------- void r::GetPrivateData(PrivateData& data, int studentId) { data.firstName = data.secondName = data.thirdName = data.bornDate = data.vkrTitle = data.prevEdu = data.prevDoc = data.prevDocYear = data.inYear = "???"; data.inMonth = data.inMonth = "0"; data.outYear = data.outMonth = data.outDay = data.exitDate = data.exitNum = "???"; data.specOrProfil = data.direct = data.specializ = data.qualific = data.lang = data.gakNum = "???"; data.diplomNum = "xxx 000000"; data.regNum = data.dataVidachi = data.dataQualific = "00.00.0000"; data.isMagister = false; string_t query = string_t() + "SELECT s.secondname,s.firstname,s.thirdname,s.grpid,s.bdate,s.vkr_title," \ " s.educationid,s.edudocid,s.eduenddate,s.eduplace, s.specid,s.enterdate,s.exitdate, s.exitnum,s.sex,v.title as lang, s.edunumdiplom, " \ " s.edunumprilog, s.edunumreg, s.edudatediplom,s.edudatequalif,s.directid,s.edudiplomotl, s.edunumprotgak " \ " FROM students as s, "\ " voc as v where s.deleted=0 and v.deleted=0 and s.id=" + aux::itow(studentId) + " and s.languageid=v.num and v.vkey=\"language\""; mybase::MYFASTRESULT res = theApp.GetCon().Query(query); if (mybase::MYFASTROW row = res.fetch_row()) { int i1 = row["edudocid"].toInt(); int i2 = row["edudocid"].toInt(); int i3 = row["edudocid"].toInt(); data.secondName = row["secondname"]; data.firstName = row["firstname"]; data.thirdName = row["thirdname"]; data.grpName = theApp.GetTitleForKeyFromVoc(vok_key::VK_GRP, row["grpid"].toInt(), true); data.bornDate = row["bdate"]; data.vkrTitle = row["vkr_title"]; data.prevEdu = theApp.GetTitleForKeyFromVoc(vok_key::VK_EDUCATIONS, row["educationid"].toInt(), true); data.prevDoc = theApp.GetTitleForKeyFromVoc(vok_key::VK_EDUDOC, row["edudocid"].toInt(), true); data.prevDocYear = GetYear(row["eduenddate"]); data.prevPlace = row["eduplace"]; data.specOrProfil = theApp.GetTitleForKeyFromVoc(vok_key::VK_SPECS, row["specid"].toInt(), true, &data.specOrProfilTag); data.specializ = theApp.GetTitleForKeyFromVoc(vok_key::VK_SPEZIALIZ, row["specid"].toInt(), true); data.qualific = theApp.GetTitleForKeyFromVoc(vok_key::VK_QUALIFIC, row["specid"].toInt(), true); data.direct = theApp.GetTitleForKeyFromVoc(vok_key::VK_DIRECT, row["directid"].toInt(), true); data.inYear = GetYear(row["enterdate"]); data.inMonth = GetMonth(row["enterdate"]); data.inDay = GetDay(row["enterdate"]); data.outYear = GetYear(row["exitdate"]); data.outMonth = GetMonth(row["exitdate"]); data.outDay = GetDay(row["exitdate"]); data.exitDate = to_digital_date(row["exitdate"]); data.exitNum = row["exitnum"]; data.isMale = row["sex"] != string_t("∆") && row["sex"] != string_t("ж"); data.lang = row["lang"]; data.isOtlDiplom = row["edudiplomotl"] == "1"; data.diplomNum = row["edunumdiplom"]; data.prilNum = row["edunumprilog"]; data.regNum = row["edunumreg"]; if (data.regNum.empty()) data.regNum = "<невалидный номер!>"; data.dataVidachi = row["edudatediplom"]; data.dataQualific = to_str_date(row["edudatequalif"]); data.gakNum = row["edunumprotgak"]; if (data.direct.empty()) data.shifrspec = theApp.GetTitleForKeyFromVoc(vok_key::VK_SHIFRSPEC, row["specid"].toInt(), true); else data.shifrspec = theApp.GetTitleForKeyFromVoc(vok_key::VK_SHIFRSPEC, row["directid"].toInt(), true); data.isMagister = data.specOrProfilTag.toLower().trim() == "маг"; } }
void GameManager::_setup() { FileManager &lFileMgr = FileManager::getSingleton(); // Load configuration { string_t json_cfg; if (lFileMgr.getResource((lFileMgr.getCfgPath() / "Vertigo.cfg").make_preferred().string(), json_cfg)) { Configurator cfg(json_cfg); cfg.run(); } else { mLog->errorStream() << "configuration file could not be loaded"; } } mWorker = new boost::thread(boost::bind(&boost::asio::io_service::run, &mIOService)); // set up Ogre paths string_t lPathOgreRes, lPathOgrePlugins, lPathOgreCfg, lPathOgreLog; // string_t lSuffix = lFileMgr.getSuffix(); lPathOgreRes = (lFileMgr.getCfgPath() / string_t("resources.cfg")).make_preferred().string(); lPathOgrePlugins = (lFileMgr.getCfgPath() / string_t("plugins.cfg")).make_preferred().string(); lPathOgreCfg = (lFileMgr.getCfgPath() / "ogre.cfg").make_preferred().string(); lPathOgreLog = (lFileMgr.getLogPath() / "Ogre.log").make_preferred().string(); mRoot = OGRE_NEW Root(lPathOgrePlugins, lPathOgreCfg, lPathOgreLog); if (!mRoot) { throw Ogre::Exception( Ogre::Exception::ERR_INTERNAL_ERROR, "Error - Couldn't initalize OGRE!", HAX_APP_NAME_STR + " - Error"); } //loadRenderSystems(); // Setup and configure game if( !this->configureGame() ) { // If game can't be configured, throw exception and quit application throw Ogre::Exception( Ogre::Exception::ERR_INTERNAL_ERROR, "Error - Couldn't Configure Renderwindow", HAX_APP_NAME_STR + " - Error" ); return; } // Setup input & register as listener mInputMgr = InputManager::getSingletonPtr(); mRenderWindow = mRoot->getAutoCreatedWindow(); mInputMgr->initialise( mRenderWindow ); WindowEventUtilities::addWindowEventListener( mRenderWindow, this ); // load initial resources this->setupResources(lPathOgreRes); mInputMgr->addKeyListener( this, "GameManager" ); mInputMgr->addMouseListener( this, "GameManager" ); EventManager::getSingletonPtr(); GfxEngine::getSingletonPtr()->setup(); UIEngine::getSingletonPtr()->setup(); FxEngine::getSingletonPtr()->setup(); ScriptEngine::getSingletonPtr()->setup(); ScriptEngine::getSingletonPtr()->runScript("Hax.lua"); ScriptEngine::getSingletonPtr()->passToLua("Hax.onEnter", 0); // Change to first state //~ this->changeState( Intro::getSingletonPtr() ); //~ this->changeState( Intro::getSingletonPtr() ); // lTimeLastFrame remembers the last time that it was checked // we use it to calculate the time since last frame lTimeLastFrame = 0; lTimeCurrentFrame = 0; lTimeSinceLastFrame = 0; mRoot->getTimer()->reset(); fSetup = true; }
const string_t array::get_metadata_value(const string_t& Name) const { metadata_t::const_iterator pair = metadata.find(Name); return pair != metadata.end() ? pair->second : string_t(); }
/// /// assign string constant to var /// var& var::operator = (const char* s) { _var = string_t(s); return *this; }
string_t double_t::convert_to<string_t>() const { return string_t( boost::lexical_cast<std::string>( data_ ) ); }
inline basic_val<T> const& basic_val<T>::operator[](char_t const(&s)[N]) const { return this->operator[](string_t(s)); }
/// /// ctor: init with string constant /// var::var(const char* s) : _var(string_t(s)) {}
//--------------------------------------------------------------------------- void WordMacros::BeginMacros() { string_t name = string_t("M") + aux::itoa(++m_MacroCounter); m_Macros += "Sub " + name + "() \n"; m_Macros += "' Johnny Txe \n"; }
Sirius2D::Sirius2D( ChannelWPtr parent , const string_t& deviceId , const int32_t deviceType , const int32_t serialId , const int32_t modbusId , const int32_t primeCurrent , const int32_t secondCurrent , const int32_t primeVoltage , const int32_t secondVoltage ) : Sirius2Base(parent, deviceId, deviceType, "Сириус-2-Д", serialId, modbusId) { paramTags.DI16 = Sirius2Base::WithPrefix("DI16"); paramTags.U = Sirius2Base::WithPrefix("U"); paramTags.Ua = Sirius2Base::WithPrefix("Ua"); paramTags.Uax = Sirius2Base::WithPrefix("Uax"); paramTags.Uay = Sirius2Base::WithPrefix("Uay"); paramTags.Ub = Sirius2Base::WithPrefix("Ub"); paramTags.Ubx = Sirius2Base::WithPrefix("Ubx"); paramTags.Uby = Sirius2Base::WithPrefix("Uby"); paramTags.Uc = Sirius2Base::WithPrefix("Uc"); paramTags.Ucx = Sirius2Base::WithPrefix("Ucx"); paramTags.Ucy = Sirius2Base::WithPrefix("Ucy"); paramTags.I = Sirius2Base::WithPrefix("I"); paramTags.Ia = Sirius2Base::WithPrefix("Ia"); paramTags.Iax = Sirius2Base::WithPrefix("Iax"); paramTags.Iay = Sirius2Base::WithPrefix("Iay"); paramTags.Ib = Sirius2Base::WithPrefix("Ib"); paramTags.Ibx = Sirius2Base::WithPrefix("Ibx"); paramTags.Iby = Sirius2Base::WithPrefix("Iby"); paramTags.Ic = Sirius2Base::WithPrefix("Ic"); paramTags.Icx = Sirius2Base::WithPrefix("Icx"); paramTags.Icy = Sirius2Base::WithPrefix("Icy"); paramTags.I0x = Sirius2Base::WithPrefix("I0x"); paramTags.I0y = Sirius2Base::WithPrefix("I0y"); paramTags.I2x = Sirius2Base::WithPrefix("I2x"); paramTags.I2y = Sirius2Base::WithPrefix("I2y"); paramTags.P = Sirius2Base::WithPrefix("P"); paramTags.Q = Sirius2Base::WithPrefix("Q"); Sirius2Base::AddTag(paramTags.DI16, ComVariant(uint16_t(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.U, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ua, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Uax, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Uay, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ub, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ubx, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Uby, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Uc, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ucx, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ucy, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(Sirius2Base::WithPrefix("U_unit"), ComVariant(string_t("кВ")), OPC_QUALITY_GOOD); Sirius2Base::AddTag(paramTags.I, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ia, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Iax, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Iay, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ib, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ibx, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Iby, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Ic, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Icx, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.Icy, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.I0x, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.I0y, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.I2x, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(paramTags.I2y, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(Sirius2Base::WithPrefix("I_unit"), ComVariant(string_t("А")), OPC_QUALITY_GOOD); Sirius2Base::AddTag(paramTags.P, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(Sirius2Base::WithPrefix("P_unit"), ComVariant(string_t("МВт")), OPC_QUALITY_GOOD); Sirius2Base::AddTag(paramTags.Q, ComVariant(float(0)), OPC_QUALITY_BAD); Sirius2Base::AddTag(Sirius2Base::WithPrefix("Q_unit"), ComVariant(string_t("МВр")), OPC_QUALITY_GOOD); // data request // discrete { RequestRTU request; request.startAdress = modbusId; request.func = 2; request.startAdress = 72; request.byteCount = 2; request.tags.push_back( TagInfo(paramTags.DI16, 18) ); Sirius2Base::AddRequest(request); } // analog { RequestRTU request; request.startAdress = modbusId; request.func = 3; request.startAdress = 1298; request.byteCount = 32; float factorCurrent = static_cast<float>(primeCurrent / secondCurrent); request.tags.push_back( TagInfo(paramTags.Iax, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.Iay, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.Ibx, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.Iby, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.Icx, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.Icy, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.I2x, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.I2y, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.I0x, 4, factorCurrent /* А */) ); request.tags.push_back( TagInfo(paramTags.I0y, 4, factorCurrent /* А */) ); float factorVoltage = static_cast<float>(primeVoltage / secondVoltage / 1000); request.tags.push_back( TagInfo(paramTags.Uax, 4, factorVoltage /* кВ */) ); request.tags.push_back( TagInfo(paramTags.Uay, 4, factorVoltage /* кВ */) ); request.tags.push_back( TagInfo(paramTags.Ubx, 4, factorVoltage /* кВ */) ); request.tags.push_back( TagInfo(paramTags.Uby, 4, factorVoltage /* кВ */) ); request.tags.push_back( TagInfo(paramTags.Ucx, 4, factorVoltage /* кВ */) ); request.tags.push_back( TagInfo(paramTags.Ucy, 4, factorVoltage /* кВ */) ); Sirius2Base::AddRequest(request); } }
string_t string_t::convert_to<string_t>() const { return string_t( is_reference_ ? ptr_to_ds_ : data_->c_str(), !is_reference_ ); //copy }
//--------------------------------------------------------------------------- void WordMacros::TablesColumns(int tableNum, int colNum, const string_t& param) { m_Macros += "ActiveDocument.Tables(" + string_t(aux::itoa(tableNum)) + ").Columns(" + aux::itoa(colNum) + ")." + param + "\n"; IsLarge(); }
} break; case '\r': case '\n': case '\0': error(px, "unterminated string"); case '"': goto final; } ++px; ++len; } final: string_t::ctor_t ctor(p - ptr + len); ctor(string_t(ptr, p - ptr)); while(true) { char c; switch(c = *(p++)) { case '\\': switch(c = *(p++)) { case '\\': case '"': break; case 'r': c = '\r'; break; case 'n': c = '\n'; break;
//--------------------------------------------------------------------------- void WordMacros::Cell(int tableNum, int x, int y, const string_t& param) { m_Macros += "ActiveDocument.Tables(" + string_t(aux::itoa(tableNum)) + ").Cell(" + aux::itoa(x) + "," + aux::itoa(y) + ")." + param + "\n"; IsLarge(); }
void file_types_default_t::parse_item( string_t const &_mime_type, in_t::ptr_t &p, size_t depth ) { string_t mime_type = _mime_type; if(!mime_type) { while(true) { // skip comments if(!p) { init(depth); return; } if(*p != '#') break; ++p; while(!is_eol(*p)) ++p; ++p; } in_t::ptr_t p0 = p; while(!is_hspace(*p) && !is_eol(*p)) ++p; mime_type = string_t(p0, p - p0); } while(is_hspace(*p)) ++p; if(is_eol(*p)) { ++p; parse_item(string_t::empty, p, depth); return; } in_t::ptr_t p0 = p; while(!is_hspace(*p) && !is_eol(*p)) ++p; string_t ext = string_t(p0, p - p0); parse_item(mime_type, p, depth + 1); item_t &item = items[depth]; item.mime_type = mime_type; item.ext = ext; item.need_charset = mime_type_need_charset(mime_type); item_t *&list = bucket(ext); for(item_t **itempp = &list; *itempp; itempp = &(*itempp)->next) { item_t *itemp = *itempp; if(string_t::cmp<lower_t>(item.ext, itemp->ext)) { if(mime_type_compare(item.mime_type, itemp->mime_type)) { *itempp = itemp->next; itemp->next = NULL; break; } else return; } } item.next = list; list = &item; return; }