Пример #1
0
 internal static bool TryConstruct(cSequenceSet pSequenceSet, int pAsterisk, bool pDistinct, out cUIntList rResult)
 {
     if (pSequenceSet == null)
     {
         throw new ArgumentNullException(nameof(pSequenceSet));
     }
     if (!ZExpand(pSequenceSet, pAsterisk, out rResult))
     {
         return(false);
     }
     if (pDistinct)
     {
         rResult = new cUIntList(rResult.Distinct());
     }
     return(true);
 }
Пример #2
0
        public bool GetSequenceSet(out cSequenceSet rSequenceSet)
        {
            var lBookmark = Position;

            List <cSequenceSetItem> lItems = new List <cSequenceSetItem>();

            while (true)
            {
                if (!ZGetSequenceSetItem(out var lItem))
                {
                    Position     = lBookmark;
                    rSequenceSet = null;
                    return(false);
                }

                lItems.Add(lItem);

                if (!SkipByte(cASCII.COMMA))
                {
                    rSequenceSet = new cSequenceSet(lItems);
                    return(true);
                }
            }
        }
Пример #3
0
        private static bool ZExpand(cSequenceSet pSequenceSet, int pAsterisk, out cUIntList rResult)
        {
            if (pSequenceSet == null)
            {
                rResult = null; return(false);
            }

            rResult = new cUIntList();

            foreach (var lItem in pSequenceSet)
            {
                if (lItem == cSequenceSetItem.Asterisk)
                {
                    if (pAsterisk < 1)
                    {
                        return(false);
                    }
                    rResult.Add((uint)pAsterisk);
                    continue;
                }

                if (lItem is cSequenceSetNumber lNumber)
                {
                    rResult.Add(lNumber.Number);
                    continue;
                }

                if (!(lItem is cSequenceSetRange lRange))
                {
                    return(false);
                }

                if (lRange.From == cSequenceSetItem.Asterisk)
                {
                    if (pAsterisk < 1)
                    {
                        return(false);
                    }
                    rResult.Add((uint)pAsterisk);
                    continue;
                }

                if (!(lRange.From is cSequenceSetNumber lFrom))
                {
                    return(false);
                }

                uint lTo;

                if (lRange.To == cSequenceSetItem.Asterisk)
                {
                    if (pAsterisk < 1)
                    {
                        return(false);
                    }
                    lTo = (uint)pAsterisk;
                }
                else
                {
                    if (!(lRange.To is cSequenceSetNumber lRangeTo))
                    {
                        return(false);
                    }
                    lTo = lRangeTo.Number;
                }

                for (uint i = lFrom.Number; i <= lTo; i++)
                {
                    rResult.Add(i);
                }
            }

            return(true);
        }
Пример #4
0
                public bool Process(cBytesCursor pCursor, out cResponseData rResponseData, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cResponseDataParserESearch), nameof(Process));

                    if (!pCursor.SkipBytes(kESearch))
                    {
                        rResponseData = null; return(false);
                    }

                    if (pCursor.Position.AtEnd)
                    {
                        rResponseData = new cResponseDataESearch(null, false, null);
                        return(true);
                    }

                    bool lSetParsedAs = false; // just in case there is another response that starts with the string "ESEARCH"

                    IList <byte> lTag;

                    if (pCursor.SkipBytes(kSpaceLParenTAGSpace))
                    {
                        if (!pCursor.GetString(out lTag) || !pCursor.SkipByte(cASCII.RPAREN))
                        {
                            rResponseData = null;
                            return(true);
                        }

                        lSetParsedAs = true;
                    }
                    else
                    {
                        lTag = null;
                    }

                    bool lUID;

                    if (pCursor.SkipBytes(kSpaceUID))
                    {
                        lUID         = true;
                        lSetParsedAs = true;
                    }
                    else
                    {
                        lUID = false;
                    }

                    cSequenceSet lSequenceSet = null;

                    while (true)
                    {
                        if (!pCursor.SkipByte(cASCII.SPACE))
                        {
                            break;
                        }

                        lSetParsedAs = true;

                        if (!pCursor.GetToken(cCharset.Atom, null, null, out cByteList lName) ||
                            !pCursor.SkipByte(cASCII.SPACE) ||
                            !pCursor.ProcessExtendedValue(out var lValue)
                            )
                        {
                            rResponseData = null;
                            return(true);
                        }

                        if (cASCII.Compare(lName, kAll, false) && lValue is cExtendedValue.cSequenceSetEV lSequenceSetEV)
                        {
                            lSequenceSet = lSequenceSetEV.SequenceSet;
                        }
                    }

                    if (!pCursor.Position.AtEnd)
                    {
                        rResponseData = null;
                        return(lSetParsedAs);
                    }

                    rResponseData = new cResponseDataESearch(lTag, lUID, lSequenceSet);
                    return(true);
                }
Пример #5
0
 public cFilterUIDIn(uint pUIDValidity, cSequenceSet pSequenceSet) : base(pUIDValidity)
 {
     SequenceSet = pSequenceSet ?? throw new ArgumentNullException(nameof(pSequenceSet));
 }
Пример #6
0
 public cResponseDataESearch(IList <byte> pTag, bool pUID, cSequenceSet pSequenceSet)
 {
     Tag         = pTag;
     UID         = pUID;
     SequenceSet = pSequenceSet;
 }
Пример #7
0
 public cSequenceSetEV(cSequenceSet pSequenceSet)
 {
     SequenceSet = pSequenceSet;
 }
Пример #8
0
        public cTextCommandPart(cSequenceSet pSequenceSet) : base(false, false)
        {
            cByteList lBytes = new cByteList();
            cByteList lTemp  = new cByteList();

            bool lFirst = true;

            foreach (var lItem in pSequenceSet)
            {
                if (lFirst)
                {
                    lFirst = false;
                }
                else
                {
                    lBytes.Add(cASCII.COMMA);
                }

                if (lItem == cSequenceSetItem.Asterisk)
                {
                    lBytes.Add(cASCII.ASTERISK);
                    continue;
                }

                if (lItem is cSequenceSetNumber lNumber)
                {
                    lTemp = cTools.UIntToBytesReverse(lNumber.Number);
                    lTemp.Reverse();
                    lBytes.AddRange(lTemp);
                    continue;
                }

                if (!(lItem is cSequenceSetRange lRange))
                {
                    throw new ArgumentException("invalid form 1", nameof(pSequenceSet));
                }

                if (lRange.From == cSequenceSetItem.Asterisk)
                {
                    lBytes.Add(cASCII.ASTERISK);
                    continue;
                }

                if (!(lRange.From is cSequenceSetNumber lFrom))
                {
                    throw new ArgumentException("invalid form 2", nameof(pSequenceSet));
                }

                lTemp = cTools.UIntToBytesReverse(lFrom.Number);
                lTemp.Reverse();
                lBytes.AddRange(lTemp);

                lBytes.Add(cASCII.COLON);

                if (lRange.To == cSequenceSetItem.Asterisk)
                {
                    lBytes.Add(cASCII.ASTERISK);
                    continue;
                }

                if (!(lRange.To is cSequenceSetNumber lTo))
                {
                    throw new ArgumentException("invalid form 3", nameof(pSequenceSet));
                }

                lTemp = cTools.UIntToBytesReverse(lTo.Number);
                lTemp.Reverse();
                lBytes.AddRange(lTemp);
            }

            Bytes = new cBytes(lBytes);
        }