Esempio n. 1
0
        /// <summary>
        /// Converts an array of characters into a StringBlob.
        /// </summary>
        /// <param name="operand"></param>
        /// <returns></returns>
        public static StringBlob FromCharArray(char[] operand)
        {
            var sb = new StringBlob();

            sb._mem = operand;
            return(sb);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a StringBlob from a string array.
        /// </summary>
        /// <param name="operand">Source array.</param>
        /// <returns></returns>
        public static StringBlob FromStringArray(string[] operand)
        {
            var sb = new StringBlob();

            sb.AddStrings(operand);
            return(sb);
        }
Esempio n. 3
0
        /// <summary>
        /// Converts a byte array into a string blob, with the optional size-descriptor size.
        /// </summary>
        /// <param name="operand">Byte array to copy.</param>
        /// <param name="sizeDesc">Size descriptor kind.</param>
        /// <returns></returns>
        public static StringBlob FromByteArray(byte[] operand, BlobOrdinalTypes sizeDesc = BlobOrdinalTypes.Integer)
        {
            var sb = new StringBlob();

            sb.SizeDescriptorType = sizeDesc;
            sb._mem.SetBytes(Native.CIntPtr(0), operand);
            sb.GetCount();
            return(sb);
        }
Esempio n. 4
0
        /// <summary>
        /// Copies the strings from the StringBlob into the specified array starting at the specified index.
        /// </summary>
        /// <param name="sb">Source object.</param>
        /// <param name="array">Destination array.</param>
        /// <param name="startIndex">Index within array to begin copying.</param>
        public static void ToStringArray(StringBlob sb, string[] array, int startIndex)
        {
            int c = startIndex;

            foreach (string n in sb)
            {
                array[c] = n;
                c       += 1;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Sets the specified byte array into the specified StringBlob.
        /// This will overwrite the contents in the StringBlob.
        /// </summary>
        /// <param name="operand">Target object.</param>
        /// <param name="value">Byte array.</param>
        public static void SetBytes(ref StringBlob operand, byte[] value)
        {
            if (operand is null)
            {
                operand = new StringBlob();
            }

            operand._mem.Alloc(value.Length);
            operand._mem.SetBytes(Native.CIntPtr(0), value);
        }
Esempio n. 6
0
        public object Clone()
        {
            var sb = new StringBlob();

            sb.LpWStr      = LpWStr;
            sb.Dynamic     = Dynamic;
            sb._mem.Length = _mem.Length;
            Native.CopyMemory(sb._mem.handle, _mem.handle, Native.CIntPtr(_mem.Length));
            sb.Refresh();
            return(sb);
        }
        public StringBlobEnumerator(StringBlob subj)
        {
            _Sb = subj;
            ptr = _Sb.SafePtr.handle;
            sd  = _Sb.SizeDescriptorLength;
            if (_Sb.LpWStr == false)
            {
                ptr = ptr + _Sb.SizeDescriptorLength;
            }

            ep = ptr;
            c  = _Sb.Count;
        }
Esempio n. 8
0
 /// <summary>
 /// Gets a string array for the specified StringBlob
 /// </summary>
 /// <param name="operand">StringBlob whose strings to return.</param>
 /// <returns></returns>
 public static string[] ToStringArray(StringBlob operand)
 {
     string[] ToStringArrayRet = default;
     ToStringArrayRet = new StringBlobEnumerator(operand).AllStrings();
     return(ToStringArrayRet);
 }
Esempio n. 9
0
 /// <summary>
 /// Converts the StringBlob into a byte array.
 /// </summary>
 /// <param name="operand"></param>
 /// <returns></returns>
 public static byte[] ToByteArray(StringBlob operand)
 {
     return(operand._mem.GrabBytes());
 }
Esempio n. 10
0
 /// <summary>
 /// Converts the StringBlob into an array of characters.
 /// </summary>
 /// <param name="operand"></param>
 /// <returns></returns>
 public static char[] ToCharArray(StringBlob operand)
 {
     return(Conversions.ToCharArrayRankOne(operand.ToString()));
 }
Esempio n. 11
0
 /// <summary>
 /// Returns the specified StringBlob as a byte array.
 /// </summary>
 /// <param name="operand">Object whose bytes to retrieve.</param>
 /// <returns></returns>
 public static byte[] GetBytes(StringBlob operand)
 {
     return(operand._mem.GrabBytes((IntPtr)0, (int)operand._mem.Length));
 }