private static void StripCharBurst(ref ReadOnlyStringEntity source, ref Char16 target, bool left, bool right, out ReadOnlyStringEntity result) { result = StringStripperExt.StripCharImpl(source, target, left, right); }
/// <summary> /// split into NativeStringList by single char delimiter. /// </summary> /// <param name="source"></param> /// <param name="delim"></param> /// <param name="alloc"></param> /// <returns>result</returns> public static NativeStringList Split(this NativeList <Char16> source, Char16 delim, Allocator alloc) { var tmp = new NativeStringList(alloc); source.Split(delim, tmp, false); return(tmp); }
internal static unsafe void SplitCharImpl <Ts, Tr>(Ts source, Char16 delim, Tr result) where Ts : unmanaged, IJaggedArraySliceBase <Char16>, ISlice <Ts> where Tr : IAddSlice <Ts> { int len_source = source.Length; Char16 *ptr_source = (Char16 *)source.GetUnsafePtr(); int start = 0; for (int i = 0; i < len_source; i++) { if (ptr_source[i] == delim) { int len = (i - start); if (len > 0) { result.Add(source.Slice(start, i)); } start = i + 1; } } // final part if (start < len_source) { result.Add(source.Slice(start, len_source)); } }
public void VerifyChar16() { var x1 = "Hello, World!"; Char16 x2 = x1; string x3 = x1; Claim.eq(x1, x3); }
/// <summary> /// split into NativeStringList by single Char16 delimiter. /// </summary> /// <param name="source"></param> /// <param name="delim"></param> /// <param name="alloc"></param> /// <returns></returns> public static NativeStringList Split <T>(this T source, Char16 delim, Allocator alloc) where T : unmanaged, IJaggedArraySliceBase <Char16>, ISlice <T> { var tmp = new NativeStringList(alloc); source.Split(delim, tmp, false); return(tmp); }
/// <summary> /// split into NativeStringList by single Char16 delimiter. /// </summary> /// <param name="source"></param> /// <param name="delim"></param> /// <param name="result"></param> /// <param name="append"></param> public static unsafe void Split(this NativeList <Char16> source, Char16 delim, NativeStringList result, bool append = false) { if (!append) { result.Clear(); } var se = source.ToStringEntity(); se.Split(delim, result.GetUnsafeRef()); }
/// <summary> /// split by single Char16 delimiter. /// </summary> public static void Split <T>(this T source, Char16 delim, UnsafeRefToNativeStringList result, bool append = false) where T : unmanaged, IJaggedArraySliceBase <Char16>, ISlice <T> { if (!append) { result.Clear(); } var res = new SplitResultStringList <T>(result); SplitCharImpl(source, delim, res); }
/// <summary> /// split into NativeStringList by single Char16 delimiter. /// </summary> /// <param name="source"></param> /// <param name="delim"></param> /// <param name="result"></param> /// <param name="append"></param> public static unsafe void Split <T>(this T source, Char16 delim, NativeStringList result, bool append = false) where T : unmanaged, IJaggedArraySliceBase <Char16>, ISlice <T> { if (!append) { result.Clear(); } source.Split(delim, result.GetUnsafeRef()); }
private static void SplitCharBurst(ref ReadOnlyStringEntity source, ref Char16 delim, ref UnsafeRefToNativeList <ReadOnlyStringEntity> result) { source.Split(delim, result); }
private static unsafe bool ParseLineImpl(ParseLinesWorker.Info *info, UnsafeRefToNativeHeadRemovableList <Char16> charBuff, UnsafeRefToNativeStringList lines) { // check '\r\n' is overlap between previous buffer and current buffer if (info->check_CR && charBuff.Length > 0) { if (charBuff[0] == UTF16CodeSet.code_LF) { charBuff.RemoveHead(); } } int len_chars = charBuff.Length; Char16 *ptr_chars = (Char16 *)charBuff.GetUnsafePtr(); if (len_chars == 0) { return(false); } for (int i = 0; i < len_chars; i++) { Char16 ch = ptr_chars[i]; // detect ch = '\n' (unix), '\r\n' (DOS), or '\r' (Mac) if (ch == UTF16CodeSet.code_LF || ch == UTF16CodeSet.code_CR) { /* * //Debug.Log(" ** found LF = " + ((int)ch).ToString() + ", i=" + i.ToString() + "/" + charBuff.Length.ToString()); * if (_charBuff[i] == '\n' && i > 0) * { * //Debug.Log(" ** before LF = " + ((int)charBuff[i-1]).ToString()); * } * //*/ lines.Add(ptr_chars, i); if (ch == UTF16CodeSet.code_CR) { if (i + 1 < len_chars) { if (ptr_chars[i + 1] == UTF16CodeSet.code_LF) { i++; //Debug.Log(" ** found CRLF"); } } else { // check '\r\n' or not on the head of next buffer //Debug.LogWarning(" >> checking overlap CRLF"); info->check_CR = true; } } else { info->check_CR = false; } charBuff.RemoveHead(i + 1); return(true); } } return(false); }