<commit_before>package vectorx.svg;

import lib.ha.aggx.color.RgbaColor;
import lib.ha.svg.SVGElement;
import types.Data;
class SvgElementSerializer
{
    private var flagFill: Int = 1  << 0;
    private var flagFillOpacity: Int = 1 << 1;
    private var flagStroke: Int = 1 << 2;
    private var flagEvenOdd: Int = 1 << 3;

    public static function writeSVGElement(data: Data, element: SVGElement)
    {
        var flags: Int = 0;

        if (element.fill_flag)
        {
            flags |= flagFill;

            if (element.fill_opacity)
            {
                flags |= flagFillOpacity;
            }
        }

        if (element.stroke_flag)
        {
            flags |= flagStroke;
        }

        if (element.even_odd_flag)
        {
            flags |= flagEvenOdd;
        }

        data.writeInt8(flags);
        data.offset += 1;

        data.writeInt32(element.index);
        data.offset += 4;

        if (element.fill_flag)
        {
            SvgSerializer.writeRgbaColor(data, element.fill_color);
            if (element.fill_opacity != null)
            {
                data.writeFloat32(element.fill_opacity);
                data.offset += 4;
            }
        }
    }

    public static function readSVGElement(data: Data, element: SVGElement)
    {
        var flags: Int = 0;
        flags = data.readUInt8();
        data.offset += 1;

        element.index = data.readInt32();
        data.offset += 4;

        if (flags & flagFill != 0)
        {
            element.fill_flag = true;
            if (element.fill_color == null)
            {
                element.fill_color = new RgbaColor();
                SvgSerializer.readRgbaColor(element.fill_color);
                if (flags & flagFillOpacity != 0)
                {
                    element.fill_opacity = data.readFloat32();
                    data.offset += 4;
                }
            }
            else
            {
                element.fill_opacity = null;
            }
        }
    }

}
<commit_msg>SVGElement serialisation<commit_after>package vectorx.svg;

import lib.ha.svg.SVGStringParsers;
import lib.ha.aggx.color.RgbaColor;
import lib.ha.svg.SVGElement;
import types.Data;
class SvgElementSerializer
{
    private var flagFill: Int = 1  << 0;
    private var flagFillOpacity: Int = 1 << 1;
    private var flagStroke: Int = 1 << 2;
    private var flagEvenOdd: Int = 1 << 3;

    public static function writeSVGElement(data: Data, element: SVGElement)
    {
        var flags: Int = 0;

        if (element.fill_flag)
        {
            flags |= flagFill;

            if (element.fill_opacity)
            {
                flags |= flagFillOpacity;
            }
        }

        if (element.stroke_flag)
        {
            flags |= flagStroke;
        }

        if (element.even_odd_flag)
        {
            flags |= flagEvenOdd;
        }

        data.writeInt8(flags);
        data.offset += 1;

        data.writeInt32(element.index);
        data.offset += 4;

        if (element.fill_flag)
        {
            SvgSerializer.writeRgbaColor(data, element.fill_color);
            if (element.fill_opacity != null)
            {
                SvgSerializer.writeFloat(data, element.fill_opacity);
            }
        }

        if (element.stroke_flag)
        {
            SvgSerializer.writeRgbaColor(element.stroke_color);
            SvgSerializer.writeFloat(data, element.stroke_width);
        }

        data.writeUInt8(element.line_join);
        data.offset++;

        data.writeUInt8(element.line_cap);
        data.offset++;

        SvgSerializer.writeFloat(element.miter_limit);
    }

    public static function readSVGElement(data: Data, element: SVGElement)
    {
        var flags: Int = 0;
        flags = data.readUInt8();
        data.offset += 1;

        if (flags & flagEvenOdd != 0)
        {
            element.even_odd_flag = true;
        }
        else
        {
            element.even_odd_flag = false;
        }

        element.index = data.readInt32();
        data.offset += 4;

        if (flags & flagFill != 0)
        {
            element.fill_flag = true;
            if (element.fill_color == null)
            {
                element.fill_color = new RgbaColor();
                SvgSerializer.readRgbaColor(element.fill_color);
                if (flags & flagFillOpacity != 0)
                {
                    element.fill_opacity = SvgSerializer.readFloat(data);
                }
            }
            else
            {
                element.fill_opacity = null;
            }
        }
        else
        {
            element.fill_flag = false;
        }

        if (flags & flagStroke != 0)
        {
            element.stroke_flag = true;
            if (element.stroke_color == null)
            {
                element.stroke_color = new RgbaColor();
            }

            SvgSerializer.readRgbaColor(data, element.stroke_color);
            element.stroke_width = SvgSerializer.readFloat(data);
        }
        else
        {
            element.stroke_flag = false;
        }

        element.line_join = data.readUInt8();
        data.offset++;

        element.line_cap = data.readUInt8();
        data.offset++;

        element.miter_limit = SvgSerializer.readFloat(data);
    }

}

{'fraction_non_alphanumeric': 0.09820426487093153, 'fraction_numerical': 0.010475121586232696, 'mean_word_length': 1.4460201280878318, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3087027', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1514, 'n_words': 289}