当前位置: 首页>>代码示例>>C++>>正文


C++ wstring::c_str方法代码示例

本文整理汇总了C++中std::wstring::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::c_str方法的具体用法?C++ wstring::c_str怎么用?C++ wstring::c_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::wstring的用法示例。


在下文中一共展示了wstring::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: showFile

void SourceView::showFile(std::wstring path, int proclinenum, const std::vector<double> &linecounts)
{
	currentfile = path;

	// Don't show error messages with CPP highlighting
	setPlainMode();
	if (path == "[hint KiFastSystemCallRet]")
	{
		updateText(
			" Hint: KiFastSystemCallRet often means the thread was waiting for something else to finish.\n"
			" \n"
			" Possible causes might be disk I/O, waiting for an event, or maybe just calling Sleep().\n"
			);
		return;
	}

	if (path == "" || path == "[unknown]")
	{
		updateText("[ No source file available for this location. ]");
		return;
	}


	FILE *file = _wfopen(path.c_str(),L"r, ccs=UNICODE");
	if(!file)
	{
		wchar_t *crtSub = L"\\crt\\src\\";
		wchar_t *crt = wcsstr((wchar_t *)path.c_str(), crtSub);
		if(crt) {
			for(size_t i=0;i<msDevPaths.size();i++) {
				std::wstring newPath(msDevPaths[i]);
				newPath += crt+wcslen(crtSub);
				path = newPath;
				file = _wfopen(path.c_str(),L"r");
				if(file)
					break;
			}
		}
	}

	if(!file)
	{
		updateText(std::wstring("[ Could not open file '" + path + "'. ]").c_str());
		return;
	}

	std::wstring displaytext;
	wchar_t line[1024];
	while(fgetws(line,countof(line),file))
	{
		displaytext += line;
	}

	fclose(file);

	setCppMode();

	updateText(displaytext);

	// Show line counts in margin
	for (int line=1,lineCount=linecounts.size(); line<lineCount; ++line)
	{
		if (linecounts[line])
		{
			wchar_t currCount[32];
			swprintf(currCount, countof(currCount), L"%0.2fs ", linecounts[line]);
			MarginSetText (line-1, currCount);
			MarginSetStyle(line-1, MARGIN_TEXT_STYLE);
		}
	}

	SetYCaretPolicy(wxSTC_CARET_STRICT|wxSTC_CARET_EVEN, 0);
	GotoLine(proclinenum);
	SetYCaretPolicy(wxSTC_CARET_EVEN, 0);

	MarkerDefine(1, wxSTC_MARK_BACKGROUND, wxNullColour, *wxYELLOW);
	MarkerAdd(proclinenum-1, 1);
}
开发者ID:doneykoo,项目名称:verysleepy,代码行数:78,代码来源:sourceview.cpp

示例2: AddChapterItem_Menu

