Esempio n. 1
0
        /// <summary>
        /// sort file paths with filtering.
        /// </summary>
        static public void Sort(NativeStringList source, ReadOnlyStringEntity target_pattern, NativeStringList result)
        {
            var job = new SortJob(source, target_pattern, result, Allocator.TempJob);

            job.Run();
            job.Dispose();
        }
Esempio n. 2
0
 public unsafe void ReadToEnd(NativeStringList result)
 {
     while (_blockPos <= _blockNum)
     {
         this.ReadLinesFromBuffer(result);
     }
 }
Esempio n. 3
0
        public void ReadLine(NativeStringList result)
        {
            var ret = new Result_NSL();

            ret.result = result;
            this.ReadLinesImpl(ret, 1);
        }
Esempio n. 4
0
        /// <summary>
        /// sort file paths.
        /// </summary>
        static public void Sort(NativeStringList source, NativeStringList result)
        {
            var job = new SortJob(source, result, Allocator.TempJob);

            job.Run();
            job.Dispose();
        }
Esempio n. 5
0
        public NativeStringList Split(NativeList <Char16> input, Allocator alloc)
        {
            var tmp = new NativeStringList(alloc);

            this.Split(input, tmp);
            return(tmp);
        }
Esempio n. 6
0
        /// <summary>
        /// sort file paths with filtering.
        /// </summary>
        static public void Sort(NativeStringList source, ReadOnlyStringEntity target_pattern, List <string> result)
        {
            var tmp_result = new NativeStringList(Allocator.TempJob);

            Sort(source, target_pattern, tmp_result);
            WriteBackListStr(tmp_result, result);
            tmp_result.Dispose();
        }
Esempio n. 7
0
 static private void WriteBackListStr(NativeStringList source, List <string> result)
 {
     result.Clear();
     for (int i = 0; i < source.Length; i++)
     {
         result.Add(source[i].ToString());
     }
 }
Esempio n. 8
0
        /// <summary>
        /// sort file paths.
        /// </summary>
        static public void Sort(NativeStringList source, List <string> result)
        {
            var tmp_result = new NativeStringList(Allocator.TempJob);

            Sort(source, tmp_result);
            WriteBackListStr(tmp_result, result);
            tmp_result.Dispose();
        }
Esempio n. 9
0
        /// <summary>
        /// sort file paths with filtering.
        /// </summary>
        static public void Sort <T>(T source, string target_pattern, NativeStringList result)
            where T : IEnumerable <string>
        {
            var tmp_source = ConvertListStr(source, Allocator.TempJob);

            Sort(tmp_source, target_pattern, result);
            tmp_source.Dispose();
        }
Esempio n. 10
0
        public NativeTextStreamReader(Allocator alloc)
        {
            _byteBuffer = new byte[Define.DefaultBufferSize];

            _worker = new ParseLinesWorker(alloc);
            _lines  = new NativeStringList(alloc);

            _allocated = true;

            this.Encoding = Encoding.Default;
        }
Esempio n. 11
0
        static private NativeStringList ConvertListStr <T>(T str_list, Allocator alloc)
            where T : IEnumerable <string>
        {
            var tmp = new NativeStringList(alloc);

            foreach (var str in str_list)
            {
                tmp.Add(str);
            }
            return(tmp);
        }
Esempio n. 12
0
 public void SetDelim(NativeStringList delims)
 {
     _delims.Clear();
     foreach (var se in delims)
     {
         // check duplication
         if (_delims.IndexOf(se) < 0)
         {
             _delims.Add(se);
         }
     }
 }
Esempio n. 13
0
        /// <summary>
        /// sort file paths with filtering.
        /// </summary>
        static public void Sort(NativeStringList source, string target_pattern, NativeStringList result)
        {
            var char_list = new NativeList <char>(Allocator.TempJob);

            char_list.Capacity = target_pattern.Length;
            foreach (var c in target_pattern)
            {
                char_list.Add(c);
            }
            Sort(source, char_list.ToStringEntity(), result);
            char_list.Dispose();
        }
