Ejemplo n.º 1
0
        public string[] ReadAsStringArray()
        {
            /* %typemap(csout) char** CSL */
            IntPtr cPtr = GdalPINVOKE.Attribute_ReadAsStringArray(swigCPtr);
            IntPtr objPtr;
            int    count = 0;

            if (cPtr != IntPtr.Zero)
            {
                while (Marshal.ReadIntPtr(cPtr, count * IntPtr.Size) != IntPtr.Zero)
                {
                    ++count;
                }
            }
            string[] ret = new string[count];
            if (count > 0)
            {
                for (int cx = 0; cx < count; cx++)
                {
                    objPtr  = System.Runtime.InteropServices.Marshal.ReadIntPtr(cPtr, cx * System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr)));
                    ret[cx] = (objPtr == IntPtr.Zero) ? null : System.Runtime.InteropServices.Marshal.PtrToStringAnsi(objPtr);
                }
            }
            if (cPtr != IntPtr.Zero)
            {
                GdalPINVOKE.StringListDestroy(cPtr);
            }

            if (GdalPINVOKE.SWIGPendingException.Pending)
            {
                throw GdalPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }