本文整理汇总了C++中CAtlString::Tokenize方法的典型用法代码示例。如果您正苦于以下问题:C++ CAtlString::Tokenize方法的具体用法?C++ CAtlString::Tokenize怎么用?C++ CAtlString::Tokenize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAtlString
的用法示例。
在下文中一共展示了CAtlString::Tokenize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readConfiguration
HRESULT IGConfigManager::readConfiguration (HINSTANCE hInstance, LPCWSTR pwConfigRes, BOOL bOverwrite)
{
// read the config file
HANDLE hFile = ::CreateFile (m_wsConfigPath.c_str(), GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (bOverwrite)
{
if (hFile == INVALID_HANDLE_VALUE)
{
return E_FAIL; // cannot overwrite non existing file
}
else
{
::CloseHandle (hFile);
BOOL bSuccess = ::DeleteFile (m_wsConfigPath.c_str());
if (bSuccess)
hFile = INVALID_HANDLE_VALUE;
else
return E_FAIL; // impossible to delete corrupted file
}
}
int nRes = ::SHCreateDirectory (NULL, m_wsUserHistoryPath.c_str());
if ((nRes != ERROR_SUCCESS) && (nRes != ERROR_FILE_EXISTS) && (nRes != ERROR_ALREADY_EXISTS))
return E_FAIL;
// delete all history files
if ((nRes == ERROR_FILE_EXISTS) || (nRes == ERROR_ALREADY_EXISTS))
deleteHistory();
HRESULT hr = S_OK;
if (!m_spXMLDoc)
hr = ::CoCreateInstance(CLSID_DOMDocument30, NULL, CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument, (void**)&m_spXMLDoc);
if (FAILED(hr))
return E_FAIL;
char *pXmlFileBuffer = NULL;
if (hFile == INVALID_HANDLE_VALUE)
{
CAtlString strConfigPath (IGCONFIGMANAGER_CONFIGPATH);
CAtlString resToken, nextToken, nextNextToken;
int curPos = 0;
wstring wsConstructPath (m_wsUserPath);
nextToken = strConfigPath.Tokenize(_T("\\"), curPos);
nextNextToken = strConfigPath.Tokenize(_T("\\"), curPos);
do
{
resToken = nextToken;
nextToken = nextNextToken;
nextNextToken = strConfigPath.Tokenize(_T("\\"), curPos);
wsConstructPath += L"\\" + resToken;
::CreateDirectory (wsConstructPath.c_str(), NULL);
}while (nextNextToken != _T(""));
hFile = ::CreateFile (m_wsConfigPath.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
return E_FAIL;
// File does not exist, open the default config file
char *pValidXml = IGConfigManager::CreateBufferFromRes (hInstance, pwConfigRes, L"Configuration");
VARIANT_BOOL bSucceeded;
hr = m_spXMLDoc->loadXML (CComBSTR(pValidXml), &bSucceeded);
if ((hr != S_OK) || !bSucceeded)
return E_FAIL;
delete [] pValidXml;
::CloseHandle (hFile);
}
else
{
::CloseHandle (hFile);
VARIANT_BOOL bSucceeded;
hr = m_spXMLDoc->load (CComVariant(m_wsConfigPath.c_str()), &bSucceeded);
if ((hr != S_OK) || !bSucceeded)
return E_FAIL;
}
if (m_spNodeCommonConfig)
m_spNodeCommonConfig.Release();
hr = m_spXMLDoc->selectSingleNode (CComBSTR("./Common"), &m_spNodeCommonConfig);
if ((hr != S_OK) || !m_spNodeCommonConfig)
return E_FAIL;
// get user picture folder
if (m_spNodeUserPicturesPath)
m_spNodeUserPicturesPath.Release();
hr = m_spNodeCommonConfig->selectSingleNode (CComBSTR("./UserPicturesPath"), &m_spNodeUserPicturesPath);
if ((hr != S_OK) || !m_spNodeUserPicturesPath)
return E_FAIL;
VARIANT_BOOL bHasChild = VARIANT_FALSE;
m_spNodeUserPicturesPath->hasChildNodes (&bHasChild);
if (m_spNodeUserPicturesPathValue)
m_spNodeUserPicturesPathValue.Release();
if (bHasChild)
m_spNodeUserPicturesPath->get_firstChild (&m_spNodeUserPicturesPathValue);
// get picture list
if (m_spNodeListPicturesPath)
m_spNodeListPicturesPath.Release();
hr = m_spNodeCommonConfig->selectSingleNode (CComBSTR("./Pictures"), &m_spNodeListPicturesPath);
if ((hr != S_OK) || !m_spNodeListPicturesPath)
//.........这里部分代码省略.........