예제 #1
0
 /// <summary>
 ///    Constructs and initializes a new instance of <see
 ///    cref="StringCollection" /> by converting a collection of
 ///    <see cref="ByteVector" /> objects to strings with a
 ///    specified encoding.
 /// </summary>
 /// <param name="vectorList">
 ///    A <see cref="ByteVectorCollection" /> object containing
 ///    values to convert and add to the new instance.
 /// </param>
 /// <param name="type">
 ///    A <see cref="StringType" /> specifying what encoding to
 ///    use when converting the data to strings.
 /// </param>
 public StringCollection(ByteVectorCollection vectorList,
                         StringType type)
 {
     foreach (ByteVector vector in vectorList)
     {
         Add(vector.ToString(type));
     }
 }
예제 #2
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");
            }

            ByteVectorCollection list = new ByteVectorCollection();
            int previous_offset       = 0;

            for (int offset = vector.Find(pattern, 0, byteAlign);
                 offset != -1 && (max == 0 ||
                                  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);
        }
예제 #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)
 {
 }