void VRTLSupport_cl::SetText(const wchar_t *pText) { VASSERT(pText!=NULL); //clear text vars for multiple SetText calls if(m_ppTextLines!=NULL) { for(int i=0;i<m_iTextLines;i++) { V_SAFE_FREE(m_ppTextLines[i]); } } V_SAFE_FREE(m_ppTextLines); //create a tokenizer in order to separate the text lines VArrayHelper_cl<wchar_t> tokenizer(pText, L"\n"); //create line pointers m_iTextLines = tokenizer.CalcNumberOfTokens(); m_ppTextLines = (char **)vMemAlloc(m_iTextLines * sizeof(char *)); int iLineIndex=0; int iWLen, iSize; while( tokenizer.HasNextToken() ) { //get the current text line const wchar_t *pCurrentLine = tokenizer.NextToken(); //length of the current line int iLength = VArrayHelper_cl<wchar_t>::Length(pCurrentLine); //allocate the target buffer (original length + terminator) wchar_t *pReversed = (wchar_t *) vMemAlloc(sizeof(wchar_t)*(iLength+1)); //pre-terminate buffer pReversed[iLength] = 0; //transform LTR to RTL for(int i=0;i<iLength;i++) { pReversed[iLength-i-1] = pCurrentLine[i]; } // Convert to UTF8 and assign the reversed line iWLen = (int)wcslen(pReversed); iSize = VString::ConvertWCharToUTF8String(pReversed, iWLen, NULL, 0); m_ppTextLines[iLineIndex] = new char[iSize+1]; VString::ConvertWCharToUTF8String(pReversed, iWLen, m_ppTextLines[iLineIndex], iSize); m_ppTextLines[iLineIndex][iSize] = '\0'; V_SAFE_DELETE(pReversed); iLineIndex++; } }
VRTLSupport_cl::~VRTLSupport_cl() { //delete text block an line pointers if(m_ppTextLines!=NULL) { for(int i=0;i<m_iTextLines;i++) { V_SAFE_FREE(m_ppTextLines[i]); } } V_SAFE_FREE(m_ppTextLines); }
void VArabicSupport_cl::SetText(const wchar_t *pArabicText, bool isContextualArabic, bool duplicateSpacesDuringConversion) { VASSERT(pArabicText!=NULL); //clear text vars for multiple SetText calls if(m_ppTextLines!=NULL) { for(int i=0;i<m_iTextLines;i++) { V_SAFE_FREE(m_ppTextLines[i]); } } V_SAFE_FREE(m_ppTextLines); //create a tokenizer in order to separate the text lines VArrayHelper_cl<wchar_t> tokenizer(pArabicText, L"\n"); //create line pointers m_iTextLines = tokenizer.CalcNumberOfTokens(); m_ppTextLines = (char **)vMemAlloc(m_iTextLines * sizeof(char *)); int iWLen, iSize; int iLineIndex=0; while( tokenizer.HasNextToken() ) { wchar_t *pConverted = NULL; if(isContextualArabic) { //duplicate line pConverted = VArrayHelper_cl<wchar_t>::Copy(tokenizer.NextToken()); } else { //convert to contextual pConverted = UniformToContextualLine(m_pFont, tokenizer.NextToken(), duplicateSpacesDuringConversion); } // Convert to UTF8 and assign the reversed line iWLen = (int)wcslen(pConverted); iSize = VString::ConvertWCharToUTF8String(pConverted, iWLen, NULL, 0); m_ppTextLines[iLineIndex] = new char[iSize+1]; VString::ConvertWCharToUTF8String(pConverted, iWLen, m_ppTextLines[iLineIndex], iSize); m_ppTextLines[iLineIndex][iSize] = '\0'; V_SAFE_DELETE(pConverted); iLineIndex++; } }
/// \brief /// Get the next token (if present) or NULL. const ELEM_TYPE * NextToken() { if(!HasNextToken()) return NULL; V_SAFE_FREE(m_pCurrentToken); int iBufferLength = m_iNextIndex-m_iStartIndex; VASSERT(iBufferLength>0); //create the buffer with terminator at the end m_pCurrentToken = Copy(&m_pBuffer[m_iStartIndex], iBufferLength); //seek for next token seek(); //return the generated buffer; return m_pCurrentToken; }
/// \brief /// Destructor ~VNetworkSynchronizationGroupInstanceInfo_t() { V_SAFE_FREE(m_pCustomData); }
inline ~VTerrainLockObject() { if (m_bOwnsData) V_SAFE_FREE(m_pData); }
/// \brief /// Release internal resources. ~VArrayHelper_cl() { V_SAFE_FREE(m_pBuffer); V_SAFE_FREE(m_pDelimiters); V_SAFE_FREE(m_pCurrentToken); }