void CContextMenu::AddChapterItem_Menu(HMENU parent, MatroskaChapterEntry *chapter, std::wstring chapterTitle, UINT &idCmd, UINT &indexMenu)
{
	CRASH_PROTECT_START;

	HMENU hmChapterItem = CreatePopupMenu();				
	InsertMenu(parent, indexMenu++, MF_STRING|MF_BYPOSITION|MF_POPUP, (UINT_PTR)hmChapterItem, chapterTitle.c_str());
	
	// Insert UID
	{
		SmartStringFormat wBuf;
		wBuf << _W("UID");
		wBuf << L": ";
		wBuf << chapter->chapterUID;
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}
	// Insert Start, End Times
	{
		SmartStringFormat wBuf;
		wBuf << _W("Start Time");
		wBuf << L": ";
		wBuf << chapter->GetTimeStartStr().c_str();
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}	
	if (chapter->timeEnd != 0) {
		SmartStringFormat wBuf;
		wBuf << _W("End Time");
		wBuf << L": ";
		wBuf << chapter->GetTimeEndStr().c_str();
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}	

	// Insert Display Strings
	for (size_t d = 0; d < chapter->display.size(); d++) {
		MatroskaChapterDisplayInfo &displayInfo = chapter->display.at(d);
		
		HMENU hmDisplayInfo = CreatePopupMenu();				
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION|MF_POPUP, (UINT_PTR)hmDisplayInfo, _W("Display String"));

		if (displayInfo.string.length() > 0) {
			SmartStringFormat wBuf;
			wBuf << _W("String");
			wBuf << L": ";
			wBuf << displayInfo.string.c_str();			
			InsertMenu(hmDisplayInfo, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
		}
		if (displayInfo.lang.length() > 0) {
			SmartStringFormat wBuf;
			wBuf << _W("Language");
			wBuf << L": ";
			wBuf << displayInfo.lang.c_str();
			InsertMenu(hmDisplayInfo, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
		}
		if (displayInfo.country.length() > 0) {			
			SmartStringFormat wBuf;
			wBuf << _W("Country");
			wBuf << L": ";
			wBuf << displayInfo.country.c_str();
			InsertMenu(hmDisplayInfo, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
		}
	}	

	// Insert Track UID
	HMENU hmTrackUID; 
	if (chapter->tracks.size() > 0) {
		hmTrackUID = CreatePopupMenu();				
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION|MF_POPUP, (UINT_PTR)hmTrackUID, _W("Track UID(s))"));
	}
	for (size_t t = 0; t < chapter->tracks.size(); t++) {
		SmartStringFormat wBuf;
		wBuf << _W("Track UID");
		wBuf << L": ";
		wBuf << (uint64)chapter->tracks.at(t);
		InsertMenu(hmTrackUID, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}

	for (size_t c = 0; c < chapter->children.size(); c++) {
		MatroskaChapterEntry *childChapter = chapter->children.at(c);
		SmartStringFormat wBuf;
		wBuf << chapterTitle.c_str();
		wBuf << L"-";
		wBuf << (c+1);
		AddChapterItem_Menu(hmChapterItem, childChapter, wBuf.str(), idCmd, indexMenu);
	}

	CRASH_PROTECT_END;
}
开发者ID:Matroska-Org,项目名称:matroskautils,代码行数:86,代码来源:CContextMenu.cpp

示例3: getPlayerHudFileMapped

std::wstring Team::getPlayerHudFileMapped(std::wstring const & map, u8 id){
	u8 index = getIndexMapped(map.c_str());
	return getPlayer(index)->getHudFile(id);
}
开发者ID:ddionisio,项目名称:Mahatta,代码行数:4,代码来源:game_team.cpp

示例4: install

//-------------------------------------------------------------------------------------
bool Script::install(const wchar_t* pythonHomeDir, std::wstring pyPaths, 
	const char* moduleName, COMPONENT_TYPE componentType)
{
	std::wstring pySysPaths = SCRIPT_PATH;
	wchar_t* pwpySysResPath = strutil::char2wchar(const_cast<char*>(Resmgr::getSingleton().getPySysResPath().c_str()));
	strutil::kbe_replace(pySysPaths, L"../../res/", pwpySysResPath);
	pyPaths += pySysPaths;
	free(pwpySysResPath);

	Py_SetPythonHome(const_cast<wchar_t*>(pythonHomeDir));								// 先设置python的环境变量

#if KBE_PLATFORM != PLATFORM_WIN32
	std::wstring fs = L";";
	std::wstring rs = L":";
	size_t pos = 0; 

	while(true)
	{ 
		pos = pyPaths.find(fs, pos);
		if (pos == std::wstring::npos) break;
		pyPaths.replace(pos, fs.length(), rs);
	}  

	char* tmpchar = strutil::wchar2char(const_cast<wchar_t*>(pyPaths.c_str()));
	DEBUG_MSG(fmt::format("Script::install(): paths={}.\n", tmpchar));
	free(tmpchar);
	
#endif
	// Initialise python
	// Py_VerboseFlag = 2;
	Py_FrozenFlag = 1;

	// Warn if tab and spaces are mixed in indentation.
	// Py_TabcheckFlag = 1;
	Py_NoSiteFlag = 1;
	Py_IgnoreEnvironmentFlag = 1;

	Py_SetPath(pyPaths.c_str());

	// python解释器的初始化  
	Py_Initialize();                      											
    if (!Py_IsInitialized())
    {
    	ERROR_MSG("Script::install(): Py_Initialize is failed!\n");
        return false;
    } 

	PyObject *m = PyImport_AddModule("__main__");

	// 添加一个脚本基础模块
	module_ = PyImport_AddModule(moduleName);										
	if (module_ == NULL)
		return false;
	
	const char* componentName = COMPONENT_NAME_EX(componentType);
	if (PyModule_AddStringConstant(module_, "component", componentName))
	{
		ERROR_MSG(fmt::format("Script::install(): Unable to set KBEngine.component to {}\n",
			componentName));
		return false;
	}
	
	// 注册产生uuid方法到py
	APPEND_SCRIPT_MODULE_METHOD(module_,		genUUID64,			__py_genUUID64,					METH_VARARGS,			0);

	if(!install_py_dlls())
	{
		ERROR_MSG("Script::install(): install_py_dlls() is failed!\n");
		return false;
	}

	// 安装py重定向模块
	ScriptStdOut::installScript(NULL);												
	ScriptStdErr::installScript(NULL);	

	static struct PyModuleDef moduleDesc =   
	{  
			 PyModuleDef_HEAD_INIT,  
			 moduleName,  
			 "This module is created by KBEngine!",  
			 -1,  
			 NULL  
	};  

	// 初始化基础模块
	PyModule_Create(&moduleDesc);		

	// 将模块对象加入main
	PyObject_SetAttrString(m, moduleName, module_);									

	// 重定向python输出
	pyStdouterr_ = new ScriptStdOutErr();											
	
	// 安装py重定向脚本模块
	if(!pyStdouterr_->install()){													
		ERROR_MSG("Script::install::pyStdouterr_->install() is failed!\n");
		delete pyStdouterr_;
		SCRIPT_ERROR_CHECK();
		return false;
//.........这里部分代码省略.........
开发者ID:ArcherPeng,项目名称:kbengine-cocos2dx,代码行数:101,代码来源:script.cpp

示例5: key_path

RemoteDesktop::EventLog::EventLog(std::wstring name){
	Name = name;
	auto key_path(L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + name);

	HKEY key;

	DWORD last_error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
		key_path.c_str(),
		0,
		0,
		REG_OPTION_NON_VOLATILE,
		KEY_SET_VALUE,
		0,
		&key,
		0);
	if (ERROR_SUCCESS == last_error)
	{
		wchar_t szPath[MAX_PATH];
		bool ret = false;

		GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath));

		const DWORD types_supported = EVENTLOG_ERROR_TYPE |
			EVENTLOG_WARNING_TYPE |
			EVENTLOG_INFORMATION_TYPE;

		RegSetValueEx(key,
			L"EventMessageFile",
			0,
			REG_SZ,
			(BYTE*)szPath,
			wcsnlen_s(szPath, MAX_PATH) * 2);

		RegSetValueEx(key,
			L"CategoryMessageFile",
			0,
			REG_SZ,
			(BYTE*)szPath,
			wcsnlen_s(szPath, MAX_PATH) * 2);

		RegSetValueEx(key,
			L"ParameterMessageFile",
			0,
			REG_SZ,
			(BYTE*)szPath,
			wcsnlen_s(szPath, MAX_PATH) * 2);

		RegSetValueEx(key,
			L"TypesSupported",
			0,
			REG_DWORD,
			(LPBYTE)&types_supported,
			sizeof(types_supported));
		DWORD catcount = 3;
		RegSetValueEx(key,
			L"CategoryCount",
			0,
			REG_DWORD,
			(LPBYTE)&catcount,
			sizeof(catcount));
		RegCloseKey(key);
	}
	else
	{
		std::cerr << "Failed to install source: " << last_error << "\n";
	}

	_EventSource = RegisterEventSource(NULL, name.c_str());
}
开发者ID:gvsurenderreddy,项目名称:RemoteDesktop-1,代码行数:69,代码来源:EventLog.cpp

示例6: ToCString

ATL::CString ToCString(const std::wstring& s)
{
  return ATL::CString(s.c_str());
}
开发者ID:abby-sergz,项目名称:new-adblockplusie,代码行数:4,代码来源:ATL_Deprecate.cpp

示例7: drawString

void RenderContext::drawString(const std::wstring& str, const D2D1_POINT_2F& pt, IDWriteTextFormat* pFormat, ID2D1Brush* pBrush)
{
	this->pInternalContext->DrawTextW(str.c_str(), static_cast<UINT>(str.length()), pFormat, 
		D2D1::RectF(pt.x, pt.y, floatMax, floatMax), pBrush);
}
开发者ID:Pctg-x8,项目名称:ChartForge,代码行数:5,代码来源:renderDevice.cpp

示例8: SelectCertificate

		bool SelectCertificate(const std::wstring& certStoreName, const std::string& certHash)
		{
			certStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER, certStoreName.c_str());

			if (!certStore)
			{
				std::wcerr << L"Failed to open cert store. Error: " << std::hex << GetLastError() << L", Store: " << certStoreName << std::endl;
				return false;
			}

			CRYPT_HASH_BLOB hashBlob;
			hashBlob.pbData = (BYTE*)certHash.data();
			hashBlob.cbData = (DWORD)certHash.size();

			CERT_ID id;
			id.dwIdChoice = CERT_ID_SHA1_HASH;
			id.HashId = hashBlob;
			certContext = CertFindCertificateInStore(certStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_CERT_ID, (void *)&id, NULL);

			if (!certContext)
			{
				std::cerr << "Failed to open cert context. Error: " << std::hex << GetLastError() << ", Certificate: " << certHash << std::endl;
				return false;
			}

			return true;
		}
