CoerceBytes() static private method

static private CoerceBytes ( object obj ) : IList
obj object
return IList
Ejemplo n.º 1
0
        internal static bool EndsWith(this IList <byte> /*!*/ bytes, PythonTuple /*!*/ suffix, int start)
        {
            int len = bytes.Count;

            if (start > len)
            {
                return(false);
            }
            // map the negative indice to its positive counterpart
            if (start < 0)
            {
                start += len;
                if (start < 0)
                {
                    start = 0;
                }
            }
            foreach (object obj in suffix)
            {
                if (bytes.Substring(start).EndsWith(ByteOps.CoerceBytes(obj)))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        internal static bool StartsWith(this IList <byte> /*!*/ bytes, PythonTuple /*!*/ prefix, int start)
        {
            int len = bytes.Count;

            if (start > len)
            {
                return(false);
            }
            if (start < 0)
            {
                start += len;
                if (start < 0)
                {
                    start = 0;
                }
            }
            foreach (object obj in prefix)
            {
                if (bytes.Substring(start).StartsWith(ByteOps.CoerceBytes(obj)))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
 internal static bool EndsWith(this IList <byte> bytes, PythonTuple suffix)
 {
     foreach (object?obj in suffix)
     {
         if (bytes.EndsWith(ByteOps.CoerceBytes(obj)))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
 internal static bool StartsWith(this IList <byte> /*!*/ bytes, PythonTuple /*!*/ prefix)
 {
     foreach (object obj in prefix)
     {
         if (bytes.StartsWith(ByteOps.CoerceBytes(obj)))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
        internal static bool StartsWith(this IList <byte> /*!*/ bytes, PythonTuple /*!*/ prefix, int start, int end)
        {
            int len = bytes.Count;

            if (start > len)
            {
                return(false);
            }
            // map the negative indices to their positive counterparts
            else if (start < 0)
            {
                start += len;
                if (start < 0)
                {
                    start = 0;
                }
            }
            if (end >= len)
            {
                end = len;
            }
            else if (end < 0)
            {
                end += len;
                if (end < 0)
                {
                    return(false);
                }
            }
            if (end < start)
            {
                return(false);
            }

            foreach (object obj in prefix)
            {
                if (bytes.Substring(start, end - start).StartsWith(ByteOps.CoerceBytes(obj)))
                {
                    return(true);
                }
            }
            return(false);
        }