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(); }
/////////////////////////////////////////////////////////////////////////// // 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 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(); }
// 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; }
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); }
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(); }
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(); }
//============================================================================ // // 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(); }
// 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(); }
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); } } } }