Esempio n. 1
0
        public static CharSet Intersection(CharSet a, CharSet b)
        {
            CharSet c = new CharSet();

            foreach (Char ch in a.m_set)
                if (b.m_set.Contains(ch))
                    c.m_set.Add(ch);

            c.m_set.Sort();
            return c;
        }
Esempio n. 2
0
 List<bool> ContentData(CharSet perAlphaCon)
 {
     List<bool> ret = new List<bool>();
     foreach(char ch in Value.ToCharArray())
         ret.AddRange(EncodeSingleChar(ch, perAlphaCon));
     return ret;
 }
Esempio n. 3
0
        protected virtual List<bool> EncodeSingleChar(char p, CharSet perAlphaCon)
        {
            List<bool> ret = new List<bool>();
            IStringType myType = m_type.GetFinalType() as IStringType;
            if (myType == null)
                throw new Exception("Internal Error");

            int min;
            int max;
            List<char> tmp = new List<char>(myType.AllowedCharSet);
            int charIndex = tmp.IndexOf(p);
            min = 0;
            max = tmp.Count - 1;

            if (perAlphaCon != null)
            {
                max = perAlphaCon.m_set.Count - 1;
                charIndex = perAlphaCon.m_set.IndexOf(p);
            }

            if (min == max)
                return ret;
            ret.AddRange(PER.EncodeConstraintWholeNumber(charIndex, min, max));

            return ret;
        }
Esempio n. 4
0
        public List<bool> EncodeAsUnCostraint(CharSet perAlphaCon)
        {
            List<bool> ret = new List<bool>();
            if (Size <= 0x7F)
            {
                ret.AddRange(PER.EncodeConstraintWholeNumber(Size, 0, 0xFF));
                ret.AddRange(ContentData(perAlphaCon));
                return ret;
            }

            if (Size <= 0x3FFF)
            {
                ret.Add(true);
                ret.AddRange(PER.EncodeConstraintWholeNumber(Size, 0, 0x7FFF));
                ret.AddRange(ContentData(perAlphaCon));
                return ret;
            }
            long nCount = Size;
            int curBlockSize = 0;
            List<char> items = new List<char>(Value.ToCharArray());
            int curItem = 0;
            while (nCount >= 0x4000)
            {
                if (nCount >= 0x10000)
                {
                    curBlockSize = 0x10000;
                    ret.AddRange(PER.EncodeConstraintWholeNumber(0xC4, 0, 0xFF));
                }
                else if (nCount >= 0xC000)
                {
                    curBlockSize = 0xC000;
                    ret.AddRange(PER.EncodeConstraintWholeNumber(0xC3, 0, 0xFF));
                }
                else if (nCount >= 0x8000)
                {
                    curBlockSize = 0x8000;
                    ret.AddRange(PER.EncodeConstraintWholeNumber(0xC2, 0, 0xFF));
                }
                else
                {
                    curBlockSize = 0x4000;
                    ret.AddRange(PER.EncodeConstraintWholeNumber(0xC1, 0, 0xFF));
                }
                for (int i = curItem; i < curBlockSize + curItem; i++)
                {
                    ret.AddRange(EncodeSingleChar(items[i],perAlphaCon));
                }
                curItem += curBlockSize;
                nCount -= curBlockSize;
            }

            if (nCount <= 0x7F)
            {
                ret.AddRange(PER.EncodeConstraintWholeNumber(nCount, 0, 0xFF));
                for (int i = curItem; i < curItem + nCount; i++)
                    ret.AddRange(EncodeSingleChar(items[i], perAlphaCon));
                return ret;
            }

            ret.Add(true);
            ret.AddRange(PER.EncodeConstraintWholeNumber(nCount, 0, 0x7FFF));
            for (int i = curItem; i < curItem + nCount; i++)
                ret.AddRange(EncodeSingleChar(items[i], perAlphaCon));
            return ret;
        }
Esempio n. 5
0
        protected int BitsPerSingleChar(CharSet perAlphaCon)
        {
            int min;
            int max;
            min = 0;
            max = AllowedCharSet.Length - 1;

            if (perAlphaCon != null)
                max = perAlphaCon.m_set.Count - 1;

            if (min == max)
                return 0;
            return PER.GetNumberOfBitsForNonNegativeInteger((UInt64)(max - min));
        }
Esempio n. 6
0
        public static CharSet Union(CharSet a, CharSet b)
        {
            CharSet c = a.Clone();

            foreach (Char ch in b.m_set)
                if (!c.m_set.Contains(ch))
                    c.m_set.Add(ch);

            c.m_set.Sort();
            return c;
        }
Esempio n. 7
0
        public PERAlphabetAndSizeEffectiveConstraint(Char? min, Char? max, IStringType strType)
        {
            if (strType == null)
                throw new Exception("Internal Error");
            if (min ==null && max ==null)
                throw new Exception("Internal Error");

            if (min != null && max != null)
            {
                m_from = new CharSet(min.Value, max.Value);
            }
            else if (min != null && max == null)
            {
                m_from = new CharSet(min.Value, strType.AllowedCharSet[strType.AllowedCharSet.Length - 1]);
            }
            else if (min == null && max != null)
            {
                m_from = new CharSet(strType.AllowedCharSet[0], max.Value);
            }
        }
Esempio n. 8
0
 public PERAlphabetAndSizeEffectiveConstraint(List<Char> charSet)
 {
     m_from = new CharSet(charSet);
 }