开发者ID:ezolenko,项目名称:peparser,代码行数:27,代码来源:signer.cpp

示例9: create

bool WindowsWindow::create(
    const ContextFormat & format
,   const std::string & title
,   const unsigned int width
,   const unsigned int height)
{
    const std::wstring wtitle = std::wstring(title.begin(), title.end());
    static const LPCWSTR className = L"glow::Window";

    const HINSTANCE hInstance(GetModuleHandle(NULL));

    WNDCLASSEX wcex;
    ZeroMemory(&wcex, sizeof(WNDCLASSEX));

    if (FALSE == GetClassInfoEx(hInstance, className, &wcex))
    {
        // register window class

        wcex.cbSize         = sizeof(WNDCLASSEX);
        wcex.style          = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
        wcex.lpfnWndProc    = InitialProc;
        wcex.cbClsExtra     = 0;
        wcex.cbWndExtra     = 0;
        wcex.hInstance      = hInstance;
        wcex.hIcon          = NULL;
        wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
        wcex.hbrBackground  = NULL;
        wcex.lpszMenuName   = NULL;
        wcex.lpszClassName  = className;
        wcex.hIconSm        = NULL;

        if (!RegisterClassEx(&wcex))
        {
            fatal() << "Registering the window class failed (RegisterClassEx). Error: " << GetLastError();
            return false;
        }
    }

    m_hWnd = CreateWindowEx(
        WS_EX_APPWINDOW | WS_EX_WINDOWEDGE
    ,   className
    ,   wtitle.c_str()
    ,   WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
    ,   CW_USEDEFAULT
    ,   CW_USEDEFAULT
    ,   width
    ,   height
    ,   NULL
    ,   NULL
    ,   hInstance
    ,   this);

    if (NULL == m_hWnd)
    {
        fatal() << "Creating a window failed (CreateWindowEx). Error: " << GetLastError();
        return false;
    }

    GetWindowRect(m_hWnd, &m_rect);

    return true;
}
开发者ID:gersseba,项目名称:glow,代码行数:62,代码来源:WindowsWindow.cpp

