Started by Juergen Kuehlwein, April 09, 2018, 11:39:00 PM
0 Members and 1 Guest are viewing this topic.
QuoteI was thinking mostly in terms of speed/performance, that if the length is known, like in a UDT that extends Z|WSTRING and stores length data, that it would be preferable to use the stored length rather than always calling w|strlen(), especially for large strings.
PRIVATE OPERATOR LEN (BYREF cws AS CWSTR) AS UINT OPERATOR = cws.m_BufferLen \ 2END OPERATOR
QuoteThe much hated ** workaround
' ========================================================================================PRIVATE OPERATOR CWstr.Let (BYREF cws AS CWSTR) CWSTR_DP("CWSTR LET CWSTR - m_pBuffer = " & .WSTR(m_pBuffer) & " - IN buffer = " & .WSTR(cws.m_pBuffer)) IF m_pBuffer = cws.m_pBuffer THEN EXIT OPERATOR ' // Ignore cws = cws this.Clear this.Add(cws)END OPERATOR' ========================================================================================
#if __FB_VERSION__ < "1.07.0"TYPE CWSTR#elseTYPE CWSTR EXTENDS WSTRING#endif
PRIVATE OPERATOR DWSTR.Let (BYREF pwszStr AS WSTRING PTR) IF m_pBuffer = cast(ubyte ptr, pwszStr) THEN EXIT OPERATOR 'ignore self assign this.Clear IF pwszStr = 0 THEN EXIT OPERATOR this.Add(*pwszStr)END OPERATOR
DECLARE OPERATOR CAST () BYREF AS WSTRING
PRIVATE OPERATOR DWSTR.CAST () BYREF AS WSTRING 'returns the string data (same as **). OPERATOR = *cast(WSTRING PTR, m_pBuffer)END OPERATOR
dim u as ustring = wchr( 1234 ) u = wstr(u) print u
dim w1 as wstring * 50 = wspace(5) & "asdfghjklmnop" dim u1 as ustring = w1 dim w as Wstring * 50 = wspace(25) dim u as ustring = wspace(25) lset w, w1 lset u, u1 print u print w
Quote from: Charles Pegge on June 16, 2019, 12:29:54 PMchar wcharzstring wzstringstring wstring
Quote from: Juergen Kuehlwein on June 18, 2019, 09:15:32 PMthis one gives me a compiler error (with CONST):Code Select Expand dim w1 as wstring * 50 = wspace(5) & "asdfghjklmnop" dim u1 as ustring = w1 dim w as Wstring * 50 = wspace(25) dim u as ustring = wspace(25) lset w, w1 lset u, u1 print u print w
Page created in 0.207 seconds with 23 queries.