Esempio n. 14
0
        private unsafe void SplitImpl(Char16 *source_ptr, int source_len, NativeStringList result)
        {
            // parse
            int start = 0;

            for (int i = 0; i < source_len; i++)
            {
                int match_len = 0;
                foreach (var d in _delims)
                {
                    // skip shorter delim
                    if (match_len >= d.Length)
                    {
                        continue;
                    }

                    bool match = true;
                    for (int j = 0; j < d.Length; j++)
                    {
                        if (source_ptr[i + j] != d[j])
                        {
                            match = false;
                            break;
                        }
                    }
                    if (match)
                    {
                        match_len = d.Length;
                    }
                }

                if (match_len > 0)
                {
                    int elem_len = i - start;
                    if (elem_len > 0)
                    {
                        Char16 *st_ptr = source_ptr + start;
                        result.Add(st_ptr, elem_len);
                    }
                    start = i + match_len;
                    i    += match_len;
                }
            }

            // final part
            if (start < source_len)
            {
                int     len    = source_len - start;
                Char16 *st_ptr = source_ptr + start;
                result.Add(st_ptr, len);
            }
        }
Esempio n. 15
0
            public SortJob(NativeStringList source, NativeStringList result, Allocator alloc)
            {
                this.source         = source;
                this.target_pattern = source[0]; // dummy value
                this.result         = result;

                WithFiltering = false;

                TgtWords     = new NativeList <WordBlock>(alloc);
                tmpWords     = new NativeList <WordBlock>(alloc);
                SrcWordsList = new NativeJaggedArray <WordBlock>(alloc);

                paths    = new NativeList <DecodedPath>(alloc);
                tmp_list = new NativeList <DecodedPath>(alloc);
            }
Esempio n. 16
0
            public SortJob(NativeStringList source, ReadOnlyStringEntity target_pattern, NativeStringList result, Allocator alloc)
            {
                this.source         = source;
                this.target_pattern = target_pattern;
                this.result         = result;

                WithFiltering = true;

                TgtWords     = new NativeList <WordBlock>(alloc);
                tmpWords     = new NativeList <WordBlock>(alloc);
                SrcWordsList = new NativeJaggedArray <WordBlock>(alloc);

                paths    = new NativeList <DecodedPath>(alloc);
                tmp_list = new NativeList <DecodedPath>(alloc);
            }
Esempio n. 17
0
        public unsafe void Split(NativeList <Char16> source, NativeStringList result, bool append = false)
        {
            if (!append)
            {
                result.Clear();
            }

            // redirect to using Char16.IsWhiteSpace() function
            if (_delims.Length == 0)
            {
                source.Split(result, append);
                return;
            }
            // redirect to using single char delim function
            if (_delims.Length == 1 && _delims[0].Length == 1)
            {
                source.Split(_delims[0][0], result, append);
                return;
            }

            this.SplitImpl((Char16 *)source.GetUnsafePtr(), source.Length, result);
        }
Esempio n. 18
0
        public unsafe void ReadLinesFromBuffer(NativeStringList result)
        {
            var ret = new Result_NSL();

            ret.result = result;

            if (_blockPos < _blockNum)
            {
                this.ReadStream();
                fixed(byte *byte_ptr = _byteBuffer)
                {
                    var handle = new GCHandle <Decoder>();

                    handle.Create(_decoder);
                    _worker.DecodeTextIntoBuffer(byte_ptr, _byteLength, handle);
                    handle.Dispose();
                    _worker.GetLines(_lines);
                }
            }

            // read all lines in buffer
            this.PickLinesImpl(ret, int.MaxValue);
            _lines.Clear();

            if (_blockPos == _blockNum)
            {
                // if final part do not have LF.
                if (!_worker.IsEmpty)
                {
                    using (var buff = new NativeList <Char16>(Allocator.Temp))
                    {
                        _worker.GetInternalBuffer(buff);
                        result.Add((char *)buff.GetUnsafePtr(), buff.Length);
                    }
                }
            }
        }
Esempio n. 19
0
 public StringSplitter(Allocator alloc)
 {
     _delims = new NativeStringList(alloc);
 }