本文整理汇总了C++中CFX_WideString::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CFX_WideString::GetBuffer方法的具体用法?C++ CFX_WideString::GetBuffer怎么用?C++ CFX_WideString::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFX_WideString
的用法示例。
在下文中一共展示了CFX_WideString::GetBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRange
void CFDE_TxtEdtBuf::GetRange(CFX_WideString& wsText,
int32_t nBegin,
int32_t nLength) const {
FDE_CHUNKPLACE cp;
Index2CP(nBegin, cp);
int32_t nLeave = nLength;
int32_t nCount = m_Chunks.GetSize();
FX_WCHAR* lpDstBuf = wsText.GetBuffer(nLength);
int32_t nChunkIndex = cp.nChunkIndex;
FDE_CHUNKHEADER* lpChunkHeader = m_Chunks[nChunkIndex];
int32_t nCopyLength = lpChunkHeader->nUsed - cp.nCharIndex;
FX_WCHAR* lpSrcBuf = lpChunkHeader->wChars + cp.nCharIndex;
while (nLeave > 0) {
if (nLeave <= nCopyLength) {
nCopyLength = nLeave;
}
FXSYS_memcpy(lpDstBuf, lpSrcBuf, nCopyLength * sizeof(FX_WCHAR));
nChunkIndex++;
if (nChunkIndex >= nCount) {
break;
}
lpChunkHeader = m_Chunks[nChunkIndex];
lpSrcBuf = lpChunkHeader->wChars;
nLeave -= nCopyLength;
lpDstBuf += nCopyLength;
nCopyLength = lpChunkHeader->nUsed;
}
wsText.ReleaseBuffer();
}
示例2: CutString
CFX_WideString Document::CutString(CFX_WideString cbFrom)
{
size_t iLength = cbFrom.GetLength();
pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t);
iSize *= (iLength + 1);
wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
for (int i = 0; i < iLength; i++)
{
if (pFrom[i] == L'\\' || pFrom[i] == L'/')
{
pResult[i] = L'\0';
break;
}
pResult[i] = pFrom[i];
}
pResult[iLength] = L'\0';
cbFrom.ReleaseBuffer();
CFX_WideString cbRet = CFX_WideString(pResult);
free(pResult);
pResult = NULL;
return cbRet;
}
示例3: ExtractSubString
FX_BOOL CPDF_TextPageFind::ExtractSubString(CFX_WideString& rString,
const FX_WCHAR* lpszFullString,
int iSubString,
FX_WCHAR chSep) {
if (!lpszFullString)
return FALSE;
while (iSubString--) {
lpszFullString = std::wcschr(lpszFullString, chSep);
if (!lpszFullString) {
rString.clear();
return FALSE;
}
lpszFullString++;
while (*lpszFullString == chSep)
lpszFullString++;
}
const FX_WCHAR* lpchEnd = std::wcschr(lpszFullString, chSep);
int nLen = lpchEnd ? (int)(lpchEnd - lpszFullString)
: (int)FXSYS_wcslen(lpszFullString);
ASSERT(nLen >= 0);
FXSYS_memcpy(rString.GetBuffer(nLen), lpszFullString,
nLen * sizeof(FX_WCHAR));
rString.ReleaseBuffer();
return TRUE;
}
示例4: GetString
int32_t CFDE_TxtEdtTextSet::GetString(FDE_TEXTEDITPIECE* pPiece,
CFX_WideString& wsText) {
FX_WCHAR* pBuffer = wsText.GetBuffer(pPiece->nCount);
for (int32_t i = 0; i < pPiece->nCount; i++) {
pBuffer[i] = m_pPage->GetChar(pPiece, i);
}
wsText.ReleaseBuffer(pPiece->nCount);
return pPiece->nCount;
}
示例5: FX_WideString_GetNormalization
FX_STRSIZE FX_WideString_GetNormalization(const CFX_WideStringC& wsSrc,
CFX_WideString& wsDst) {
FX_STRSIZE nLen = FX_WideString_GetNormalization(wsSrc, (FX_WCHAR*)NULL);
if (!nLen) {
return 0;
}
FX_WCHAR* pBuf = wsDst.GetBuffer(nLen);
FX_WideString_GetNormalization(wsSrc, pBuf);
wsDst.ReleaseBuffer(nLen);
return nLen;
}
示例6: CFX_WideString
CFX_WideString CFX_WideString::FromUTF16LE(const unsigned short* wstr, FX_STRSIZE wlen)
{
if (!wstr || 0 == wlen) {
return CFX_WideString();
}
CFX_WideString result;
FX_WCHAR* buf = result.GetBuffer(wlen);
for (int i = 0; i < wlen; i ++) {
buf[i] = wstr[i];
}
result.ReleaseBuffer(wlen);
return result;
}
示例7: SetText
void CFDE_TxtEdtEngine::SetText(const CFX_WideString& wsText) {
ResetEngine();
int32_t nLength = wsText.GetLength();
if (nLength > 0) {
CFX_WideString wsTemp;
FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nLength);
FXSYS_memcpy(lpBuffer, wsText.c_str(), nLength * sizeof(FX_WCHAR));
ReplaceParagEnd(lpBuffer, nLength, FALSE);
wsTemp.ReleaseBuffer(nLength);
if (m_nLimit > 0 && nLength > m_nLimit) {
wsTemp.Delete(m_nLimit, nLength - m_nLimit);
nLength = m_nLimit;
}
m_pTxtBuf->SetText(wsTemp);
}
m_pTxtBuf->Insert(nLength, &m_wLineEnd, 1);
RebuildParagraphs();
}
示例8: RecoverParagEnd
void CFDE_TxtEdtEngine::RecoverParagEnd(CFX_WideString& wsText) {
FX_WCHAR wc = (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CR) ? L'\n' : L'\r';
if (m_nFirstLineEnd == FDE_TXTEDIT_LINEEND_CRLF) {
CFX_ArrayTemplate<int32_t> PosArr;
int32_t nLength = wsText.GetLength();
int32_t i = 0;
FX_WCHAR* lpPos = const_cast<FX_WCHAR*>(wsText.c_str());
for (i = 0; i < nLength; i++, lpPos++) {
if (*lpPos == m_wLineEnd) {
*lpPos = wc;
PosArr.Add(i);
}
}
const FX_WCHAR* lpSrcBuf = wsText.c_str();
CFX_WideString wsTemp;
int32_t nCount = PosArr.GetSize();
FX_WCHAR* lpDstBuf = wsTemp.GetBuffer(nLength + nCount);
int32_t nDstPos = 0;
int32_t nSrcPos = 0;
for (i = 0; i < nCount; i++) {
int32_t nPos = PosArr[i];
int32_t nCopyLen = nPos - nSrcPos + 1;
FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos,
nCopyLen * sizeof(FX_WCHAR));
nDstPos += nCopyLen;
nSrcPos += nCopyLen;
lpDstBuf[nDstPos] = L'\n';
nDstPos++;
}
if (nSrcPos < nLength) {
FXSYS_memcpy(lpDstBuf + nDstPos, lpSrcBuf + nSrcPos,
(nLength - nSrcPos) * sizeof(FX_WCHAR));
}
wsTemp.ReleaseBuffer(nLength + nCount);
wsText = wsTemp;
} else {
int32_t nLength = wsText.GetLength();
FX_WCHAR* lpBuf = const_cast<FX_WCHAR*>(wsText.c_str());
for (int32_t i = 0; i < nLength; i++, lpBuf++) {
if (*lpBuf == m_wLineEnd)
*lpBuf = wc;
}
}
}
示例9: ReversalStr
CFX_WideString Document::ReversalStr(CFX_WideString cbFrom)
{
size_t iLength = cbFrom.GetLength();
pdfium::base::CheckedNumeric<size_t> iSize = sizeof(wchar_t);
iSize *= (iLength + 1);
wchar_t* pResult = (wchar_t*)malloc(iSize.ValueOrDie());
wchar_t* pFrom = (wchar_t*)cbFrom.GetBuffer(iLength);
for (size_t i = 0; i < iLength; i++)
{
pResult[i] = *(pFrom + iLength - i - 1);
}
pResult[iLength] = L'\0';
cbFrom.ReleaseBuffer();
CFX_WideString cbRet = CFX_WideString(pResult);
free(pResult);
pResult = NULL;
return cbRet;
}
示例10: documentFileName
FX_BOOL Document::documentFileName(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
if (vp.IsSetting()) {
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
sError = JSGetStringFromID(pContext, IDS_STRING_JSREADONLY);
return FALSE;
}
CFX_WideString wsFilePath = m_pDocument->GetPath();
FX_INT32 i = wsFilePath.GetLength() - 1;
for ( ; i >= 0; i-- )
{
if ( wsFilePath.GetAt( i ) == L'\\' || wsFilePath.GetAt( i ) == L'/' )
break;
}
if ( i >= 0 && i < wsFilePath.GetLength() - 1 )
{
vp << ( wsFilePath.GetBuffer( wsFilePath.GetLength() ) + i + 1 );
}else{
vp << L"";
}
return TRUE;
}
示例11: while
static int32_t XFA_FilterName(const CFX_WideStringC& wsExpression,
int32_t nStart,
CFX_WideString& wsFilter) {
FXSYS_assert(nStart > -1);
int32_t iLength = wsExpression.GetLength();
if (nStart >= iLength) {
return iLength;
}
FX_WCHAR* pBuf = wsFilter.GetBuffer(iLength - nStart);
int32_t nCount = 0;
const FX_WCHAR* pSrc = wsExpression.GetPtr();
FX_WCHAR wCur;
while (nStart < iLength) {
wCur = pSrc[nStart++];
if (wCur == ',') {
break;
}
pBuf[nCount++] = wCur;
}
wsFilter.ReleaseBuffer(nCount);
wsFilter.TrimLeft();
wsFilter.TrimRight();
return nStart;
}
示例12: GetNumbericFormat
void CXFA_LocaleValue::GetNumbericFormat(CFX_WideString& wsFormat,
int32_t nIntLen,
int32_t nDecLen,
FX_BOOL bSign) {
ASSERT(wsFormat.IsEmpty());
ASSERT(nIntLen >= -1 && nDecLen >= -1);
int32_t nTotalLen = (nIntLen >= 0 ? nIntLen : 2) + (bSign ? 1 : 0) +
(nDecLen >= 0 ? nDecLen : 2) + (nDecLen == 0 ? 0 : 1);
FX_WCHAR* lpBuf = wsFormat.GetBuffer(nTotalLen);
int32_t nPos = 0;
if (bSign) {
lpBuf[nPos++] = L's';
}
if (nIntLen == -1) {
lpBuf[nPos++] = L'z';
lpBuf[nPos++] = L'*';
} else {
while (nIntLen) {
lpBuf[nPos++] = L'z';
nIntLen--;
}
}
if (nDecLen != 0) {
lpBuf[nPos++] = L'.';
}
if (nDecLen == -1) {
lpBuf[nPos++] = L'z';
lpBuf[nPos++] = L'*';
} else {
while (nDecLen) {
lpBuf[nPos++] = L'z';
nDecLen--;
}
}
wsFormat.ReleaseBuffer(nTotalLen);
}
示例13: GetPreInsertText
void CFDE_TxtEdtEngine::GetPreInsertText(CFX_WideString& wsText,
int32_t nIndex,
const FX_WCHAR* lpText,
int32_t nLength) {
GetText(wsText, 0, GetTextBufLength());
int32_t nSelIndex = 0;
int32_t nSelLength = 0;
int32_t nSelCount = CountSelRanges();
while (nSelCount--) {
nSelLength = GetSelRange(nSelCount, nSelIndex);
wsText.Delete(nSelIndex, nSelLength);
nIndex = nSelIndex;
}
CFX_WideString wsTemp;
int32_t nOldLength = wsText.GetLength();
const FX_WCHAR* pOldBuffer = wsText.c_str();
FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nOldLength + nLength);
FXSYS_memcpy(lpBuffer, pOldBuffer, (nIndex) * sizeof(FX_WCHAR));
FXSYS_memcpy(lpBuffer + nIndex, lpText, nLength * sizeof(FX_WCHAR));
FXSYS_memcpy(lpBuffer + nIndex + nLength, pOldBuffer + nIndex,
(nOldLength - nIndex) * sizeof(FX_WCHAR));
wsTemp.ReleaseBuffer(nOldLength + nLength);
wsText = wsTemp;
}
示例14: printf
FX_BOOL util::printf(OBJ_METHOD_PARAMS)
{
int iSize = params.size();
if (iSize < 1)
return FALSE;
std::wstring c_ConvChar((const wchar_t*)(FX_LPCWSTR)params[0].operator CFX_WideString());
std::vector<std::wstring> c_strConvers;
int iOffset = 0;
int iOffend = 0;
c_ConvChar.insert(c_ConvChar.begin(),L'S');
while(iOffset != -1)
{
iOffend = c_ConvChar.find(L"%",iOffset+1);
std::wstring strSub;
if (iOffend == -1)
strSub = c_ConvChar.substr(iOffset);
else
strSub = c_ConvChar.substr(iOffset ,iOffend - iOffset);
c_strConvers.push_back(strSub);
iOffset = iOffend ;
}
std::wstring c_strResult;
//for(int iIndex = 1;iIndex < params.size();iIndex++)
std::wstring c_strFormat;
for(int iIndex = 0;iIndex < (int)c_strConvers.size();iIndex++)
{
c_strFormat = c_strConvers[iIndex];
if (iIndex == 0)
{
c_strResult = c_strFormat;
continue;
}
CFX_WideString strSegment;
if (iIndex >= iSize) {
c_strResult += c_strFormat;
continue;
}
switch (ParstDataType(&c_strFormat))
{
case UTIL_INT:
strSegment.Format((FX_LPCWSTR)c_strFormat.c_str(),(int)params[iIndex]);
break;
case UTIL_DOUBLE:
strSegment.Format((FX_LPCWSTR)c_strFormat.c_str(),(double)params[iIndex]);
break;
case UTIL_STRING:
strSegment.Format((FX_LPCWSTR)c_strFormat.c_str(),(FX_LPCWSTR)params[iIndex].operator CFX_WideString());
break;
default:
strSegment.Format((FX_LPCWSTR)L"%S", (FX_LPCWSTR)c_strFormat.c_str());
break;
}
c_strResult += (wchar_t*)strSegment.GetBuffer(strSegment.GetLength()+1);
}
c_strResult.erase(c_strResult.begin());
vRet = (FX_LPCWSTR)c_strResult.c_str();
return TRUE;
}
示例15: printf
FX_BOOL util::printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError)
{
int iSize = params.size();
if (iSize < 1)
return FALSE;
std::wstring c_ConvChar(params[0].ToCFXWideString().c_str());
std::vector<std::wstring> c_strConvers;
int iOffset = 0;
int iOffend = 0;
c_ConvChar.insert(c_ConvChar.begin(),L'S');
while(iOffset != -1)
{
iOffend = c_ConvChar.find(L"%",iOffset+1);
std::wstring strSub;
if (iOffend == -1)
strSub = c_ConvChar.substr(iOffset);
else
strSub = c_ConvChar.substr(iOffset ,iOffend - iOffset);
c_strConvers.push_back(strSub);
iOffset = iOffend ;
}
std::wstring c_strResult;
//for(int iIndex = 1;iIndex < params.size();iIndex++)
std::wstring c_strFormat;
for(int iIndex = 0;iIndex < (int)c_strConvers.size();iIndex++)
{
c_strFormat = c_strConvers[iIndex];
if (iIndex == 0)
{
c_strResult = c_strFormat;
continue;
}
CFX_WideString strSegment;
if (iIndex >= iSize) {
c_strResult += c_strFormat;
continue;
}
switch (ParstDataType(&c_strFormat))
{
case UTIL_INT:
strSegment.Format(c_strFormat.c_str(), params[iIndex].ToInt());
break;
case UTIL_DOUBLE:
strSegment.Format(c_strFormat.c_str(), params[iIndex].ToDouble());
break;
case UTIL_STRING:
strSegment.Format(c_strFormat.c_str(), params[iIndex].ToCFXWideString().c_str());
break;
default:
strSegment.Format(L"%S", c_strFormat.c_str());
break;
}
c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1);
}
c_strResult.erase(c_strResult.begin());
vRet = c_strResult.c_str();
return TRUE;
}