Exemplo n.º 1
0
        public int GetLength()
        {
            int read       = 0;
            int characters = 0;

            int length   = hierarchy.GetLength(id);
            int position = hierarchy.GetPosition(id);

            if (length > 0)
            {
                byte   value;
                byte[] data = entry.GetData(0, out int size, out int skip);

                while (position < size)
                {
                    value = data[position];
                    read  = value < 128 ? 1 : BufferEntry.GetLength(value);

                    length     = length - read;
                    position   = position + read;
                    characters = characters + (read <= 3 ? 1 : 2);

                    if (length <= 0)
                    {
                        return(characters);
                    }
                }

                while (true)
                {
                    data = entry.GetData(position, out size, out skip);
                    int offset = position - skip;

                    while (offset < size)
                    {
                        value = data[offset];
                        read  = value < 128 ? 1 : BufferEntry.GetLength(value);

                        length     = length - read;
                        position   = position + read;
                        characters = characters + (read <= 3 ? 1 : 2);
                        offset     = offset + read;

                        if (length <= 0)
                        {
                            return(characters);
                        }
                    }
                }
            }

            return(characters);
        }
Exemplo n.º 2
0
        public static int NextElementName(BufferEntry entry, int position)
        {
            byte value;
            int  size, skip;

            byte[] data = entry.GetData(0, out size, out skip);

            while (position < size)
            {
                value = data[position];

                if (value == '/' || value == '>' || value == ' ' || value == '\r' || value == '\n' || value == '\t')
                {
                    return(position);
                }

                position++;
            }

            while (true)
            {
                data = entry.GetData(position, out size, out skip);
                int index = position - skip;

                while (index < size)
                {
                    value = data[index];

                    if (value == '/' || value == '>' || value == ' ' || value == '\r' || value == '\n' || value == '\t')
                    {
                        return(position);
                    }

                    if (value == '\0')
                    {
                        return(-1);
                    }

                    index++;
                    position++;
                }
            }
        }
Exemplo n.º 3
0
        public static int SkipWhiteCharactersForward(BufferEntry entry, int position)
        {
            byte value;
            int  size, skip;

            byte[] data = entry.GetData(0, out size, out skip);

            while (position < size)
            {
                value = data[position];

                if (value != ' ' && value != '\r' && value != '\n' && value != '\t')
                {
                    return(position);
                }

                position++;
            }

            while (true)
            {
                data = entry.GetData(position, out size, out skip);
                int index = position - skip;

                while (index < size)
                {
                    value = data[index];

                    if (value != ' ' && value != '\r' && value != '\n' && value != '\t')
                    {
                        return(position);
                    }

                    if (value == '\0')
                    {
                        return(-1);
                    }

                    index++;
                    position++;
                }
            }
        }
Exemplo n.º 4
0
        public static int SkipWhiteCharactersBackward(BufferEntry entry, int position)
        {
            byte value;
            int  size, skip;

            while (true)
            {
                byte[] data  = entry.GetData(position, out size, out skip);
                int    index = position - skip;

                while (index >= 0)
                {
                    value = data[index];

                    if (value != ' ' && value != '\r' && value != '\n' && value != '\t')
                    {
                        return(position);
                    }

                    index--;
                    position--;
                }
            }
        }