예제 #1
0
        public void H5LvisitTest2()
        {
            string path = String.Join("/", m_utf8strings);

            Assert.IsTrue(H5G.create(m_v0_test_file,
                                     Encoding.UTF8.GetBytes(path), m_lcpl_utf8) >= 0);
            Assert.IsTrue(H5G.create(m_v2_test_file,
                                     Encoding.UTF8.GetBytes(path), m_lcpl_utf8) >= 0);

            ArrayList al      = new ArrayList();
            GCHandle  hnd     = GCHandle.Alloc(al);
            IntPtr    op_data = (IntPtr)hnd;

            // the callback is defined in H5LTest.cs
            H5L.iterate_t cb = DelegateMethod;

            Assert.IsTrue(H5L.visit(m_v0_test_file, H5.index_t.NAME,
                                    H5.iter_order_t.NATIVE, cb, op_data) >= 0);
            // we should have 5 elements in the array list
            Assert.IsTrue(al.Count == 5);

            Assert.IsTrue(H5L.visit(m_v2_test_file, H5.index_t.NAME,
                                    H5.iter_order_t.NATIVE, cb, op_data) >= 0);
            // we should have 10 (5 + 5) elements in the array list
            Assert.IsTrue(al.Count == 10);

            hnd.Free();
        }
