本文整理汇总了C++中CStdStringA::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringA::c_str方法的具体用法?C++ CStdStringA::c_str怎么用?C++ CStdStringA::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringA
的用法示例。
在下文中一共展示了CStdStringA::c_str方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CCharsetConverter::stringCharsetToUtf8(const CStdStringA& strSourceCharset, const CStdStringA& strSource, CStdStringA& strDest)
{
iconv_t iconvString=iconv_open("UTF-8", strSourceCharset.c_str());
if (iconvString != (iconv_t) - 1)
{
const char* src = strSource.c_str();
size_t inBytes = strSource.length() + 1;
size_t outBytes = (inBytes * 4) + 1;
char *dst = strDest.GetBuffer(outBytes);
if (iconv_const(iconvString, &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;
return ;
}
strDest.ReleaseBuffer();
iconv_close(iconvString);
}
}
示例2:
void CCharsetConverter::stringCharsetToUtf8(const CStdStringA& strSourceCharset, const CStdStringA& strSource, CStdStringA& strDest)
{
iconv_t iconvString=iconv_open("UTF-8", strSourceCharset.c_str());
if (iconvString != (iconv_t) - 1)
{
size_t inBytes = (strSource.length() + 1);
size_t outBytes = (strSource.length() + 1) * 4;
const char *src = strSource.c_str();
char *dst = strDest.GetBuffer(outBytes);
if (iconv_const(iconvString, &src, &inBytes, &dst, &outBytes) == (size_t) -1)
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
if (iconv(iconvString, NULL, NULL, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
iconv_close(iconvString);
}
}
示例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: GetFormattedTime
CStdStringA TerDateTimeFormatter::GetFormattedTime(SYSTEMTIME& st, const CStdStringA& sFormatPicture)
{
CStdString sDate;
int ir = GetTimeFormat(m_locale, 0, &st, sFormatPicture.c_str(), sDate.GetBuffer(MAX_PATH), MAX_PATH);
sDate.ReleaseBuffer();
return sDate;
}
示例5: logicalToVisualBiDi
// The bVisualBiDiFlip forces a flip of characters for hebrew/arabic languages, only set to false if the flipping
// of the string is already made or the string is not displayed in the GUI
void CCharsetConverter::utf8ToW(const CStdStringA& utf8String, CStdStringW &wString, bool bVisualBiDiFlip/*=true*/)
{
CStdStringA strFlipped;
const char* src;
size_t inBytes;
// Try to flip hebrew/arabic characters, if any
if (bVisualBiDiFlip)
{
logicalToVisualBiDi(utf8String, strFlipped, FRIBIDI_CHAR_SET_UTF8);
src = strFlipped.c_str();
inBytes = strFlipped.length() + 1;
}
else
{
src = utf8String.c_str();
inBytes = utf8String.length() + 1;
}
if (m_iconvUtf8toW == (iconv_t) - 1)
m_iconvUtf8toW = iconv_open(WCHAR_CHARSET, UTF8_SOURCE);
if (m_iconvUtf8toW != (iconv_t) - 1)
{
size_t outBytes = inBytes * sizeof(wchar_t);
char * dst = (char*)wString.GetBuffer(outBytes);
if (iconv_const(m_iconvUtf8toW, &src, &inBytes, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
wString.ReleaseBuffer();
wString = utf8String;
return;
}
if (iconv(m_iconvUtf8toW, NULL, NULL, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
wString.ReleaseBuffer();
wString = utf8String;
return;
}
wString.ReleaseBuffer();
}
}
示例6: RTFfield
DocFileField::DocFileField(const WrdCharacterProperties& props, WordParserInfo& wpi) : RTFfield(wpi.GetFileContext())
{
the_RTFFieldInst = new RTFfldinst(m_pContext);
CStdStringA sFont = wpi.m_FontTable.getFontFamilyName(props.getFontIndexForSymbol()).getFaceName().c_str();
if ((int)sFont.find(" ") > 0)
{
sFont = "\"" + sFont + "\"";
}
CStdStringA sInst;
if (1 & props.getFontSize())
sInst.Format("SYMBOL %d \\f %s \\s %.1f", props.getSymbolCharacter() & 0xFF, sFont.c_str(), ((double)props.getFontSize())/2);
else
sInst.Format("SYMBOL %d \\f %s \\s %d", props.getSymbolCharacter() & 0xFF, sFont.c_str(), props.getFontSize()/2);
the_RTFFieldInst->AddObject(new DocFilePCData(m_pContext, sInst));
CreateResult();
// the_RTFFieldResult->AddObject( new DocFileChrfmt(props , wpi, false) );//TODO - need a double check
}
示例7: logicalToVisualBiDi
// The bVisualBiDiFlip forces a flip of characters for hebrew/arabic languages, only set to false if the flipping
// of the string is already made or the string is not displayed in the GUI
void CCharsetConverter::utf8ToW(const CStdStringA& utf8String, CStdStringW &wString, bool bVisualBiDiFlip/*=true*/)
{
CStdStringA strFlipped;
const char* src;
size_t inBytes;
// Try to flip hebrew/arabic characters, if any
if (bVisualBiDiFlip)
{
logicalToVisualBiDi(utf8String, strFlipped, FRIBIDI_CHAR_SET_UTF8);
src = strFlipped.c_str();
inBytes = strFlipped.length() + 1;
}
else
{
src = utf8String.c_str();
inBytes = utf8String.length() + 1;
}
if (m_iconvUtf8toW == (iconv_t) - 1)
m_iconvUtf8toW = iconv_open(WCHAR_CHARSET, UTF8_SOURCE);
if (m_iconvUtf8toW != (iconv_t) - 1)
{
char *dst = new char[inBytes * sizeof(wchar_t)];
size_t outBytes = inBytes * sizeof(wchar_t);
char *outdst = dst;
if (iconv_const(m_iconvUtf8toW, &src, &inBytes, &outdst, &outBytes))
{
// For some reason it failed (maybe wrong charset?). Nothing to do but
// return the original..
wString = utf8String;
}
else
{
wString = (WCHAR *)dst;
}
delete[] dst;
}
}
示例8: CopyTestFileToTempFile
CStdString CTestUtils::CopyTestFileToTempFile(const CStdString& sSource)
{
if(_taccess(sSource, 0) != 0)
{
CStdStringA sError;
sError.Format("CTestUtils::CopyTestFileToTempFile - source file (%s) doesn't exist.", sSource.c_str());
throw std::exception(sError.c_str());
}
TCHAR szTempPath[ MAX_PATH ] = {0};
::GetTempPath( MAX_PATH, szTempPath );
TCHAR szTempFileName[MAX_PATH] = {0};
::GetTempFileName( szTempPath, _T( "wst" ), 0, szTempFileName );
if (!CopyFile(sSource.c_str(), szTempFileName, false))
{
CStdStringA sError;
sError.Format("CTestUtils::CopyTestFileToTempFile copy file failed - source file (%s) destination file (%s)", sSource.c_str(), szTempFileName);
throw std::exception(sError.c_str());
}
return CStdString(szTempFileName);
}
示例9: 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)
{
size_t inBytes = (strSource.length() + 1);
size_t outBytes = (strSource.length() + 1) * sizeof(wchar_t);
const char *src = strSource.c_str();
char *dst = (char*)strDest.GetBuffer(outBytes);
if (iconv_const(m_iconvSubtitleCharsetToW, &src, &inBytes, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
if (iconv_const(m_iconvSubtitleCharsetToW, NULL, NULL, &dst, &outBytes) == (size_t)-1)
{
CLog::Log(LOGERROR, "%s failed cleanup", __FUNCTION__);
strDest.ReleaseBuffer();
strDest = strSource;
return;
}
strDest.ReleaseBuffer();
}
}
示例10: ProcessCommand
BOOL CServer::ProcessCommand(CAdminSocket *pAdminSocket, int nID, unsigned char *pData, int nDataLength)
{
switch (nID)
{
case 2:
if (!nDataLength) {
unsigned char buffer[2];
buffer[0] = m_nServerState / 256;
buffer[1] = m_nServerState % 256;
pAdminSocket->SendCommand(1, 2, buffer, 2);
}
else if (nDataLength == 2) {
ToggleActive(*pData * 256 + pData[1]);
unsigned char buffer[2];
buffer[0] = m_nServerState / 256;
buffer[1] = m_nServerState % 256;
pAdminSocket->SendCommand(1, 2, buffer, 2);
}
else
pAdminSocket->SendCommand(1, 1, "\001Protocol error: Unexpected data length", strlen("\001Protocol error: Unexpected data length") + 1);
break;
case 3:
if (!nDataLength) {
pAdminSocket->SendCommand(1, 1, "\001Protocol error: Unexpected data length", strlen("\001Protocol error: Unexpected data length") + 1);
}
else if (*pData == USERCONTROL_GETLIST) {
int len = 4;
std::map<int, t_connectiondata>::iterator iter;
for (iter = m_UsersList.begin(); iter != m_UsersList.end(); ++iter) {
const t_connectiondata& data = iter->second;
auto ip = ConvToNetwork(data.ip);
auto user = ConvToNetwork(data.user);
len += 4 + ip.size() + 2 + 4 + user.size() + 2 + 1;
if (data.transferMode) {
auto physicalFile = ConvToNetwork(data.physicalFile);
auto logicalFile = ConvToNetwork(data.logicalFile);
len += 2 + physicalFile.size() + 2 + logicalFile.size();
if (data.currentOffset != 0)
len += 8;
if (data.totalSize != -1)
len += 8;
}
}
unsigned char *buffer = new unsigned char[len];
buffer[0] = USERCONTROL_GETLIST;
buffer[1] = ((m_UsersList.size() / 256) / 256) & 0xff;
buffer[2] = (m_UsersList.size() / 256) & 0xff;
buffer[3] = m_UsersList.size() % 256;
unsigned char *p = buffer + 4;
for (iter = m_UsersList.begin(); iter != m_UsersList.end(); ++iter) {
const t_connectiondata& data = iter->second;
auto ip = ConvToNetwork(data.ip);
auto user = ConvToNetwork(data.user);
memcpy(p, &data.userid, 4);
p += 4;
*p++ = (ip.size() / 256) & 0xff;
*p++ = ip.size() % 256;
memcpy(p, ip.c_str(), ip.size());
p += ip.size();
memcpy(p, &data.port, 4);
p += 4;
*p++ = (user.size() / 256) & 0xff;
*p++ = user.size() % 256;
memcpy(p, user.c_str(), user.size());
p += user.size();
*p = data.transferMode;
if (data.transferMode) {
// Bit 5 and 6 indicate presence of currentOffset and totalSize.
if (data.currentOffset != 0) {
*p |= 0x20;
}
if (data.totalSize != -1) {
*p |= 0x40;
}
p++;
auto physicalFile = ConvToNetwork(data.physicalFile);
*p++ = (physicalFile.size() / 256) & 0xff;
*p++ = physicalFile.size() % 256;
memcpy(p, physicalFile.c_str(), physicalFile.size());
p += physicalFile.size();
auto logicalFile = ConvToNetwork(data.logicalFile);
*p++ = (logicalFile.size() / 256) & 0xff;
*p++ = logicalFile.size() % 256;
memcpy(p, logicalFile.c_str(), logicalFile.size());
p += logicalFile.size();
if (data.currentOffset != 0) {
memcpy(p, &data.currentOffset, 8);
p += 8;
}
if (data.totalSize != -1) {
memcpy(p, &data.totalSize, 8);
p += 8;
//.........这里部分代码省略.........
示例11: CchFetchLpszError
long PASCAL CchFetchLpszError(long fce, char FAR *lpszError, long cb)
{
CStdStringA sErrorMessage;
switch( fce )
{
default:
{
int nSolidError = -( fce - fceWorkshareLastDefined );
switch( nSolidError )
{
default:
return 0;
case Solid::Canceled:
sErrorMessage = "Pdf conversion cancelled\0";
break;
case Solid::BadData:
sErrorMessage = "The Pdf document may be corrupt\0";
break;
case Solid::IOError:
sErrorMessage = "Pdf conversion IO error\0";
break;
case Solid::IOFileLocked:
sErrorMessage = "Pdf conversion IO file locked\0";
break;
case Solid::ProtectedFile:
sErrorMessage = "Workshare is unable to open Pdf files with copy protection\0";
break;
case Solid::InternalError:
sErrorMessage = "Pdf conversion internal error\0";
break;
case Solid::InvalidPagesRange:
sErrorMessage = "Pdf conversion invalid page range\0";
break;
case Solid::NoBppConversion:
sErrorMessage = "Pdf bits per pixel conversion failed\0";
break;
case Solid::NoGrayScale:
sErrorMessage = "Pdf gray scale conversion failed\0";
break;
case Solid::PSDUnsupportedMode:
sErrorMessage = "Pdf is password protected, unable to convert\0";
break;
case Solid::TablesNotFound:
sErrorMessage = "Pdf conversion found no tables to extract\0";
break;
case Solid::ImagesNotFound:
sErrorMessage = "Pdf conversion found no images to extract\0";
break;
case Solid::UnsupportedEncryptionHandler:
sErrorMessage = "Pdf has unsupported encryption\0";
break;
case Solid::MissingCertificate:
sErrorMessage = "Pdf has missing certifucate\0";
break;
case Solid::Unknown:
sErrorMessage = "An unknown error has occured\0";
break;
}
break;
}
case fceOpenInFileErr:
sErrorMessage = "Could not open input file\0";
break;
case fceReadErr:
sErrorMessage = "Error during read\0";
break;
case fceWriteErr:
sErrorMessage = "Error during write\0";
break;
case fceInvalidFile:
sErrorMessage = "Invalid data in conversion file\0";
break;
case fceNoMemory:
sErrorMessage = "Out of memory\0";
break;
case fceOpenOutFileErr:
sErrorMessage = "Could not open output file\0";
break;
case fceUserCancel:
sErrorMessage = "Conversion cancelled by user\0";
break;
case fceWrongFileType:
sErrorMessage = "Wrong file type for this converter\0";
break;
case fceWorkshareNotLicensed:
sErrorMessage = "Workshare needs to be licensed for Protect to enable this functionality\0";
break;
case fceWorkshareExportNotImplimented:
sErrorMessage = "Workshare does not provide save functionality for Pdf files\0";
break;
case fceWorkshareNoConcurrentConversions:
sErrorMessage = "Conversions cannot run concurrently\0";
break;
}
if( cb > (long)sErrorMessage.length() )
{
strcpy_s( lpszError, cb, sErrorMessage.c_str() );
return (long)sErrorMessage.length();
//.........这里部分代码省略.........