示例#1
0
        public static ByteVectorCollection Split(ByteVector vector, ByteVector pattern, int byteAlign, int max)
        {
            if (vector == null)
            {
                throw new ArgumentNullException("vector");
            }
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }
            if (byteAlign < 1)
            {
                throw new ArgumentOutOfRangeException("byteAlign", "byteAlign must be at least 1.");
            }
            ByteVectorCollection list = new ByteVectorCollection();
            int previous_offset       = 0;

            for (int offset = vector.Find(pattern, 0, byteAlign); offset != -1 && (max < 1 || max > list.Count + 1); offset = vector.Find(pattern, offset + pattern.Count, byteAlign))
            {
                list.Add(vector.Mid(previous_offset, offset - previous_offset));
                previous_offset = offset + pattern.Count;
            }
            if (previous_offset < vector.Count)
            {
                list.Add(vector.Mid(previous_offset, vector.Count - previous_offset));
            }
            return(list);
        }
示例#2
0
 public StringCollection(ByteVectorCollection vectorList, StringType type)
 {
     foreach (ByteVector vector in vectorList)
     {
         Add(vector.ToString(type));
     }
 }
示例#3
0
 /// <summary>
 ///    Constructs and initializes a new instance of <see
 ///    cref="StringCollection" /> by converting a collection of
 ///    <see cref="ByteVector" /> objects to strings using the
 ///    UTF-8 encoding.
 /// </summary>
 /// <param name="vectorList">
 ///    A <see cref="ByteVectorCollection" /> object containing
 ///    values to convert and add to the new instance.
 /// </param>
 public StringCollection(ByteVectorCollection vectorList)
     : this(vectorList, StringType.UTF8)
 {
 }