示例10: sizeof

extern "C" void generate_type_list(const std::wstring &input)
{

		lex_t *lex = __build_lex();
		psrGrammar_t	*gmr = __build_grammar(&__g_handler);
		const parser_t		*parser = Parser_CreateParser(gmr, PARSER_LALR);
		psrContext_t *parser_ctx = Parser_CreateContext(parser, NULL);






		ARSpace::lexMatch_t *match = ARSpace::Lex_CreateMatch(lex);
		ARSpace::Lex_ResetInput(match, input.c_str());
		
		ARSpace::Lex_MatchClearFlags(match);
		
		ARSpace::lexToken_t		token;

		memset(&token, 0, sizeof(token));
		
		arStatus_t status = AR_S_YES;

		while(status == AR_S_YES)
		{

				status = ARSpace::Lex_Match(match, &token);

				if(status == AR_S_YES)
				{
						ARSpace::psrToken_t		psr_tok;

						PARSER_TOTERMTOK(&token, &psr_tok);

						status = ARSpace::Parser_AddToken(parser_ctx, &psr_tok);
						
						if(token.value == 0)
						{
								break;
						}

				}else if(status == AR_S_NO)
				{
						size_t len = wcslen(ARSpace::Lex_GetNextInput(match));
						if(len > 20) len = 20;

						size_t line;
						ARSpace::Lex_MatchGetCoordinate(match, NULL, &line, NULL);

						
						wchar_t msg[1024];
						AR_wcsncpy(msg, ARSpace::Lex_GetNextInput(match),  (int)len);
						AR_error(AR_ERR_FATAL, L"Input Error : %ls line : %Iu", msg, line);
						AR_abort();

				}else
				{
						AR_error(AR_ERR_FATAL, L"inner error !\r\n");
						AR_abort();
				}

		}

		Parser_DestroyContext(parser_ctx);
		parser_ctx = NULL;

		Parser_DestroyParser(parser);
		parser = NULL;

		Parser_DestroyGrammar(gmr);
		gmr = NULL;

		Lex_Destroy(lex);
		lex = NULL;

		Lex_DestroyMatch(match);
		match = NULL;

}
开发者ID:solidusex,项目名称:arsenalcomp,代码行数:80,代码来源:generate_type.cpp

