using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.IO;

namespace skyscraper5.Dvb.DataBroadcasting.Dsm.Event
{
    public class EventList_T
    {
        public EventList_T(MemoryStream ms)
        {
            N3 = ms.ReadUInt16BE();
            if (ms.GetAvailableBytes() < N3)
                return;
            EventNames = new string[N3];
            for (int i = 0; i < N3; i++)
            {
                byte eventNameLength = ms.ReadUInt8();
                N4 += eventNameLength;
                EventNames[i] = Encoding.UTF8.GetString(ms.ReadBytes(i)).TrimEnd((char)0);
            }
        }

        public ushort N3 { get; private set; }

        public int N4 { get; private set; }

        public string[] EventNames { get; private set; }
    }
}
