comparison src/ls-mat5.cc @ 4675:f6d6335c08f6

[project @ 2003-12-16 05:11:26 by jwe]
author jwe
date Tue, 16 Dec 2003 05:11:27 +0000
parents 9d8e84d710a5
children 34a740dc31a6
comparison
equal deleted inserted replaced
4674:7736835a5c8e 4675:f6d6335c08f6
423 423
424 for (int j = n_fields-1; j >= 0; j--) 424 for (int j = n_fields-1; j >= 0; j--)
425 { 425 {
426 const char *key = elname + j*field_name_length; 426 const char *key = elname + j*field_name_length;
427 427
428 Cell c (dim_vector (n, 1));
429
428 for (int k = n-1; k >=0; k--) 430 for (int k = n-1; k >=0; k--)
429 m[key](k) = field_elts(j,k); 431 c(k) = field_elts(j,k);
432
433 m.assign (key, c);
430 } 434 }
431 435
432 tc = m; 436 tc = m;
433 } 437 }
434 break; 438 break;
849 } 853 }
850 else if (tc.is_map ()) 854 else if (tc.is_map ())
851 { 855 {
852 // an Octave structure */ 856 // an Octave structure */
853 // recursively write each element of the structure 857 // recursively write each element of the structure
854 Octave_map m = tc.map_value (); 858 const Octave_map m = tc.map_value ();
855 859
856 { 860 {
857 char buf[32]; 861 char buf[32];
858 FOUR_BYTE_INT maxfieldnamelength = 32; 862 FOUR_BYTE_INT maxfieldnamelength = 32;
859 int fieldcnt = 0; 863 int fieldcnt = 0;
860 864
861 for (Octave_map::iterator i = m.begin (); i != m.end (); i++) 865 for (Octave_map::const_iterator i = m.begin (); i != m.end (); i++)
862 fieldcnt++; 866 fieldcnt++;
863 867
864 write_mat5_tag (os, miINT32, 4); 868 write_mat5_tag (os, miINT32, 4);
865 os.write ((char *)&maxfieldnamelength, 4); 869 os.write ((char *)&maxfieldnamelength, 4);
866 write_mat5_tag (os, miINT8, fieldcnt*32); 870 write_mat5_tag (os, miINT8, fieldcnt*32);
867 871
868 for (Octave_map::iterator i = m.begin (); i != m.end (); i++) 872 for (Octave_map::const_iterator i = m.begin (); i != m.end (); i++)
869 { 873 {
870 // write the name of each element 874 // write the name of each element
871 std::string tstr = m.key (i); 875 std::string tstr = m.key (i);
872 memset (buf, 0, 32); 876 memset (buf, 0, 32);
873 strncpy (buf, tstr.c_str (), 31); // only 31 char names permitted 877 strncpy (buf, tstr.c_str (), 31); // only 31 char names permitted
874 os.write (buf, 32); 878 os.write (buf, 32);
875 } 879 }
876 880
877 int len = m.numel (); 881 int len = m.numel ();
878 882
879 for (Octave_map::iterator i = m.begin (); i != m.end (); i++) 883 for (Octave_map::const_iterator i = m.begin (); i != m.end (); i++)
880 { 884 {
881 // write the data of each element 885 // write the data of each element
882 Cell elts = m.contents (i); 886 Cell elts = m.contents (i);
883 887
884 for (int j = 0; j < len; j++) 888 for (int j = 0; j < len; j++)