TString TPerformanceMeasurerStorage::Statistic() const { TCriticalSection::TLocker locker(m_pCS); TPmMap *pTotal = new TPmMap(); for(TThreadMap::iterator threadIt = m_pMap->begin(); threadIt != m_pMap->end(); ++threadIt) { TPmMap *pPmMap = threadIt->second; for(TPmMap::iterator pmIt = pPmMap->begin(); pmIt != pPmMap->end(); ++pmIt) { TPerformanceMeasurer *pPm = NULL; TPmMap::iterator totalIt = pTotal->find(pmIt->first); if(totalIt == pTotal->end()) { pPm = new TPerformanceMeasurer(pmIt->second->Description().c_str()); (*pTotal)[pmIt->first] = pPm; } else pPm = totalIt->second; pPm->Combine(*pmIt->second); } } std::vector<TString> statistics; for(TPmMap::iterator totalIt = pTotal->begin(); totalIt != pTotal->end(); ++totalIt) statistics.push_back(totalIt->second->Statistic()); Free(pTotal); std::sort(statistics.begin(), statistics.end()); TStringStream statistic; for(size_t i = 0; i < statistics.size(); ++i) statistic << statistics[i] << std::endl; return statistic.str(); }
/////////////////////////////////////////////////////////////////////////// // CTSPIConferenceCall::Dump // // Debug "dump" of the object and it's contents. // TString CTSPIConferenceCall::Dump() const { TStringStream outstm; CEnterCode keyLock(this, FALSE); outstm << _T("0x") << hex << (DWORD)this; outstm << _T(",htCall=0x") << hex << m_htCall; outstm << _T(",LineOwner=0x") << hex << GetLineOwner()->GetPermanentDeviceID(); outstm << _T(",State=") << GetCallStateName(); outstm << _T(",RefCnt=") << setw(2) << GetRefCount(); // Only dump the conferenced parties if we can lock the object right now. // If not, ignore it and continue. This particular function is called during // call removal and causes a deadlock if another call is changing state at // this moment in the conference. (V3.043) if (keyLock.Lock(0)) { outstm << _T(",Parties=") << setw(2) << m_lstConference.size() << endl; for (TCallHubList::const_iterator iCall = m_lstConference.begin(); iCall != m_lstConference.end(); ++iCall) outstm << _T(" ") << (*iCall)->Dump() << endl; } else outstm << endl; return(outstm.str()); }// CTSPIConferenceCall::Dump
TString FormatWithCommas(T value) { TStringStream tss; tss.imbue(locale("")); tss << fixed << value; return tss.str(); }
TString FormatDateTime(time_t value) { TStringStream tss; tss.imbue(locale("")); tss << put_time(localtime(&value), wxT("%c")); return tss.str(); }
// static TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction) { if (hashFunction == NULL || name.empty()) return name; khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length()); TStringStream stream; stream << HASHED_NAME_PREFIX << std::hex << number; TString hashedName = stream.str(); return hashedName; }
Stroka PrintTimePerItem(TDuration time, size_t count) { TStringStream res; if (time == TDuration::Zero()) res << "0"; else if (count == 0) res << "INF"; else res << NFormat::Duration(time / count); return res.Str(); }
Stroka PrintItemPerSecond(TDuration time, size_t itemscount, int kbase) { TStringStream res; double seconds = (double)(time.MilliSeconds()) / 1000.0; if (itemscount == 0) res << "0"; else if (time == TDuration::Zero() && seconds == 0.0) res << "INF"; else res << NFormat::Short<double>(itemscount / seconds, kbase); return res.Str(); }
TString TPerformanceMeasurer::Statistic() const { TStringStream ss; ss << m_decription << TEXT(": "); ss << std::setprecision(0) << std::fixed << m_total*1000 << TEXT(" ms"); ss << TEXT(" / ") << m_count << TEXT(" = "); ss << std::setprecision(2) << std::fixed << Average()*1000.0 << TEXT(" ms"); ss << std::setprecision(2) << TEXT(" {min=") << m_min*1000.0 << TEXT("; max=") << m_max*1000.0 << TEXT("}"); if(m_size > (long long)m_count) { double size = double(m_size); ss << std::setprecision(3) << TEXT(" [<s>=") << size/m_count*0.001 << TEXT(" kb; <t>=") << m_total/size*1000000000 << TEXT(" ns]"); } return ss.str(); }
static Stroka Summary(TInstant start, size_t totalLines, TInstant prev, size_t prevLines, bool shrinked = true) { TInstant current = Now(); TStringStream res; if (shrinked) res << NFormat::Short(totalLines); else res << totalLines; res << " processed (" << NFormat::Duration(current - start) << ", " << PrintTimePerItem(current - prev, prevLines) << " -> " << PrintTimePerItem(current - start, totalLines) << " avg)"; return res.Str(); }
//============================================================================ // // Implementation dependent built-in constants. // //============================================================================ static TString BuiltInConstants(const ShBuiltInResources &resources) { TStringStream s; s << "const int gl_MaxVertexAttribs = " << resources.MaxVertexAttribs << ";"; s << "const int gl_MaxVertexUniformVectors = " << resources.MaxVertexUniformVectors << ";"; s << "const int gl_MaxVaryingVectors = " << resources.MaxVaryingVectors << ";"; s << "const int gl_MaxVertexTextureImageUnits = " << resources.MaxVertexTextureImageUnits << ";"; s << "const int gl_MaxCombinedTextureImageUnits = " << resources.MaxCombinedTextureImageUnits << ";"; s << "const int gl_MaxTextureImageUnits = " << resources.MaxTextureImageUnits << ";"; s << "const int gl_MaxFragmentUniformVectors = " << resources.MaxFragmentUniformVectors << ";"; s << "const int gl_MaxDrawBuffers = " << resources.MaxDrawBuffers << ";"; return s.str(); }
TString TType::getCompleteString() const { TStringStream stream; if (qualifier != EvqTemporary && qualifier != EvqGlobal) stream << getQualifierString() << " " << getPrecisionString() << " "; if (array) stream << "array[" << getArraySize() << "] of "; if (matrix) stream << static_cast<int>(size) << "X" << static_cast<int>(size) << " matrix of "; else if (size > 1) stream << static_cast<int>(size) << "-component vector of "; stream << getBasicString(); return stream.str(); }
// static TString TIntermTraverser::hash(const TString& name, ShHashFunction64 hashFunction) { if (hashFunction == NULL || name.empty()) return name; #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wshorten-64-to-32" #endif khronos_uint64_t number = (*hashFunction)(name.c_str(), name.length()); #if defined(__clang__) #pragma clang diagnostic pop #endif TStringStream stream; stream << HASHED_NAME_PREFIX << std::hex << number; TString hashedName = stream.str(); return hashedName; }
TString TType::getCompleteString() const { TStringStream stream; if (qualifier != EvqTemporary && qualifier != EvqGlobal) stream << getQualifierString() << " "; if (precision != EbpUndefined) stream << getPrecisionString() << " "; if (array) stream << "array[" << getArraySize() << "] of "; if (isMatrix()) stream << getCols() << "X" << getRows() << " matrix of "; else if (isVector()) stream << getNominalSize() << "-component vector of "; stream << getBasicString(); return stream.str(); }
inline void TestVirtualInheritance() { TStringStream ss; OUTS = &ss; class TA { public: inline TA() { *OUTS << "A"; } }; class TB { public: inline TB() { *OUTS << "B"; } }; class TC: public virtual TB, public virtual TA { public: inline TC() { *OUTS << "C"; } }; class TD: public virtual TA { public: inline TD() { *OUTS << "D"; } }; class TE: public TC, public TD { public: inline TE() { *OUTS << "E"; } }; TE e; UNIT_ASSERT_EQUAL(ss.Str(), "BACDE"); }
static Stroka SummaryBytes(TInstant start, size_t totalLines, TInstant prev, size_t prevLines, bool shrinked = true) { TInstant current = Now(); const size_t KB = 1024; const size_t MB = 1024*KB; TStringStream res; if (shrinked) res << NFormat::Short(totalLines, KB); else res << totalLines; res << " bytes processed (" << NFormat::Duration(current - start) << ", " << PrintTimePerItem(current - prev, prevLines/MB) << "/MB -> " << PrintTimePerItem(current - start, totalLines/MB) << "/MB, " << PrintItemPerSecond(current - start, totalLines, KB) << "B/s avg)"; return res.Str(); }
void ErrExit::FinalError(const TCHAR *FailCall, const TCHAR *Function, const TCHAR *File, const long Line, const DWORD SystemErrorID, const TCHAR *ErrorText) { const TCHAR *newl = TEXT("\r\n"); TCHAR Buffer[MAX_PATH]; int Response; TStringStream msg; //General Information msg << TEXT("DateTime: ") << GetLocalTime() << newl << TEXT("FailCall: ") << FailCall << newl << TEXT("Function: ") << Function << newl << TEXT("File: ") << File << newl << TEXT("Line: ") << Line << newl << newl; //Get Windows LastError Information if(SystemErrorID) { GetSystemErrText(SystemErrorID, Buffer, MAX_PATH); msg << TEXT("GetLastError: ") << SystemErrorID << newl << Buffer << newl; } else if(ErrorText) { msg << TEXT("ErrorText: ") << newl << ErrorText << newl << newl; } //Get CallStack msg << TEXT("Stack: ") << newl << Stackage::GetString() << newl; //Display MessageBox and Copy to Clipboard TString info = msg.str(); msg << newl << TEXT("Copy this information to clipboard?"); Response = MessageBox(HWND_DESKTOP, msg.str().c_str(), TEXT("Fatal Error"), MB_YESNO | MB_ICONHAND | MB_DEFBUTTON2); if(Response == IDYES) ClipBoardSetText(info.c_str()); //Fatal Fail ExitProcess(1); }
bool TSimpleTextMiner::Run() { if (Input == NULL || Output == NULL) return false; Wtroka text; SDocumentAttribtes docAttr; ETypeOfDocument type; while (DoInput(text, docAttr, type)) { bool res = DoProcess(text, docAttr, type); if (res) res = DoOutput(docAttr); if (!res && Errors != NULL && dynamic_cast<TStringStream*>(ErrorStream) != NULL) { TStringStream* str = static_cast<TStringStream*>(ErrorStream); Errors->OutputError(str->Str()); str->clear(); } } return true; }
static Stroka FormatOption(const TOpt* option) { TStringStream result; const TOpt::TShortNames& shorts = option->GetShortNames(); const TOpt::TLongNames& longs = option->GetLongNames(); const size_t nopts = shorts.size() + longs.size(); const bool multiple = 1 < nopts; if (multiple) result << '{'; for (size_t i = 0; i < nopts; ++i) { if (multiple && 0 != i) result << '|'; if (i < shorts.size()) // short result << '-' << shorts[i]; else result << "--" << longs[i - shorts.size()]; } if (multiple) result << '}'; static const Stroka metavarDef("VAL"); const Stroka& title = option->ArgTitle_; const Stroka& metavar = title.Empty() ? metavarDef : title; if (option->HasArg_ == OPTIONAL_ARGUMENT) { result << " [" << metavar; if (option->HasOptionalValue()) result << ':' << option->GetOptionalValue(); result << ']'; } else if (option->HasArg_ == REQUIRED_ARGUMENT) result << ' ' << metavar; else YASSERT(option->HasArg_ == NO_ARGUMENT); return result.Str(); }
static TString FormatOption(const TOpt* option, const NColorizer::TColors& colors) { TStringStream result; const TOpt::TShortNames& shorts = option->GetShortNames(); const TOpt::TLongNames& longs = option->GetLongNames(); const size_t nopts = shorts.size() + longs.size(); const bool multiple = 1 < nopts; if (multiple) result << '{'; for (size_t i = 0; i < nopts; ++i) { if (multiple && 0 != i) result << '|'; if (i < shorts.size()) // short result << colors.GreenColor() << '-' << shorts[i] << colors.OldColor(); else result << colors.GreenColor() << "--" << longs[i - shorts.size()] << colors.OldColor(); } if (multiple) result << '}'; static const TString metavarDef("VAL"); const TString& title = option->GetArgTitle(); const TString& metavar = title.Empty() ? metavarDef : title; if (option->GetHasArg() == OPTIONAL_ARGUMENT) { result << " [" << metavar; if (option->HasOptionalValue()) result << ':' << option->GetOptionalValue(); result << ']'; } else if (option->GetHasArg() == REQUIRED_ARGUMENT) result << ' ' << metavar; else Y_ASSERT(option->GetHasArg() == NO_ARGUMENT); return result.Str(); }
Stroka CPrimitiveGroup::DebugString() const { TStringStream str; str << "CPrimitiveGroup \"" << NStr::DebugEncode(UTF8ToWide(GetRuleName())) << "\": homonyms [" << m_ActiveHomonyms << "]"; return str.Str(); }
void TOpts::PrintUsage(const TStringBuf& program, IOutputStream& osIn, const NColorizer::TColors& colors) const { TStringStream os; if (!Title.empty()) os << Title << "\n\n"; PrintCmdLine(program, os, colors); TVector<TString> leftColumn(Opts_.size()); TVector<size_t> leftColumnSizes(leftColumn.size()); size_t leftWidth = 0; size_t requiredOptionsCount = 0; NColorizer::TColors disabledColors(false); for (size_t i = 0; i < Opts_.size(); i++) { const TOpt* opt = Opts_[i].Get(); if (opt->IsHidden()) continue; leftColumn[i] = FormatOption(opt, colors); const size_t leftColumnSize = colors.IsTTY() ? FormatOption(opt, disabledColors).size() : leftColumn[i].size(); leftColumnSizes[i] = leftColumnSize; leftWidth = Max(leftWidth, leftColumnSize); if (opt->IsRequired()) requiredOptionsCount++; } const size_t kMaxLeftWidth = 25; leftWidth = Min(leftWidth, kMaxLeftWidth); const TString maxPadding(kMaxLeftWidth, ' '); const TString leftPadding(leftWidth, ' '); for (size_t sectionId = 0; sectionId <= 1; sectionId++) { bool requiredOptionsSection = (sectionId == 0); if (requiredOptionsSection) { if (requiredOptionsCount == 0) continue; os << Endl << colors.BoldColor() << "Required parameters" << colors.OldColor() << ":" << Endl; } else { if (requiredOptionsCount == Opts_.size()) continue; if (requiredOptionsCount == 0) os << Endl << colors.BoldColor() << "Options" << colors.OldColor() << ":" << Endl; else os << Endl << colors.BoldColor() << "Optional parameters" << colors.OldColor() << ":" << Endl; // optional options would be a tautology } for (size_t i = 0; i < Opts_.size(); i++) { const TOpt* opt = Opts_[i].Get(); if (opt->IsHidden()) continue; if (opt->IsRequired() != requiredOptionsSection) continue; if (leftColumnSizes[i] > leftWidth && !opt->GetHelp().empty()) { os << SPad << leftColumn[i] << Endl << SPad << maxPadding << ' '; } else { os << SPad << leftColumn[i] << ' '; if (leftColumnSizes[i] < leftWidth) os << TStringBuf(~leftPadding, leftWidth - leftColumnSizes[i]); } bool multiLineHelp = false; if (!opt->GetHelp().empty()) { TVector<TStringBuf> helpLines; Split(opt->GetHelp(), "\n", helpLines); multiLineHelp = (helpLines.size() > 1); os << helpLines[0]; for (size_t j = 1; j < helpLines.size(); ++j) { if (helpLines[j].empty()) continue; os << Endl << SPad << leftPadding << ' ' << helpLines[j]; } } if (opt->HasDefaultValue()) { TString quotedDef = QuoteForHelp(opt->GetDefaultValue()); if (multiLineHelp) os << Endl << SPad << leftPadding << " Default: " << colors.CyanColor() << quotedDef << colors.OldColor(); else if (opt->GetHelp().empty()) os << "Default: " << colors.CyanColor() << quotedDef << colors.OldColor(); else os << " (default: " << colors.CyanColor() << quotedDef << colors.OldColor() << ")"; } os << Endl; } } PrintFreeArgsDesc(os, colors); osIn << os.Str(); }
TString OptToString(char c) { TStringStream ss; ss << "-" << c; return ss.Str(); }
//--------------------------------------------------------------------------- void __fastcall TFrm1010::execBtPadraoExecute(TObject *Sender) { TStringStream *StrStream; HRSRC HrSql; HGLOBAL SqlData; DWORD szbf; String sCodRotina, sSQL; if (MessageBox(Handle,"Confirma a carga do menu padrão do sistema?",Caption.c_str(),APP_QUESTION|MB_DEFBUTTON2) == IDNO) return; StrStream = new TStringStream(""); HrSql = FindResource(HInstance, "MENUPADRAO", RT_RCDATA); SqlData = LoadResource(HInstance, HrSql); szbf = SizeofResource(HInstance, HrSql); StrStream->Write(SqlData,szbf); StrStream->Seek(0, soFromBeginning); XMLLoadMenu->LoadFromStream(StrStream); TZQuery *QyMenuItem = new TZQuery(Application); QyMenuItem->Connection = AppConnection; IXMLNodeList *NodeList = XMLLoadMenu->ChildNodes; NodeList = NodeList->FindNode("MenuSFG")->ChildNodes; IXMLNode *InstNode = NULL; IXMLNodeList *AtrsNode = NULL; IXMLNode *AtrNode = NULL; int iNumInsts = NodeList->GetCount(); for (int i=0; i < iNumInsts; i++) { InstNode = NodeList->Nodes[i]; if (InstNode != NULL) { AtrsNode = InstNode->GetAttributeNodes(); if (AtrsNode != NULL) { AtrNode = AtrsNode->FindNode("cod_rotina"); if (AtrNode != NULL) { sCodRotina = String(AtrNode->Text).Trim(); sSQL = "SELECT 1 FROM tbl_menu_sistema WHERE cod_rotina = " + QuotedStr(sCodRotina); if (!ValidacoesDB::ExistePrimaryKey(AppConnection, sSQL)) { sSQL = InstNode->Text; QyMenuItem->SQL->Text = sSQL; try { QyMenuItem->ExecSQL(); } catch (Exception &e) { String Msg = "Ocorreu o seguinte erro:\n" + e.Message +\ "\nAo executar o comando de ordem " + IntToStr(i+1) + \ " da carga do menu padrão."; MessageBox(NULL,Msg.c_str(),"Mensagem de Erro",APP_ERROR); } } } } } } delete QyMenuItem; delete StrStream; //Recarrega o menu FreeTreeNodes(TreeMenu->Items->GetFirstNode(), -1); CadMenu->Refresh(); CarregaMenu(NULL); CadMenu->Filtered = false; }
TString OptToString(const TString& longOption) { TStringStream ss; ss << "--" << longOption; return ss.Str(); }
void TStructure::createSamplerSymbols(const TString &structName, const TString &structAPIName, const unsigned int arrayOfStructsSize, TVector<TIntermSymbol *> *outputSymbols, TMap<TIntermSymbol *, TString> *outputSymbolsToAPINames) const { for (auto &field : *mFields) { const TType *fieldType = field->type(); if (IsSampler(fieldType->getBasicType())) { if (arrayOfStructsSize > 0u) { for (unsigned int arrayIndex = 0u; arrayIndex < arrayOfStructsSize; ++arrayIndex) { TStringStream name; name << structName << "_" << arrayIndex << "_" << field->name(); TIntermSymbol *symbol = new TIntermSymbol(0, name.str(), *fieldType); outputSymbols->push_back(symbol); if (outputSymbolsToAPINames) { TStringStream apiName; apiName << structAPIName << "[" << arrayIndex << "]." << field->name(); (*outputSymbolsToAPINames)[symbol] = apiName.str(); } } } else { TString symbolName = structName + "_" + field->name(); TIntermSymbol *symbol = new TIntermSymbol(0, symbolName, *fieldType); outputSymbols->push_back(symbol); if (outputSymbolsToAPINames) { TString apiName = structAPIName + "." + field->name(); (*outputSymbolsToAPINames)[symbol] = apiName; } } } else if (fieldType->isStructureContainingSamplers()) { unsigned int nestedArrayOfStructsSize = fieldType->isArray() ? fieldType->getArraySize() : 0u; if (arrayOfStructsSize > 0) { for (unsigned int arrayIndex = 0u; arrayIndex < arrayOfStructsSize; ++arrayIndex) { TStringStream fieldName; fieldName << structName << "_" << arrayIndex << "_" << field->name(); TStringStream fieldAPIName; if (outputSymbolsToAPINames) { fieldAPIName << structAPIName << "[" << arrayIndex << "]." << field->name(); } fieldType->createSamplerSymbols(fieldName.str(), fieldAPIName.str(), nestedArrayOfStructsSize, outputSymbols, outputSymbolsToAPINames); } } else { fieldType->createSamplerSymbols( structName + "_" + field->name(), structAPIName + "." + field->name(), nestedArrayOfStructsSize, outputSymbols, outputSymbolsToAPINames); } } } }
//--------------------------------------------------------------------------- void __fastcall TForm7::Button1Click(TObject *Sender) { system("TASKKILL /im ShirahNabiApps.exe"); TStringList*Send = new TStringList(this); TStringStream * Receive = new TStringStream(); IdHTTP1->Request->UserAgent = "*"; IdHTTP1->Request->ContentType="text/html"; IdHTTP1->Post("http://ariefsetya.com/p3m/usiroh/cek.php?cat=link&ver="+ NEWVERSION, Send, Receive); String URL = Receive->DataString; Receive->Clear(); IdHTTP1->Post("http://ariefsetya.com/p3m/usiroh/cek.php?cat=filename&ver="+ NEWVERSION, Send, Receive); String fn = Receive->DataString; Receive->Clear(); IdHTTP1->Post("http://ariefsetya.com/p3m/usiroh/cek.php?cat=sqlupdate&ver="+ NEWVERSION, Send, Receive); String dbupdate = Receive->DataString; //*******************************************************************// // // // Eksekusi SQL yang diberikan, jika ada perubahan database // // dari String dbupdate, jangan lupa buat ado koneksinya :v // // contoh : // // // // if(db_update.Trim()!=""){ // // ADOQuery->Close(); // // ADOQuery->SQL->Clear(); // // ADOQuery->SQL->Add(db_update); // // ADOQuery->ExecSQL(); // // } // // // //********************************************************************// Receive->Clear(); IdHTTP1->Post("http://ariefsetya.com/p3m/usiroh/cek.php?cat=logdata&ver="+ NEWVERSION,Send,Receive); String logdata = Receive->DataString; Receive->Clear(); ShowMessage("Tentang : \r\n\r\n"+logdata); TFileStream *fStream = new TFileStream(fn, fmCreate); try { try { IdHTTP1->Request->UserAgent = "*"; IdHTTP1->Get("http://"+URL, fStream); } __finally { delete fStream; MessageBoxA(0,"Download Berhasil","Complete!",MB_ICONINFORMATION|MB_OK); } } catch(Exception &e) { DeleteFile(fn); MessageBoxA(0,"Download Gagal","Gagal!",MB_ICONERROR|MB_OK); } TMemo*m = new TMemo(this); m->Text = NEWVERSION; m->Lines->SaveToFile(GetCurrentDir()+"/ver.txt"); MessageBoxA(0,"Aplikasi Diperbarui","Complete!",MB_ICONINFORMATION|MB_OK); system("TASKKILL /im UpdaterApps.exe"); system("start ShirahNabiApps.exe"); }