本文整理汇总了C++中CStdStringA类的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringA类的具体用法?C++ CStdStringA怎么用?C++ CStdStringA使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CStdStringA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CCharsetConverter::utf8ToStringCharset(const CStdStringA& strSource, CStdStringA& strDest)
{
if (m_iconvUtf8ToStringCharset == (iconv_t) - 1)
{
CStdString strCharset=g_langInfo.GetGuiCharSet();
m_iconvUtf8ToStringCharset = iconv_open(strCharset.c_str(), UTF8_SOURCE);
}
if (m_iconvUtf8ToStringCharset != (iconv_t) - 1)
{
const char* src = strSource.c_str();
size_t inBytes = strSource.length() + 1;
char *dst = strDest.GetBuffer(inBytes);
size_t outBytes = inBytes - 1;
if (iconv_const(m_iconvUtf8ToStringCharset, &src, &inBytes, &dst, &outBytes) == (size_t) -1)
{
strDest.ReleaseBuffer();
// For some reason it failed (maybe wrong charset?). Nothing to do but
// return the original..
strDest = strSource;
}
strDest.ReleaseBuffer();
}
}
示例2: sizeof
void CCharsetConverter::utf16BEtoUTF8(const CStdStringW& strSource, CStdStringA &strDest)
{
if (m_iconvUtf16BEtoUtf8 == (iconv_t) - 1)
m_iconvUtf16BEtoUtf8 = iconv_open("UTF-8", "UTF-16BE");
if (m_iconvUtf16BEtoUtf8 != (iconv_t) - 1)
{
size_t inBytes = (strSource.length() + 1) * sizeof(wchar_t);
size_t outBytes = (strSource.length() + 1) * 4;
const char *src = (const char*) strSource.c_str();
char *dst = strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf16BEtoUtf8, &src, &inBytes, &dst, &outBytes))
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
if (iconv(m_iconvUtf16BEtoUtf8, NULL, NULL, &dst, &outBytes))
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}
示例3: subtitleCharsetToW
void CCharsetConverter::subtitleCharsetToW(const CStdStringA& strSource, CStdStringW& strDest)
{
CStdStringA strFlipped;
// No need to flip hebrew/arabic as mplayer does the flipping
if (m_iconvSubtitleCharsetToW == (iconv_t) - 1)
{
CStdString strCharset=g_langInfo.GetSubtitleCharSet();
m_iconvSubtitleCharsetToW = iconv_open(WCHAR_CHARSET, strCharset.c_str());
}
if (m_iconvSubtitleCharsetToW != (iconv_t) - 1)
{
const char* src = strSource.c_str();
size_t inBytes = strSource.length() + 1;
char *dst = (char*)strDest.GetBuffer(inBytes * sizeof(wchar_t));
size_t outBytes = inBytes * sizeof(wchar_t);
if (iconv_const(m_iconvSubtitleCharsetToW, &src, &inBytes, &dst, &outBytes))
{
strDest.ReleaseBuffer();
// For some reason it failed (maybe wrong charset?). Nothing to do but
// return the original..
strDest = strSource;
}
strDest.ReleaseBuffer();
}
}
示例4: ReadASCIIString
CStdString DocReader::ReadASCIIString(int iOffset, int iCharCount)
{
CStdStringA sResult;
ReadIntoBufferIgnoringBitsInDeletedList(iOffset, iCharCount, sResult.GetBuffer(iCharCount + 1), iCharCount+2);
sResult.ReleaseBuffer();
return sResult;
}
示例5: CreateRegisterCommandString
bool DotNetRegistrar::RegisterItem()
{
CStdString sFileName;
CStdString sParams;
CreateRegisterCommandString(sFileName, sParams);
if(_taccess(GetNameOfErrorLogFile().c_str(), 00) == 0)
_tremove(GetNameOfErrorLogFile().c_str());
CFilePath exePath( GetDotNetRegistrationFileName() ); //this was retrieved in CreateRegisterCommandString, but we want one without enclosing quotes
CStdStringA sCommand ;
sCommand.Format("\"%s\" %s", CStdStringA(exePath.GetFileName()), CStdStringA( sParams ) );
//Batch file will contain just the executable name, not path. Working directory is assumed
//by ExecuteAndWait to be the execution directory.
CStdString sBatchFile = GetExecutionPath() + _T("\\Register.bat");
_tremove( sBatchFile.c_str());
CreateTextFile( sBatchFile, sCommand );
ASSERT( CGeneral::FileExists( sBatchFile ));
ExecuteAndWait(sBatchFile, _T(""));
_tremove( sBatchFile.c_str());
if (ErrorOccurred())
{
std::vector<CStdString> Errors = GetErrorsFromFile();
std::vector<CStdString>::iterator it;
for(it = Errors.begin(); it != Errors.end(); ++it)
{
ReportEvent(EVENTLOG_ERROR_TYPE, 0, *it);
}
return false;
}
return true;
}
示例6: while
void CCharsetConverter::utf32ToStringCharset(const unsigned long* strSource, CStdStringA& strDest)
{
if (m_iconvUtf32ToStringCharset == (iconv_t) - 1)
{
CStdString strCharset=g_langInfo.GetGuiCharSet();
m_iconvUtf32ToStringCharset = iconv_open(strCharset.c_str(), "UTF-32LE");
}
if (m_iconvUtf32ToStringCharset != (iconv_t) - 1)
{
const unsigned long* ptr=strSource;
while (*ptr) ptr++;
const char* src = (const char*) strSource;
size_t inBytes = (ptr-strSource+1)*4;
char *dst = strDest.GetBuffer(inBytes);
size_t outBytes = inBytes;
if (iconv_const(m_iconvUtf32ToStringCharset, &src, &inBytes, &dst, &outBytes))
{
strDest.ReleaseBuffer();
// For some reason it failed (maybe wrong charset?). Nothing to do but
// return the original..
strDest = (const char *)strSource;
}
strDest.ReleaseBuffer();
}
}
示例7: fileName
void DocXDocumentStore::GetDocumentTexts(const CStdString& sFileName, std::vector<std::string>& vDocumentTexts) const
{
vDocumentTexts.clear();
CZipArchive zipArchive;
zipArchive.Open(sFileName, CZipArchive::zipOpenReadOnly);
if( !zipArchive.IsClosed() )
{
CZipWordArray ar;
zipArchive.FindMatches( L"word\\\\*.xml", ar );
for( int uIndex = 0; uIndex < ar.GetSize(); uIndex++ )
{
CZipFileHeader fhInfo;
if( zipArchive.GetFileInfo( fhInfo, ar[uIndex] ) )
{
const CZipString fileName( fhInfo.GetFileName() );
if( fileName.find_first_of( '\\' ) == fileName.find_last_of( '\\' ) )
{
C2007DocFile mf;
zipArchive.ExtractFile( ar[uIndex], mf );
const CStdStringA sDocText = mf.GetWTInnerText();
if( sDocText.size() > 0 )
vDocumentTexts.push_back( sDocText );
}
}
}
zipArchive.Flush();
zipArchive.Close();
}
}
示例8: LoadLibrary
void ActivationContextLoader::LoadDll()
{
// Get a handle to the DLL module.
CPath dllPath;
dllPath.Combine(GetModulePath(), WS_ACTIVATIONCONTEXTLOADER_DLL);
m_hinstLib = LoadLibrary(dllPath);
// If the handle is valid, try to get the function address.
if (m_hinstLib != NULL)
{
m_funcLAC = (LAC) GetProcAddress(m_hinstLib, WS_ACLOADFUNC);
m_funcULAC = (ULAC) GetProcAddress(m_hinstLib, WS_ACUNLOADFUNC);
m_funcIAAFM = (IAAFM) GetProcAddress(m_hinstLib, WS_ACALREADYACTIVEFUNC);
}
else
{
CStdStringA msg;
msg.Format("LoadLibrary on '%s'failed. Error code: %d.", WS_ACTIVATIONCONTEXTLOADER_DLL_A, GetLastError());
throw std::exception(msg);
}
}
示例9: FormatThousands
CStdStringA RomanIndexFormatter::FormatThousands(int iValue)
{
int iThousands = iValue / 1000;
CStdStringA sResult;
sResult.resize(iThousands, 'M');
return sResult;
}
示例10: while
void CCharsetConverter::utf16LEtoUTF8(const void *strSource,
CStdStringA &strDest)
{
if (m_iconvUtf16LEtoUtf8 == (iconv_t) - 1)
m_iconvUtf16LEtoUtf8 = iconv_open("UTF-8", "UTF-16LE");
if (m_iconvUtf16LEtoUtf8 != (iconv_t) - 1)
{
size_t inBytes = 2;
uint16_t *s = (uint16_t *)strSource;
while (*s != 0)
{
s++;
inBytes += 2;
}
// UTF-8 is up to 4 bytes/character, or up to twice the length of UTF-16
size_t outBytes = inBytes * 2;
const char *src = (const char *)strSource;
char *dst = strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf16LEtoUtf8, &src, &inBytes, &dst, &outBytes) ==
(size_t)-1)
{ // failed :(
strDest.clear();
strDest.ReleaseBuffer();
return;
}
strDest.ReleaseBuffer();
}
}
示例11: ResolveSubstDriveInPath
bool NetworkDriveHelper::ShareTestFolder()
{
NET_API_STATUS res;
DWORD parm_err = 0;
wchar_t netName[MAX_PATH];
wchar_t path[MAX_PATH];
wchar_t remarks[MAX_PATH];
CStdStringA sTestPath = ResolveSubstDriveInPath(GET_TEST_TEMP_PATH(_T("")));
if (sTestPath.Right(1) == "\\")
sTestPath = sTestPath.Left( sTestPath.length() -1 ); // Remove last backslash.
mbstowcs( netName, TESTSHARE, MAX_PATH );
mbstowcs( path, sTestPath, MAX_PATH );
mbstowcs( remarks, "Workshare Local File Store testing share", MAX_PATH );
SHARE_INFO_2 p;
memset(&p, 0, sizeof(SHARE_INFO_2));
p.shi2_netname = netName;
p.shi2_type = STYPE_DISKTREE;
p.shi2_remark = NULL;
p.shi2_permissions = 0;
p.shi2_max_uses = -1;
p.shi2_current_uses = 0;
p.shi2_path = path;
p.shi2_passwd = NULL;
res = NetShareAdd(NULL, 2, (LPBYTE) &p, &parm_err);
if (res == NERR_DuplicateShare) // Already shared.
return true;
ASSERT(res != NERR_UnknownDevDir);
return res == 0;
}
示例12: localWideToUtf
CStdStringA localWideToUtf(LPCWSTR wstr)
{
if (wstr == NULL)
return "";
int bufSize = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
CStdStringA strA ("", bufSize);
if ( bufSize == 0 || WideCharToMultiByte(CP_UTF8, 0, wstr, -1, strA.GetBuf(bufSize), bufSize, NULL, NULL) != bufSize )
strA.clear();
strA.RelBuf();
return strA;
}
示例13: sDestFileName
void TestSnapshotSaver::TestSaveBufferToTempFile()
{
const CStdString sDestFileName( SnapshotSaver::SaveBufferToTempFile( _T("This is silly data") ) );
CStdStringA sRtfBuffer;
std::ifstream file( sDestFileName );
file.get( sRtfBuffer.GetBuffer(100), 100 );
sRtfBuffer.ReleaseBuffer();
::DeleteFile( sDestFileName.c_str() );
assertTest( sRtfBuffer = _T("This is silly data") );
}
示例14: UnloadDll
void ActivationContextLoader::UnloadDll()
{
if(m_hinstLib)
{
if (FALSE == FreeLibrary(m_hinstLib))
{
CStdStringA msg;
msg.Format("FreeLibrary on '%s'failed. Error code: %d.", WS_ACTIVATIONCONTEXTLOADER_DLL_A, GetLastError());
throw std::exception(msg);
}
}
}
示例15: DebugDumpStructureToFile
void CRTFTablePostProcessor::DebugDumpStructureToFile(int iSuffix, LPCSTR szContext)
{
if (m_prtfFile->GetModality() == 0)
return;
CStdStringA csFileName;
csFileName.Format("c:\\BHTableDump%d%c.txt",iSuffix, m_prtfFile->GetModality() == 1 ? 'O' : 'M');
if(FILE *fp = fopen(csFileName, "w"))
{
fprintf( fp, "%s - Starting at %d\n", szContext, m_iStart);
m_pParentCollection->Dump(fp, true);
fclose(fp);
}
}