예제 #2
0
        public void H5LvisitTest1()
        {
            Assert.IsTrue(H5G.create(m_v0_test_file, "A/B/C/D", m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_hard(m_v0_test_file, "A/B/C/D", m_v0_test_file,
                                "shortcut") >= 0);

            Assert.IsTrue(H5G.create(m_v2_test_file, "A/B/C/D", m_lcpl) >= 0);
            Assert.IsTrue(
                H5L.create_hard(m_v2_test_file, "A/B/C/D", m_v2_test_file,
                                "shortcut") >= 0);

            ArrayList al      = new ArrayList();
            GCHandle  hnd     = GCHandle.Alloc(al);
            IntPtr    op_data = (IntPtr)hnd;

            // the callback is defined in H5LTest.cs
            H5L.iterate_t cb = DelegateMethod;

            Assert.IsTrue(H5L.visit(m_v0_test_file, H5.index_t.NAME,
                                    H5.iter_order_t.NATIVE, cb, op_data) >= 0);
            // we should have 5 elements in the array list
            Assert.IsTrue(al.Count == 5);

            Assert.IsTrue(H5L.visit(m_v2_test_file, H5.index_t.NAME,
                                    H5.iter_order_t.NATIVE, cb, op_data) >= 0);
            // we should have 10 (5 + 5) elements in the array list
            Assert.IsTrue(al.Count == 10);

            hnd.Free();
        }
예제 #3
0
        public void H5LiterateTest3()
        {
            for (int i = 0; i < m_utf8strings.Length; ++i)
            {
                Assert.IsTrue(H5L.create_soft(
                                  Encoding.ASCII.GetBytes("this/is/a/soft/link"),
                                  m_v0_test_file, Encoding.UTF8.GetBytes(m_utf8strings[i]),
                                  m_lcpl_utf8) >= 0);

                Assert.IsTrue(H5L.create_soft(
                                  Encoding.ASCII.GetBytes("this/is/a/soft/link"),
                                  m_v2_test_file, Encoding.UTF8.GetBytes(m_utf8strings[i]),
                                  m_lcpl_utf8) >= 0);
            }

            ArrayList al      = new ArrayList();
            GCHandle  hnd     = GCHandle.Alloc(al);
            IntPtr    op_data = (IntPtr)hnd;
            hsize_t   n       = 0;

            // the callback is defined in H5LTest.cs
            H5L.iterate_t cb = DelegateMethod;
            Assert.IsTrue(H5L.iterate(m_v0_test_file, H5.index_t.NAME,
                                      H5.iter_order_t.NATIVE, ref n, cb, op_data) >= 0);
            Assert.IsTrue(al.Count == m_utf8strings.Length);

            n = 0;
            Assert.IsTrue(H5L.iterate(m_v2_test_file, H5.index_t.NAME,
                                      H5.iter_order_t.NATIVE, ref n, cb, op_data) >= 0);
            Assert.IsTrue(al.Count == 2 * m_utf8strings.Length);

            hnd.Free();
        }
예제 #4
0
파일: H5Group.cs 프로젝트: lefi7z/h5ohm
        private string[] CollectObjects(H5O.type_t type)
        {
            const int     CONTINUE = 0;
            int           status;
            List <string> rv = new List <string>();

            // the callback function, called for each item in the iteration
#if HDF5_VER1_10
            H5L.iterate_t op_fun = (long loc, IntPtr name, ref H5L.info_t info, IntPtr op_data) =>
#else
            H5L.iterate_t op_fun = (int loc, IntPtr name, ref H5L.info_t info, IntPtr op_data) =>
#endif
            {
                H5O.info_t oinfo = new H5O.info_t();
                var        bname = Marshal.PtrToStringAnsi(name);
                if ((status = H5O.get_info_by_name(loc, bname, ref oinfo, H5P.DEFAULT)) < 0)
                {
                    return(status);
                }

                if (oinfo.type == type)
                {
                    rv.Add(bname);
                }

                return(CONTINUE);
            };
            ulong tracking_index = 0;
            if ((status = H5L.iterate(ID, H5.index_t.NAME, H5.iter_order_t.NATIVE, ref tracking_index, op_fun, IntPtr.Zero)) < 0)
            {
                throw new H5LibraryException($"H5Literate() returned {status}");
            }

            return(rv.ToArray());
        }
예제 #5
0
        public void H5LiterateTest2()
        {
            ArrayList al      = new ArrayList();
            GCHandle  hnd     = GCHandle.Alloc(al);
            IntPtr    op_data = (IntPtr)hnd;
            hsize_t   n       = 0;

            // the callback is defined in H5ATest.cs
            H5L.iterate_t cb = DelegateMethod;

            Assert.IsFalse(
                H5L.iterate(Utilities.RandomInvalidHandle(),
                            H5.index_t.NAME, H5.iter_order_t.NATIVE, ref n,
                            cb, op_data) >= 0);

            hnd.Free();
        }
예제 #6
0
        public void H5Literate_by_nameTest1()
        {
            Assert.IsTrue(H5L.create_soft("this/is/a/soft/link",
                                          m_v0_test_file, "/A/A", m_lcpl) >= 0);
            Assert.IsTrue(H5L.create_soft("this/is/a/soft/link",
                                          m_v0_test_file, "/A/B", m_lcpl) >= 0);
            Assert.IsTrue(H5L.create_soft("this/is/a/soft/link",
                                          m_v0_test_file, "/A/C", m_lcpl) >= 0);

            ArrayList al      = new ArrayList();
            GCHandle  hnd     = GCHandle.Alloc(al);
            IntPtr    op_data = (IntPtr)hnd;
            hsize_t   n       = 0;

            // the callback is defined in H5LTest.cs
            H5L.iterate_t cb = DelegateMethod;
            Assert.IsTrue(
                H5L.iterate_by_name(m_v0_test_file, "A", H5.index_t.NAME,
                                    H5.iter_order_t.NATIVE, ref n, cb, op_data) >= 0);
            // we should have 3 elements in the array list
            Assert.IsTrue(al.Count == 3);

            Assert.IsTrue(H5L.create_soft("this/is/a/soft/link",
                                          m_v2_test_file, "A/A", m_lcpl) >= 0);
            Assert.IsTrue(H5L.create_soft("this/is/a/soft/link",
                                          m_v2_test_file, "A/B", m_lcpl) >= 0);
            Assert.IsTrue(H5L.create_soft("this/is/a/soft/link",
                                          m_v2_test_file, "A/C", m_lcpl) >= 0);

            n = 0;
            Assert.IsTrue(
                H5L.iterate_by_name(m_v2_test_file, "A", H5.index_t.NAME,
                                    H5.iter_order_t.NATIVE, ref n, cb, op_data) >= 0);
            // we should have 6 (3 + 3) elements in the array list
            Assert.IsTrue(al.Count == 6);

            hnd.Free();
        }