Ejemplo n.º 1
0
	void Log(wostringstream& stream)
	{
		stream << endl;

		//Send it all to the VS Output window
		OutputDebugStringW(stream.str().c_str());
	}
Ejemplo n.º 2
0
YK_BOOL WriteResRateToCSV( const YKString& filePath , const wostringstream& strContent, YK_SHORT fileType )
{
	if(fileType == OutputFileFormat_Tab)
	{
		HANDLE hFile = ::CreateFile(filePath.c_str(),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		if ( hFile == INVALID_HANDLE_VALUE) return false;

		DWORD byteToWirte,byteWrite;

		/* write unicode header*/
		WCHAR unicodeHeader = 0xFEFF;
		::WriteFile(hFile,&unicodeHeader,sizeof(WCHAR),&byteWrite,NULL);

		YK_WSTRING& str = strContent.str();
		const WCHAR* pData = str.c_str();
		byteToWirte  = (DWORD)lstrlenW(pData)*sizeof(WCHAR);
		::WriteFile(hFile,pData,byteToWirte,&byteWrite,NULL);

		::CloseHandle(hFile);

		return true;
	}else
	{
		HANDLE hFile = ::CreateFile(filePath.c_str(),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
		if ( hFile == INVALID_HANDLE_VALUE) return false;

		DWORD byteToWirte,byteWrite;

		YKString str = strContent.str();
		YK_STRING asiiStr = str.ToString();

		const CHAR* pData = asiiStr.c_str();
		byteToWirte  = (DWORD)lstrlenA(pData)*sizeof(CHAR);
		::WriteFile(hFile,pData,byteToWirte,&byteWrite,NULL);

		::CloseHandle(hFile);

		return true;
	}
}
Ejemplo n.º 3
0
void ErrorExit(wostringstream& logStream, const LPTSTR lpszFunction, bool showDialog) 
{ 
    // Retrieve the system error message for the last-error code
    LPVOID lpMsgBuf;
    LPVOID lpDisplayBuf;
    DWORD dw = GetLastError(); 

    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);

    // Display the error message and exit the process
    lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)lpszFunction) + 100) * sizeof(TCHAR)); 
    StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR),
		TEXT("%s failed with error %d: %s Please contact your support representative."), lpszFunction, dw, lpMsgBuf); 

    logStream << TEXT("ErrorExit called: ") << (LPTSTR)lpDisplayBuf << endl;

    // Now write logStream to file
    TCHAR destBuf[MAX_PATH];
    wostringstream DebugFilePath;
    // Get %APPDATA% path
    if (SHGetSpecialFolderPath(NULL, destBuf, CSIDL_APPDATA, 1) == TRUE)
    {
        DebugFilePath << destBuf << "\\[Citrix]\\[XenCenter]\\logs\\splash.log";
        wofstream fileStream(DebugFilePath.str().c_str(), ios_base::out | ios_base::trunc);
        fileStream << logStream.str() << endl;
    }

    if (showDialog)
    {
        // Show error to user
        MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK);
    }

    LocalFree(lpMsgBuf);
    LocalFree(lpDisplayBuf);
    ExitProcess(dw);
}
Ejemplo n.º 4
0
		{
			string strSrc = "AATELDALFJADSEWORUNFASDLHFSSCBWERQW";
			ByteVecotrPtr srcVec(new ByteVecotr());
			for each (char c in strSrc)
			{
				srcVec->push_back(c);
			}

			HuffmanTreeBuilder treeBuilder;
			unordered_map<stKey, shared_ptr<typeTreeNode>> leafMap;

			TimeRecorder tr;

			wostringstream wostr;
			wostr << L"huffman code test with array " << endl;
			Logger::WriteMessage(wostr.str().c_str());

			/*********************************************************************************/
			/**** encoder                                                                  ***/
			/*********************************************************************************/
			tr.start();
			shared_ptr<MyBinaryTree<stNodeData>> tree = treeBuilder.BuildTrees(srcVec, leafMap);
			VLC_HuffmanEncoder encoder(*tree, leafMap);
			BitVectorPtr tmp = encoder.transitData(srcVec);
			tr.end();

			wostr.str(L"");
			wostr << L"encoder time : " << tr.getPeriod() << " " << tr.getPeriodUnit() << endl;
			Logger::WriteMessage(wostr.str().c_str());

			/*********************************************************************************/