本文整理汇总了C++中Format函数的典型用法代码示例。如果您正苦于以下问题:C++ Format函数的具体用法?C++ Format怎么用?C++ Format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Format
void GLFragmentDecompilerThread::AddCode(const std::string& code)
{
main.append(m_code_level, '\t') += Format(code) + "\n";
}
示例2: LoadTableMain
// Read the string table
bool LoadTableMain(wchar_t *filename)
{
BUF *b;
UINT64 t1, t2;
UCHAR hash[MD5_SIZE];
// Validate arguments
if (filename == NULL)
{
return false;
}
if (MayaquaIsMinimalMode())
{
return true;
}
if (UniStrCmpi(old_table_name, filename) == 0)
{
// Already loaded
return true;
}
t1 = Tick64();
// Open the file
b = ReadDumpW(filename);
if (b == NULL)
{
char tmp[MAX_SIZE];
StrCpy(tmp, sizeof(tmp), "Error: Can't read string tables (file not found).\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)");
Alert(tmp, NULL);
exit(-1);
return false;
}
Hash(hash, b->Buf, b->Size, false);
if (LoadUnicodeCache(filename, b->Size, hash) == false)
{
if (LoadTableFromBuf(b) == false)
{
FreeBuf(b);
return false;
}
SaveUnicodeCache(filename, b->Size, hash);
//Debug("Unicode Source: strtable.stb\n");
}
else
{
//Debug("Unicode Source: unicode_cache\n");
}
FreeBuf(b);
SetLocale(_UU("DEFAULE_LOCALE"));
UniStrCpy(old_table_name, sizeof(old_table_name), filename);
t2 = Tick64();
if (StrCmpi(_SS("STRTABLE_ID"), STRTABLE_ID) != 0)
{
char tmp[MAX_SIZE];
Format(tmp, sizeof(tmp), "Error: Can't read string tables (invalid version: '%s'!='%s').\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)",
_SS("STRTABLE_ID"), STRTABLE_ID);
Alert(tmp, NULL);
exit(-1);
return false;
}
//Debug("Unicode File Read Cost: %u (%u Lines)\n", (UINT)(t2 - t1), LIST_NUM(TableList));
return true;
}
示例3: GetTickCount
void __fastcall TProgressPanel::UpdateProgress(bool Regular)
{
float interval = 0.0;
if (Regular) {
DWORD ticks = GetTickCount();
if (ticks > this->FLastTicks) {
interval = ((float)(ticks - this->FLastTicks))/1000.0;
this->FCurElapsed += interval;
this->FOvrElapsed += interval;
}
this->FLastTicks = ticks;
}
UnicodeString oper = this->FOperation;
float cur, ovr;
long double cur_completed, ovr_completed;
if (this->FTotalWork > 0.00) {
cur = this->FCompleteRatio;
cur_completed = this->FCurrentWork*(long double)cur;
ovr_completed = this->FCommittedWork + cur_completed;
if (this->FTotalWork > 0.0) {
ovr = ovr_completed/this->FTotalWork;
}
else {
ovr = 0.0;
}
}
else {
cur = 0.00;
ovr = 0.00;
cur_completed = 0.0;
ovr_completed = 0.0;
}
UnicodeString cur_bytes, ovr_bytes, cur_eta, ovr_eta;
if (this->FCurrentBytes > 0) {
cur_bytes = Format(TXT_COMPLETED,
ARRAYOFCONST((this->FCompletedText, FormatDataSize(this->FCompletedBytes),
FormatDataSize(this->FCurrentBytes))));
}
if (this->FTotalBytes > 0) {
ovr_bytes = Format(TXT_COMPLETED,
ARRAYOFCONST((this->FCompletedText, FormatDataSize(this->FCommittedBytes + this->FCompletedBytes),
FormatDataSize(this->FTotalBytes))));
}
if (!this->FSubOperation.IsEmpty()) {
if (cur_bytes.IsEmpty()) cur_bytes = this->FSubOperation + L"...";
else cur_bytes += L" - " + this->FSubOperation;
}
if (Regular && (this->FEnableSpeed || this->FEnableETA!=ETA_NONE)) {
if (interval > 0.0) {
if (this->FEnableSpeed && this->FLastBytes >= 0) {
float speed = ((float)(this->FCompletedBytes - this->FLastBytes))/interval;
if (this->AveragerSpeed) {
this->AveragerSpeed->Add(speed);
speed = this->AveragerSpeed->GetAverage();
}
if (speed > 0) {
ovr_bytes += L" at " + FormatDataSize(speed, true);
}
}
if (this->FEnableETA!=ETA_NONE && this->FLastWork >= 0) {
float speed = ((float)(ovr_completed - this->FLastWork))/interval;
if (this->AveragerETA) {
this->AveragerETA->Add(speed);
speed = this->AveragerETA->GetAverage();
}
if (speed > 0.0) {
long secs_current = Round((this->FCurrentWork - cur_completed)/speed);
long secs_overall = Round((this->FTotalWork - ovr_completed)/speed);
if (this->FEnableETA&ETA_CURRENT && secs_current > 0 && secs_current < MAX_ETA) {
cur_eta = L"Time Left: " + FormatDuration(secs_current);
}
if (this->FEnableETA&ETA_OVERALL && secs_overall > 0 && secs_overall < MAX_ETA) {
ovr_eta = L"Time Left: " + FormatDuration(secs_overall);
}
}
}
}
if (this->EnableETA!=ETA_NONE) this->FLastWork = ovr_completed;
if (this->EnableSpeed) this->FLastBytes = this->FCompletedBytes;
}
//Assign UI values
this->lblOperation->Caption = ReplaceStr(oper, L"&", L"&&");
this->pbCurrent->Position = cur * (float)PROGRESSBAR_GRADATION;
this->lblCurPercent->Caption = IntToStr(Round(cur*100)) + L"%";
this->pbOverall->Position = ovr * (float)PROGRESSBAR_GRADATION;
this->lblOvrPercent->Caption = IntToStr(Round(ovr*100)) + L"%";
this->lblCurCompleted->Caption = cur_bytes;
this->lblOvrCompleted->Caption = ovr_bytes;
//.........这里部分代码省略.........
示例4: re
BOOL CParseChText4::SaveChText(LPCWSTR filePath)
{
wstring loadFilePath = L"";
wstring loadTunerName = L"";
if( filePath == NULL ){
loadFilePath = this->filePath;
loadTunerName = this->tunerName;
}else{
loadFilePath = filePath;
wregex re(L".+\\\\(.+)\\(.+\\)\\.ChSet4\\.txt$");
wstring text(filePath);
wsmatch m;
if( regex_search(text, m, re) ){
loadTunerName = m[1];
loadTunerName += L".dll";
}
}
if( loadFilePath.size() == 0 ){
return FALSE;
}
if( loadTunerName.size() == 0 ){
return FALSE;
}
multimap<LONGLONG, CH_DATA4> sortList;
multimap<LONGLONG, CH_DATA4>::iterator itr;
for( itr = this->chList.begin(); itr != this->chList.end(); itr++ ){
LONGLONG Key = ((LONGLONG)itr->second.space)<<32 | ((LONGLONG)itr->second.ch)<<16 | (LONGLONG)itr->second.serviceID;
sortList.insert(pair<LONGLONG, CH_DATA4>(Key, itr->second));
}
// ファイル出力
HANDLE hFile = _CreateFile2( loadFilePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile == INVALID_HANDLE_VALUE ){
return FALSE;
}
for( itr = sortList.begin(); itr != sortList.end(); itr++ ){
string chName="";
WtoA(itr->second.chName, chName);
string serviceName="";
WtoA(itr->second.serviceName, serviceName);
string networkName="";
WtoA(itr->second.networkName, networkName);
string strBuff;
Format(strBuff, "%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n",
chName.c_str(),
serviceName.c_str(),
networkName.c_str(),
itr->second.space,
itr->second.ch,
itr->second.originalNetworkID,
itr->second.transportStreamID,
itr->second.serviceID,
itr->second.serviceType,
itr->second.partialFlag,
itr->second.useViewFlag,
itr->second.remoconID
);
DWORD dwWrite = 0;
WriteFile(hFile, strBuff.c_str(), (DWORD)strBuff.length(), &dwWrite, NULL);
}
CloseHandle(hFile);
wstring appIniPath = L"";
GetModuleIniPath(appIniPath);
wstring ipString;
DWORD ip;
DWORD port;
ip = GetPrivateProfileInt(L"SET_UDP", L"IP0", 2130706433, appIniPath.c_str());
Format(ipString, L"%d.%d.%d.%d",
(ip&0xFF000000)>>24,
(ip&0x00FF0000)>>16,
(ip&0x0000FF00)>>8,
(ip&0x000000FF) );
port = GetPrivateProfileInt( L"SET_UDP", L"Port0", 3456, appIniPath.c_str() );
// MediaPortal TV Serverのデータベースへ登録
if (this->dbCtrl.Connect(&this->mysql, MYSQL_HOST, MYSQL_USER, MYSQL_PASSWD, MYSQL_DB) != 0) {
return FALSE;
}
this->results = NULL;
CString sql = L"";
wstring wsql = L"";
int chkNum = 0;
this->dbCtrl.Begin(&this->mysql);
map<CString, int> lockTable;
lockTable[L"channelgroup"] = 2;
lockTable[L"tuningdetail"] = 2;
lockTable[L"groupmap" ] = 2;
//.........这里部分代码省略.........
示例5: Format
String Parser::clear(String arg)
{
return Format("Clear(%s)",OPENARRAY(TVarRec,(arg)));
}
示例6: ParseUrl
// Parse the URL
bool ParseUrl(URL_DATA *data, char *str, bool is_post, char *referrer)
{
char tmp[MAX_SIZE * 3];
char server_port[MAX_HOST_NAME_LEN + 16];
char *s = NULL;
char *host;
UINT port;
UINT i;
// Validate arguments
if (data == NULL || str == NULL)
{
return false;
}
Zero(data, sizeof(URL_DATA));
if (is_post)
{
StrCpy(data->Method, sizeof(data->Method), WPC_HTTP_POST_NAME);
}
else
{
StrCpy(data->Method, sizeof(data->Method), WPC_HTTP_GET_NAME);
}
if (referrer != NULL)
{
StrCpy(data->Referer, sizeof(data->Referer), referrer);
}
StrCpy(tmp, sizeof(tmp), str);
Trim(tmp);
// Determine the protocol
if (StartWith(tmp, "http://"))
{
data->Secure = false;
s = &tmp[7];
}
else if (StartWith(tmp, "https://"))
{
data->Secure = true;
s = &tmp[8];
}
else
{
if (SearchStrEx(tmp, "://", 0, false) != INFINITE)
{
return false;
}
data->Secure = false;
s = &tmp[0];
}
// Get the "server name:port number"
StrCpy(server_port, sizeof(server_port), s);
i = SearchStrEx(server_port, "/", 0, false);
if (i != INFINITE)
{
server_port[i] = 0;
s += StrLen(server_port);
StrCpy(data->Target, sizeof(data->Target), s);
}
else
{
StrCpy(data->Target, sizeof(data->Target), "/");
}
if (ParseHostPort(server_port, &host, &port, data->Secure ? 443 : 80) == false)
{
return false;
}
StrCpy(data->HostName, sizeof(data->HostName), host);
data->Port = port;
Free(host);
if ((data->Secure && data->Port == 443) || (data->Secure == false && data->Port == 80))
{
StrCpy(data->HeaderHostName, sizeof(data->HeaderHostName), data->HostName);
}
else
{
Format(data->HeaderHostName, sizeof(data->HeaderHostName),
"%s:%u", data->HostName, data->Port);
}
return true;
}
示例7: Zero
//.........这里部分代码省略.........
if (IsEmptyStr(header_name) == false && IsEmptyStr(header_value) == false)
{
AddHttpValue(h, NewHttpValue(header_name, header_value));
}
if (IsEmptyStr(data->Referer) == false)
{
AddHttpValue(h, NewHttpValue("Referer", data->Referer));
}
if (StrCmpi(data->Method, WPC_HTTP_POST_NAME) == 0)
{
ToStr(len_str, StrLen(post_data));
AddHttpValue(h, NewHttpValue("Content-Type", "application/x-www-form-urlencoded"));
AddHttpValue(h, NewHttpValue("Content-Length", len_str));
}
if (IsEmptyStr(data->AdditionalHeaderName) == false && IsEmptyStr(data->AdditionalHeaderValue) == false)
{
AddHttpValue(h, NewHttpValue(data->AdditionalHeaderName, data->AdditionalHeaderValue));
}
if (use_http_proxy)
{
AddHttpValue(h, NewHttpValue("Proxy-Connection", "Keep-Alive"));
if (IsEmptyStr(setting->ProxyUsername) == false || IsEmptyStr(setting->ProxyPassword) == false)
{
char auth_tmp_str[MAX_SIZE], auth_b64_str[MAX_SIZE * 2];
char basic_str[MAX_SIZE * 2];
// Generate the authentication string
Format(auth_tmp_str, sizeof(auth_tmp_str), "%s:%s",
setting->ProxyUsername, setting->ProxyPassword);
// Base64 encode
Zero(auth_b64_str, sizeof(auth_b64_str));
Encode64(auth_b64_str, auth_tmp_str);
Format(basic_str, sizeof(basic_str), "Basic %s", auth_b64_str);
AddHttpValue(h, NewHttpValue("Proxy-Authorization", basic_str));
}
}
send_str = HttpHeaderToStr(h);
FreeHttpHeader(h);
send_buf = NewBuf();
WriteBuf(send_buf, send_str, StrLen(send_str));
Free(send_str);
// Append to the sending data in the case of POST
if (StrCmpi(data->Method, WPC_HTTP_POST_NAME) == 0)
{
WriteBuf(send_buf, post_data, StrLen(post_data));
}
// Send
if (SendAll(s, send_buf->Buf, send_buf->Size, s->SecureMode) == false)
{
Disconnect(s);
ReleaseSock(s);
FreeBuf(send_buf);
*error_code = ERR_DISCONNECTED;
示例8: Format
void AutotestingSystem::SaveScreenShotNameToDB()
{
Logger::Debug("AutotestingSystem::SaveScreenShotNameToDB %s", screenShotName.c_str());
AutotestingDB::Instance()->Log("INFO", Format("screenshot: %s", screenShotName.c_str()));
}
示例9: CreateBrokerThreadEntry
unsigned int __stdcall CreateBrokerThreadEntry(void *data)
{
TRY_CATCH
CoInitialize(0);
SBrokerThreadEntryData* inData = reinterpret_cast<SBrokerThreadEntryData*>(data);
SStartBroker *startBroker = reinterpret_cast<SStartBroker*>(inData->buf);
if (NULL == startBroker->buf || 0 == startBroker->bufSize)
throw MCException("NULL == startBroker->buf || 0 == startBroker->bufSize");
CComPtr<IDispatch> broker;
HRESULT hr;
if((hr=broker.CoCreateInstance(L"Broker.CoBroker",NULL,CLSCTX_LOCAL_SERVER))!=S_OK)
throw CExceptionBase(__LINE__,_T(__FILE__),_T(__DATE__),tstring(_T("CoBroker creation failed")),hr);
CScopedTracker<HGLOBAL> globalMem;
globalMem.reset(GlobalAlloc(GMEM_MOVEABLE, startBroker->bufSize), GlobalFree);
if (NULL == globalMem)
throw MCException_Win("Failed to GlobalAlloc");
CComPtr<IStream> stream;
hr = CreateStreamOnHGlobal(globalMem, FALSE, &stream);
if (S_OK != hr)
throw MCException_Win(Format(_T("Failed to GlobalAlloc; result = %X"),hr));
ULARGE_INTEGER size;
size.QuadPart = startBroker->bufSize;
hr = stream->SetSize(size);
if (S_OK != hr)
throw MCException_Win(Format(_T("Failed to stream->SetSize; result = %X"),hr));
hr = CoMarshalInterface(stream, IID_IDispatch, broker, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
if (S_OK != hr)
throw MCException_Win(Format(_T("Failed to CoMarshalInterface; result = %X"),hr));
ULARGE_INTEGER uLi;
LARGE_INTEGER li;
li.QuadPart = 0;
/// Writing stream to client process memory
stream->Seek(li, STREAM_SEEK_SET, NULL);
boost::scoped_array<char> localBuf;
ULONG readCount;
localBuf.reset(new char[startBroker->bufSize]);
hr = stream->Read(localBuf.get(), startBroker->bufSize, &readCount);
if (S_OK != hr)
throw MCException_Win(Format(_T("stream->Read; result = %X"),hr));
/// Writing stream date into client process memory
ULONG writtenCount;
if (FALSE == WriteProcessMemory(inData->clientProcess, startBroker->buf, localBuf.get(), readCount, &writtenCount))
throw MCException_Win("Failed to WriteProcessMemory ");
CoUninitialize();
Log.Add(_MESSAGE_,_T("Broker created and marshaled to BrokerProxy process"));
return TRUE;
CATCH_LOG()
CoUninitialize();
return FALSE;
}
示例10: CATCH_LOG
CATCH_LOG()
}
/// Preparing to set vncHooks
m_vncHooks.reset(NULL, CloseHandle);
LoadVNCHooks();
CATCH_THROW()
}
void CRCHostProxy::LoadVNCHooks()
{
TRY_CATCH
if (NULL != m_vncHooks.get())
return; //Already loaded
tstring fileName = Format(_T("%s\\vnchooks.dll"),GetModulePath(NULL).c_str());
m_vncHooks.reset(LoadLibrary(fileName.c_str()),FreeLibrary);
if (NULL != m_vncHooks)
{
m_unSetHooks = (UnSetHooksFn) GetProcAddress( m_vncHooks, _T("UnSetHooks"));
m_setMouseFilterHook = (SetMouseFilterHookFn) GetProcAddress( m_vncHooks, _T("SetMouseFilterHook"));
m_setKeyboardFilterHook = (SetKeyboardFilterHookFn) GetProcAddress( m_vncHooks, _T("SetKeyboardFilterHook"));
m_setHooks = (SetHooksFn) GetProcAddress( m_vncHooks, _T("SetHooks"));
} else
throw MCException_Win(Format(_T("Failed to load %s"),fileName.c_str()));
Log.Add(_MESSAGE_,_T("VNCHooks loaded"));
CATCH_LOG()
}
CRCHostProxy::~CRCHostProxy()
{
示例11: operator
void operator()(const Args&... args) const
{
writeln(Format(args...));
}
示例12: CheckKey
void Parser::CheckKey(int c)
{
if(!Key(c)) ThrowError(Format("Missing %c", c));
}
示例13: SAFE_DELETE
BOOL CParseRecInfoText::ParseRecInfoText(LPCWSTR filePath)
{
if( filePath == NULL ){
return FALSE;
}
multimap<wstring, REC_FILE_INFO*>::iterator itr;
for( itr = this->recInfoMap.begin(); itr != this->recInfoMap.end(); itr++ ){
SAFE_DELETE(itr->second)
}
this->recInfoMap.clear();
this->recIDMap.clear();
this->nextID = 1;
this->loadFilePath = filePath;
HANDLE hFile = _CreateFile2( filePath, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile == INVALID_HANDLE_VALUE ){
return FALSE;
}
DWORD dwFileSize = GetFileSize( hFile, NULL );
if( dwFileSize == 0 ){
CloseHandle(hFile);
return TRUE;
}
char* pszBuff = new char[dwFileSize+1];
if( pszBuff == NULL ){
CloseHandle(hFile);
return FALSE;
}
ZeroMemory(pszBuff,dwFileSize+1);
DWORD dwRead=0;
ReadFile( hFile, pszBuff, dwFileSize, &dwRead, NULL );
string strRead = pszBuff;
CloseHandle(hFile);
SAFE_DELETE_ARRAY(pszBuff);
string parseLine="";
size_t iIndex = 0;
size_t iFind = 0;
while( iFind != string::npos ){
iFind = strRead.find("\r\n", iIndex);
if( iFind == (int)string::npos ){
parseLine = strRead.substr(iIndex);
//strRead.clear();
}else{
parseLine = strRead.substr(iIndex,iFind-iIndex);
//strRead.erase( 0, iIndex+2 );
iIndex = iFind + 2;
}
//先頭;はコメント行
if( parseLine.find(";") != 0 ){
//空行?
if( parseLine.find("\t") != string::npos ){
REC_FILE_INFO* item = new REC_FILE_INFO;
BOOL bRet = Parse1Line(parseLine, item);
if( bRet == FALSE ){
SAFE_DELETE(item)
}else{
wstring strKey;
Format(strKey, L"%04d%02d%02d%02d%02d%02d%04X%04X",
item->startTime.wYear,
item->startTime.wMonth,
item->startTime.wDay,
item->startTime.wHour,
item->startTime.wMinute,
item->startTime.wSecond,
item->originalNetworkID,
item->transportStreamID);
item->id = GetNextReserveID();
this->recInfoMap.insert( pair<wstring, REC_FILE_INFO*>(strKey,item) );
this->recIDMap.insert( pair<DWORD, REC_FILE_INFO*>(item->id,item) );
}
}
}
}
示例14: AddCode
void VertexProgramDecompiler::AddCode(const std::string& code)
{
m_body.push_back(Format(code) + ";");
m_cur_instr->body.push_back(Format(code));
}
示例15: Construction
protected func Construction()
{
var graphic = Random(5);
if(graphic)
SetGraphics(Format("%d",graphic));
}