Beispiel #1
0
        public string[] GetCategoryNames()
        {
            /* %typemap(csout) char**options */
            IntPtr cPtr = GdalPINVOKE.Band_GetCategoryNames(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 (GdalPINVOKE.SWIGPendingException.Pending)
            {
                throw GdalPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }