예제 #1
0
        public void Init()
        {
            EnableBurst     = true;
            EnableBurstFunc = true;

            Data     = new NativeList <CharaData>(Allocator.Persistent);
            IndexSeq = new NativeList <int>(Allocator.Persistent);

            _name = new NativeStringList(Allocator.Persistent);

            _tmp_name = new NativeStringList(Allocator.Persistent);
            _str_list = new NativeList <ReadOnlyStringEntity>(Allocator.Persistent);

            _mark_list = new NativeStringList(Allocator.Persistent);

            _mark_list.Add("#");

            _mark_list.Add("<@MARK>");
            _mark_list.Add("Header");
            _mark_list.Add("ExtData");
            _mark_list.Add("ExtDataEnd");
            _mark_list.Add("Body");

            _mark_list.Add("n_total");
            _mark_list.Add("d");
            _mark_list.Add("r");

            pack.mark_comment = _mark_list[0];

            pack.mark_tag     = _mark_list[1];
            pack.mark_header  = _mark_list[2];
            pack.mark_ext     = _mark_list[3];
            pack.mark_ext_end = _mark_list[4];
            pack.mark_body    = _mark_list[5];

            pack.mark_n_total = _mark_list[6];
            pack.mark_d       = _mark_list[7];
            pack.mark_r       = _mark_list[8];

            _b64_decoder       = new NativeBase64Decoder(Allocator.Persistent);
            _b64_decoded_bytes = new NativeList <byte>(Allocator.Persistent);

            // initialize references
            pack.str_list          = _str_list.GetUnsafeRef();
            pack.b64_decoder       = _b64_decoder.GetUnsafeRef();
            pack.b64_decoded_bytes = _b64_decoded_bytes.GetUnsafeRef();
            pack.tmp_name          = _tmp_name.GetUnsafeRef();
            pack.IndexSeq          = IndexSeq.GetUnsafeRef();
            pack.Data = Data.GetUnsafeRef();
            pack.name = _name.GetUnsafeRef();

            _data_size = 0;

            _timer = new System.Diagnostics.Stopwatch();
            _timer.Start();

            _allocated = true;
        }
예제 #2
0
 /// <summary>
 /// split into NativeStringList by Char16.IsWhiteSpace() delimiter.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="result"></param>
 /// <param name="append"></param>
 public static unsafe void Split <T>(this T source, NativeStringList result, bool append = false)
     where T : unmanaged, IJaggedArraySliceBase <Char16>, ISlice <T>
 {
     if (!append)
     {
         result.Clear();
     }
     source.Split(result.GetUnsafeRef());
 }
예제 #3
0
 private unsafe int GetLinesImpl(NativeStringList lines)
 {
     LineParserBurst.GetLinesImpl(_info.Target,
                                  _continueBuff.GetUnsafeRef(),
                                  _charBuff.GetUnsafeRef(),
                                  lines.GetUnsafeRef(),
                                  out int line_count);
     return(line_count);
 }
예제 #4
0
        /// <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());
        }
예제 #5
0
        public static int GetLines(ParseLinesWorker worker, NativeStringList lines)
        {
            var ref_continueBuff = worker._continueBuff.GetUnsafeRef();
            var ref_charBuff     = worker._charBuff.GetUnsafeRef();
            var ref_lines        = lines.GetUnsafeRef();

            _parseLinesDelegate(worker._info.Target,
                                ref ref_continueBuff,
                                ref ref_charBuff,
                                ref ref_lines,
                                out int line_count);
            return(line_count);
        }
예제 #6
0
        /// <summary>
        /// split into NativeStringList by NativeList(Char16) delimiter.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="delim"></param>
        /// <param name="result"></param>
        /// <param name="append"></param>
        public unsafe static void Split <T>(this T source,
                                            NativeList <Char16> delim,
                                            NativeStringList result,
                                            bool append = false)
            where T : unmanaged, IJaggedArraySliceBase <Char16>, ISlice <T>
        {
            if (!append)
            {
                result.Clear();
            }
            var de = delim.ToStringEntity();

            source.Split(de, result.GetUnsafeRef());
        }
예제 #7
0
        /// <summary>
        /// split into NativeStringList by StringEntity delimiter.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="delim"></param>
        /// <param name="result"></param>
        /// <param name="append"></param>
        public unsafe static void Split <T>(this NativeList <Char16> source,
                                            T delim,
                                            NativeStringList result,
                                            bool append = false)
            where T : IJaggedArraySliceBase <Char16>
        {
            if (!append)
            {
                result.Clear();
            }
            var se = source.ToStringEntity();

            se.Split(delim, result.GetUnsafeRef());
        }
예제 #8
0
 public bool ParseLines(NativeStringList lines)
 {
     if (EnableBurst)
     {
         var lines_input = lines.GetUnsafeRef();
         ParserFuncBurst.ParseLines(ref pack, ref lines_input, out bool success);
         return(success);
     }
     else
     {
         for (int i = 0; i < lines.Length; i++)
         {
             bool success = ParseLineImpl(lines[i]);
             if (!success)
             {
                 return(false);
             }
         }
     }
     return(true);
 }