示例11: setTitle

void WindowsWindow::setTitle(const std::string & title)
{
    const std::wstring wtitle = std::wstring(title.begin(), title.end());
    SetWindowText(m_hWnd, wtitle.c_str());
}
开发者ID:gersseba,项目名称:glow,代码行数:5,代码来源:WindowsWindow.cpp

示例12:

static inline std::string utf8(const std::wstring& p)
{
    return msra::strfun::wcstombs(p.c_str());
} // output: UTF-8... not really
开发者ID:dtmoodie,项目名称:signals,代码行数:4,代码来源:logging.cpp

示例13: GetSectionVariable

/*
** Gets the value of a section variable. Returns true if strValue is set.
** The selector is stripped from strVariable.
**
*/
bool ConfigParser::GetSectionVariable(std::wstring& strVariable, std::wstring& strValue)
{
	size_t colonPos = strVariable.find_last_of(L':');
	if (colonPos == std::wstring::npos)
	{
		return false;
	}

	const std::wstring selector = strVariable.substr(colonPos + 1);
	const WCHAR* selectorSz = selector.c_str();
	strVariable.resize(colonPos);

	bool isKeySelector = (!selector.empty() && iswalpha(selectorSz[0]));

	if (isKeySelector)
	{
		// [Meter:X], [Meter:Y], [Meter:W], [Meter:H]
		Meter* meter = m_Skin->GetMeter(strVariable);
		if (meter)
		{
			WCHAR buffer[32];
			if (_wcsicmp(selectorSz, L"X") == 0)
			{
				_itow_s(meter->GetX(), buffer, 10);
			}
			else if (_wcsicmp(selectorSz, L"Y") == 0)
			{
				_itow_s(meter->GetY(), buffer, 10);
			}
			else if (_wcsicmp(selectorSz, L"W") == 0)
			{
				_itow_s(meter->GetW(), buffer, 10);
			}
			else if (_wcsicmp(selectorSz, L"H") == 0)
			{
				_itow_s(meter->GetH(), buffer, 10);
			}
			else
			{
				return false;
			}

			strValue = buffer;
			return true;
		}
	}

	// Number: [Measure:], [Measure:dec]
	// Percentual: [Measure:%], [Measure:%, dec]
	// Scale: [Measure:/scale], [Measure:/scale, dec]
	// Max/Min: [Measure:MaxValue], [Measure:MaxValue:/scale, dec] ('%' cannot be used)
	// EscapeRegExp: [Measure:EscapeRegExp] (Escapes regular expression syntax, used for 'IfMatch')
	// EncodeUrl: [Measure:EncodeUrl] (Escapes URL reserved characters)
	// TimeStamp: [TimeMeasure:TimeStamp] (ONLY for Time measures, returns the Windows timestamp of the measure)
	enum class ValueType
	{
		Raw,
		Percentual,
		Max,
		Min,
		EscapeRegExp,
		EncodeUrl,
		TimeStamp
	} valueType = ValueType::Raw;

	if (isKeySelector)
	{
		if (_wcsicmp(selectorSz, L"MaxValue") == 0)
		{
			valueType = ValueType::Max;
		}
		else if (_wcsicmp(selectorSz, L"MinValue") == 0)
		{
			valueType = ValueType::Min;
		}
		else if (_wcsicmp(selectorSz, L"EscapeRegExp") == 0)
		{
			valueType = ValueType::EscapeRegExp;
		}
		else if (_wcsicmp(selectorSz, L"EncodeUrl") == 0)
		{
			valueType = ValueType::EncodeUrl;
		}
		else if (_wcsicmp(selectorSz, L"TimeStamp") == 0)
		{
			valueType = ValueType::TimeStamp;
		}
		else
		{
			return false;
		}

		selectorSz = L"";
	}
	else
//.........这里部分代码省略.........
开发者ID:Crawping,项目名称:rainmeter,代码行数:101,代码来源:ConfigParser.cpp

示例14: ReadIniFile

/*
** Reads the given ini file and fills the m_Values and m_Keys maps.
**
*/
void ConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR skinSection, int depth)
{
	if (depth > 100)	// Is 100 enough to assume the include loop never ends?
	{
		GetRainmeter().ShowMessage(nullptr, GetString(ID_STR_INCLUDEINFINITELOOP), MB_OK | MB_ICONERROR);
		return;
	}

	// Verify whether the file exists
	if (_waccess(iniFile.c_str(), 0) == -1)
	{
		LogErrorF(m_Skin, L"Unable to read file: %s", iniFile.c_str());
		return;
	}

	// Avoid "IniFileMapping"
	std::wstring iniRead = System::GetTemporaryFile(iniFile);
	bool temporary = (!iniRead.empty() && (iniRead.size() != 1 || iniRead[0] != L'?'));

	if (temporary)
	{
		if (GetRainmeter().GetDebug()) LogDebugF(m_Skin, L"Reading file: %s (Temp: %s)", iniFile.c_str(), iniRead.c_str());
	}
	else
	{
		if (GetRainmeter().GetDebug()) LogDebugF(m_Skin, L"Reading file: %s", iniFile.c_str());
		iniRead = iniFile;
	}

	// Get all the sections (i.e. different meters)
	std::list<std::wstring> sections;
	std::unordered_set<std::wstring> unique;
	std::wstring key, value;  // buffer

	DWORD itemsSize = MAX_LINE_LENGTH;
	WCHAR* items = new WCHAR[itemsSize];
	WCHAR* pos = nullptr;
	WCHAR* epos = nullptr;

	if (skinSection == nullptr)
	{
		// Get all the sections
		do
		{
			items[0] = 0;
			DWORD res = GetPrivateProfileSectionNames(items, itemsSize, iniRead.c_str());
			if (res == 0)		// File not found
			{
				delete [] items;
				if (temporary) System::RemoveFile(iniRead);
				return;
			}
			if (res < itemsSize - 2)		// Fits in the buffer
			{
				epos = items + res;
				break;
			}

			delete [] items;
			itemsSize *= 2;
			items = new WCHAR[itemsSize];
		}
		while (true);

		// Read the sections
		pos = items;
		while (pos < epos)
		{
			if (*pos)
			{
				value = pos;  // section name
				StrToUpperC(key.assign(value));
				if (unique.insert(key).second)
				{
					if (m_FoundSections.insert(key).second)
					{
						m_Sections.insert(m_SectionInsertPos, value);
					}
					sections.push_back(value);
				}
				pos += value.size() + 1;
			}
			else  // Empty string
			{
				++pos;
			}
		}
	}
	else
	{
		// Special case: Read only "Rainmeter" and specified section from "Rainmeter.ini"
		const std::wstring strRainmeter = L"Rainmeter";
		const std::wstring strFolder = skinSection;

		sections.push_back(strRainmeter);
		sections.push_back(strFolder);
//.........这里部分代码省略.........
开发者ID:Crawping,项目名称:rainmeter,代码行数:101,代码来源:ConfigParser.cpp

示例15: Error

bool RTMPMP4Stream::Play(std::wstring& url)
{
	char filename[1024];

	//Print it
	snprintf(filename,1024,"%ls",url.c_str());

	//Open it and play
	if (!streamer.Open(filename))
	{
		//Send error comand
		SendCommand(L"onStatus", new RTMPNetStatusEvent(L"NetStream.Play.StreamNotFound",L"error",L"Stream not found"));
		//Error
		return Error("Error opening mp4 file [path:\"%ls\"",filename);
	}
	
	//Send play comand
	SendCommand(L"onStatus", new RTMPNetStatusEvent(L"NetStream.Play.Reset",L"status",L"Playback reset") );

	//Send play comand
	SendCommand(L"onStatus", new RTMPNetStatusEvent(L"NetStream.Play.Start",L"status",L"Playback started") );

	//Create metadata object
	RTMPMetaData *meta = new RTMPMetaData(0);

	//Set name
	meta->AddParam(new AMFString(L"onMetaData"));

	//Create properties string
	AMFEcmaArray *prop = new AMFEcmaArray();

	//Add default properties
	if (streamer.HasAudioTrack())
	{
		switch (streamer.GetAudioCodec())
		{
			case AudioCodec::PCMU:
				//Set properties
				prop->AddProperty(L"audiocodecid"	,(float)RTMPAudioFrame::SPEEX	);	//Number Audio codec ID used in the file (see E.4.2.1 for available SoundFormat values)
				prop->AddProperty(L"audiodatarate"	,(float)16000			);	// Number Audio bit rate in kilobits per second
				//Set decoder
				decoder = new PCMUCodec();
				//Set encode
				encoder = new SpeexCodec();
				break;
			case AudioCodec::PCMA:
				prop->AddProperty(L"audiocodecid"	,(float)RTMPAudioFrame::SPEEX	);	//Number Audio codec ID used in the file (see E.4.2.1 for available SoundFormat values)
				prop->AddProperty(L"audiodatarate"	,(float)16000			);	// Number Audio bit rate in kilobits per second
				//Set decoder
				decoder = new PCMACodec();
				//Set encode
				encoder = new SpeexCodec();
				break;
		}
		//prop->AddProperty(L"stereo"		,new AMFBoolean(false)	);	// Boolean Indicating stereo audio
		prop->AddProperty(L"audiodelay"		,0.0	);	// Number Delay introduced by the audio codec in seconds
		prop->AddProperty(L"audiosamplerate"	,8000.0	);	// Number Frequency at which the audio stream is replayed
		prop->AddProperty(L"audiosamplesize"	,160.0	);	// Number Resolution of a single audio sample
	}

	//If ti has video track
	if (streamer.HasVideoTrack())
	{
		switch (streamer.GetVideoCodec())
		{
			case VideoCodec::H263_1996:
			case VideoCodec::H263_1998:
				prop->AddProperty(L"videocodecid"	,(float)RTMPVideoFrame::FLV1	);	// Number Video codec ID used in the file (see E.4.3.1 for available CodecID values)
				break;
			case VideoCodec::H264:
				prop->AddProperty(L"videocodecid"	,new AMFString(L"avc1")		);	// Number Video codec ID used in the file (see E.4.3.1 for available CodecID values)
				break;
		}

		prop->AddProperty(L"framerate"		,(float)streamer.GetVideoFramerate()	);	// Number Number of frames per second
		prop->AddProperty(L"height"		,(float)streamer.GetVideoHeight()	);	// Number Height of the video in pixels
		prop->AddProperty(L"videodatarate"	,(float)streamer.GetVideoBitrate()/1024	);	// Number Video bit rate in kilobits per second
		prop->AddProperty(L"width"		,(float)streamer.GetVideoWidth()	);	// Number Width of the video in pixels
	}

	prop->AddProperty(L"canSeekToEnd"	,0.0	);			// Boolean Indicating the last video frame is a key frame
	prop->AddProperty(L"duration"		,(float)streamer.GetDuration());	// Number Total duration of the file in seconds

	//Add param
	meta->AddParam(prop);

	//Send metadata
	PlayMetaData(meta);

	//Get AVC descriptor if any
	desc = streamer.GetAVCDescriptor();

	//If we have one
	if (desc)
	{
		//Create the frame
		RTMPVideoFrame fdesc(0,desc);
		//Play it
		PlayMediaFrame(&fdesc);
	}
//.........这里部分代码省略.........
开发者ID:chenxiuheng,项目名称:mcumediaserver,代码行数:101,代码来源:rtmpmp4stream.cpp


注:本文中的std::wstring::c_str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。