ARTS  2.0.49
xml_io_array_types.cc
Go to the documentation of this file.
1 /* Copyright (C) 2003-2008 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
18 
20 // File description
22 
31 #include "arts.h"
32 #include "xml_io_private.h"
33 #include "xml_io_types.h"
34 #include "jacobian.h"
35 
36 
38 // Overloaded functions for reading/writing data from/to XML stream
40 
41 //=== Array<SpeciesRecord> ================================================
42 
44 
49 void
50 xml_read_from_stream (istream& is_xml,
51  Array<SpeciesRecord>& asrecord,
52  bifstream *pbifs,
53  const Verbosity& verbosity)
54 {
55  ArtsXMLTag tag(verbosity);
56  Index nelem;
57 
58  tag.read_from_stream (is_xml);
59  tag.check_name ("Array");
60  tag.check_attribute ("type", "SpeciesData");
61 
62  tag.get_attribute_value ("nelem", nelem);
63  asrecord.resize (nelem);
64 
65  Index n;
66  try
67  {
68  for (n = 0; n < nelem; n++)
69  {
70  xml_read_from_stream (is_xml, asrecord[n], pbifs, verbosity);
71  }
72  } catch (runtime_error e) {
73  ostringstream os;
74  os << "Error reading SpeciesData: "
75  << "\n Element: " << n
76  << "\n" << e.what();
77  throw runtime_error(os.str());
78  }
79 
80  tag.read_from_stream (is_xml);
81  tag.check_name ("/Array");
82 }
83 
84 
86 
92 void
93 xml_write_to_stream (ostream& os_xml,
94  const Array<SpeciesRecord>& asrecord,
95  bofstream *pbofs,
96  const String& name,
97  const Verbosity& verbosity)
98 {
99  ArtsXMLTag open_tag(verbosity);
100  ArtsXMLTag close_tag(verbosity);
101 
102  open_tag.set_name ("Array");
103  if (name.length ())
104  open_tag.add_attribute ("name", name);
105 
106  open_tag.add_attribute ("type", "SpeciesData");
107  open_tag.add_attribute ("nelem", asrecord.nelem ());
108 
109  open_tag.write_to_stream (os_xml);
110  os_xml << '\n';
111 
112  for (Index n = 0; n < asrecord.nelem (); n++)
113  {
114  xml_write_to_stream (os_xml, asrecord[n], pbofs, "", verbosity);
115  }
116 
117  close_tag.set_name ("/Array");
118  close_tag.write_to_stream (os_xml);
119 
120  os_xml << '\n';
121 }
122 
123 
124 //=== ArrayOfArrayOfSpeciesTag ================================================
125 
127 
132 void
133 xml_read_from_stream (istream& is_xml,
134  ArrayOfArrayOfSpeciesTag& aastag,
135  bifstream *pbifs, const Verbosity& verbosity)
136 {
137  ArtsXMLTag tag(verbosity);
138  Index nelem;
139 
140  tag.read_from_stream (is_xml);
141  tag.check_name ("Array");
142  tag.check_attribute ("type", "ArrayOfSpeciesTag");
143 
144  tag.get_attribute_value ("nelem", nelem);
145  aastag.resize (nelem);
146 
147  Index n;
148  try
149  {
150  for (n = 0; n < nelem; n++)
151  {
152  xml_read_from_stream (is_xml, aastag[n], pbifs, verbosity);
153  }
154  } catch (runtime_error e) {
155  ostringstream os;
156  os << "Error reading ArrayOfArrayOfSpeciesTag: "
157  << "\n Element: " << n
158  << "\n" << e.what();
159  throw runtime_error(os.str());
160  }
161 
162 
163  tag.read_from_stream (is_xml);
164  tag.check_name ("/Array");
165 }
166 
167 
169 
175 void
176 xml_write_to_stream (ostream& os_xml,
177  const ArrayOfArrayOfSpeciesTag& aastag,
178  bofstream *pbofs,
179  const String& name, const Verbosity& verbosity)
180 {
181  ArtsXMLTag open_tag(verbosity);
182  ArtsXMLTag close_tag(verbosity);
183 
184  open_tag.set_name ("Array");
185  if (name.length ())
186  open_tag.add_attribute ("name", name);
187 
188  open_tag.add_attribute ("type", "ArrayOfSpeciesTag");
189  open_tag.add_attribute ("nelem", aastag.nelem ());
190 
191  open_tag.write_to_stream (os_xml);
192  os_xml << '\n';
193 
194  for (Index n = 0; n < aastag.nelem (); n++)
195  {
196  xml_write_to_stream (os_xml, aastag[n], pbofs, "", verbosity);
197  }
198 
199  close_tag.set_name ("/Array");
200  close_tag.write_to_stream (os_xml);
201 
202  os_xml << '\n';
203 }
204 
205 
206 
207 //=== ArrayOfPpath =========================================================
208 
210 
215 void
216 xml_read_from_stream (istream& is_xml,
217  ArrayOfPpath& appath,
218  bifstream *pbifs, const Verbosity& verbosity)
219 {
220  ArtsXMLTag tag(verbosity);
221  Index nelem;
222 
223  tag.read_from_stream (is_xml);
224  tag.check_name ("Array");
225  tag.check_attribute ("type", "Ppath");
226 
227  tag.get_attribute_value ("nelem", nelem);
228  appath.resize (nelem);
229 
230  Index n;
231  try
232  {
233  for (n = 0; n < nelem; n++)
234  {
235  xml_read_from_stream (is_xml, appath[n], pbifs, verbosity);
236  }
237  } catch (runtime_error e) {
238  ostringstream os;
239  os << "Error reading ArrayOfPpath: "
240  << "\n Element: " << n
241  << "\n" << e.what();
242  throw runtime_error(os.str());
243  }
244 
245 
246  tag.read_from_stream (is_xml);
247  tag.check_name ("/Array");
248 }
249 
250 
251 
253 
259 void
260 xml_write_to_stream (ostream& os_xml,
261  const ArrayOfPpath& appath,
262  bofstream *pbofs,
263  const String& name, const Verbosity& verbosity)
264 {
265  ArtsXMLTag open_tag(verbosity);
266  ArtsXMLTag close_tag(verbosity);
267 
268  open_tag.set_name ("Array");
269  if (name.length ())
270  open_tag.add_attribute ("name", name);
271 
272  open_tag.add_attribute ("type", "Ppath");
273  open_tag.add_attribute ("nelem", appath.nelem ());
274 
275  open_tag.write_to_stream (os_xml);
276  os_xml << '\n';
277 
278  for (Index n = 0; n < appath.nelem (); n++)
279  {
280  xml_write_to_stream (os_xml, appath[n], pbofs, "", verbosity);
281  }
282 
283  close_tag.set_name ("/Array");
284  close_tag.write_to_stream (os_xml);
285 
286  os_xml << '\n';
287 }
288 
289 
290 
291 //=== ArrayOfArrayOfTensor3==================================================
292 
294 
299 void
300 xml_read_from_stream (istream& is_xml,
301  ArrayOfArrayOfTensor3& aatensor3,
302  bifstream *pbifs, const Verbosity& verbosity)
303 {
304  ArtsXMLTag tag(verbosity);
305  Index nelem;
306 
307  tag.read_from_stream (is_xml);
308  tag.check_name ("Array");
309  tag.check_attribute ("type", "ArrayOfTensor3");
310 
311  tag.get_attribute_value ("nelem", nelem);
312  aatensor3.resize (nelem);
313 
314  Index n;
315  try
316  {
317  for (n = 0; n < nelem; n++)
318  {
319  xml_read_from_stream (is_xml, aatensor3[n], pbifs, verbosity);
320  }
321  } catch (runtime_error e) {
322  ostringstream os;
323  os << "Error reading ArrayOfArrayOfTensor3: "
324  << "\n Element: " << n
325  << "\n" << e.what();
326  throw runtime_error(os.str());
327  }
328 
329 
330  tag.read_from_stream (is_xml);
331  tag.check_name ("/Array");
332 }
333 
334 
336 
342 void
343 xml_write_to_stream (ostream& os_xml,
344  const ArrayOfArrayOfTensor3& aatensor3,
345  bofstream *pbofs,
346  const String& name, const Verbosity& verbosity)
347 {
348  ArtsXMLTag open_tag(verbosity);
349  ArtsXMLTag close_tag(verbosity);
350 
351  open_tag.set_name ("Array");
352  if (name.length ())
353  open_tag.add_attribute ("name", name);
354 
355  open_tag.add_attribute ("type", "ArrayOfTensor3");
356  open_tag.add_attribute ("nelem", aatensor3.nelem ());
357 
358  open_tag.write_to_stream (os_xml);
359  os_xml << '\n';
360 
361  for (Index n = 0; n < aatensor3.nelem (); n++)
362  {
363  xml_write_to_stream (os_xml, aatensor3[n], pbofs, "", verbosity);
364  }
365 
366  close_tag.set_name ("/Array");
367  close_tag.write_to_stream (os_xml);
368 
369  os_xml << '\n';
370 }
371 
372 
373 //=== ArrayOfArrayOfTensor6==================================================
374 
376 
381 void
382 xml_read_from_stream (istream& is_xml,
383  ArrayOfArrayOfTensor6& aatensor6,
384  bifstream *pbifs, const Verbosity& verbosity)
385 {
386  ArtsXMLTag tag(verbosity);
387  Index nelem;
388 
389  tag.read_from_stream (is_xml);
390  tag.check_name ("Array");
391  tag.check_attribute ("type", "ArrayOfTensor6");
392 
393  tag.get_attribute_value ("nelem", nelem);
394  aatensor6.resize (nelem);
395 
396  Index n;
397  try
398  {
399  for (n = 0; n < nelem; n++)
400  {
401  xml_read_from_stream (is_xml, aatensor6[n], pbifs, verbosity);
402  }
403  } catch (runtime_error e) {
404  ostringstream os;
405  os << "Error reading ArrayOfArrayOfTensor6: "
406  << "\n Element: " << n
407  << "\n" << e.what();
408  throw runtime_error(os.str());
409  }
410 
411  tag.read_from_stream (is_xml);
412  tag.check_name ("/Array");
413 }
414 
415 
417 
423 void
424 xml_write_to_stream (ostream& os_xml,
425  const ArrayOfArrayOfTensor6& aatensor6,
426  bofstream *pbofs,
427  const String& name, const Verbosity& verbosity)
428 {
429  ArtsXMLTag open_tag(verbosity);
430  ArtsXMLTag close_tag(verbosity);
431 
432  open_tag.set_name ("Array");
433  if (name.length ())
434  open_tag.add_attribute ("name", name);
435 
436  open_tag.add_attribute ("type", "ArrayOfTensor6");
437  open_tag.add_attribute ("nelem", aatensor6.nelem ());
438 
439  open_tag.write_to_stream (os_xml);
440  os_xml << '\n';
441 
442  for (Index n = 0; n < aatensor6.nelem (); n++)
443  {
444  xml_write_to_stream (os_xml, aatensor6[n], pbofs, "", verbosity);
445  }
446 
447  close_tag.set_name ("/Array");
448  close_tag.write_to_stream (os_xml);
449 
450  os_xml << '\n';
451 }
452 
453 
454 //=== ArrayOfGridPos =========================================================
455 
457 
462 void
463 xml_read_from_stream (istream& is_xml,
464  ArrayOfGridPos& agpos,
465  bifstream *pbifs, const Verbosity& verbosity)
466 {
467  ArtsXMLTag tag(verbosity);
468  Index nelem;
469 
470  tag.read_from_stream (is_xml);
471  tag.check_name ("Array");
472  tag.check_attribute ("type", "GridPos");
473 
474  tag.get_attribute_value ("nelem", nelem);
475  agpos.resize (nelem);
476 
477  Index n;
478  try
479  {
480  for (n = 0; n < nelem; n++)
481  {
482  xml_read_from_stream (is_xml, agpos[n], pbifs, verbosity);
483  }
484  } catch (runtime_error e) {
485  ostringstream os;
486  os << "Error reading ArrayOfGridPos: "
487  << "\n Element: " << n
488  << "\n" << e.what();
489  throw runtime_error(os.str());
490  }
491 
492 
493  tag.read_from_stream (is_xml);
494  tag.check_name ("/Array");
495 }
496 
497 
499 
505 void
506 xml_write_to_stream (ostream& os_xml,
507  const ArrayOfGridPos& agpos,
508  bofstream *pbofs,
509  const String& name, const Verbosity& verbosity)
510 {
511  ArtsXMLTag open_tag(verbosity);
512  ArtsXMLTag close_tag(verbosity);
513 
514  open_tag.set_name ("Array");
515  if (name.length ())
516  open_tag.add_attribute ("name", name);
517 
518  open_tag.add_attribute ("type", "GridPos");
519  open_tag.add_attribute ("nelem", agpos.nelem ());
520 
521  open_tag.write_to_stream (os_xml);
522  os_xml << '\n';
523 
524  for (Index n = 0; n < agpos.nelem (); n++)
525  {
526  xml_write_to_stream (os_xml, agpos[n], pbofs, "", verbosity);
527  }
528 
529  close_tag.set_name ("/Array");
530  close_tag.write_to_stream (os_xml);
531 
532  os_xml << '\n';
533 }
534 
535 //=== ArrayOfArrayOfGridPos =====================================
536 
538 
543 void
544 xml_read_from_stream (istream& is_xml,
545  ArrayOfArrayOfGridPos& aagpos,
546  bifstream *pbifs, const Verbosity& verbosity)
547 {
548  ArtsXMLTag tag(verbosity);
549  Index nelem;
550 
551  tag.read_from_stream (is_xml);
552  tag.check_name ("Array");
553  tag.check_attribute ("type", "ArrayOfGridPos");
554 
555  tag.get_attribute_value ("nelem", nelem);
556  aagpos.resize (nelem);
557 
558  Index n;
559  try
560  {
561  for (n = 0; n < nelem; n++)
562  {
563  xml_read_from_stream (is_xml, aagpos[n], pbifs, verbosity);
564  }
565  } catch (runtime_error e) {
566  ostringstream os;
567  os << "Error reading ArrayOfArrayOfGridPos: "
568  << "\n Element: " << n
569  << "\n" << e.what();
570  throw runtime_error(os.str());
571  }
572 
573 
574  tag.read_from_stream (is_xml);
575  tag.check_name ("/Array");
576 }
577 
578 
580 
586 void
587 xml_write_to_stream (ostream& os_xml,
588  const ArrayOfArrayOfGridPos& aagpos,
589  bofstream *pbofs,
590  const String& name, const Verbosity& verbosity)
591 {
592  ArtsXMLTag open_tag(verbosity);
593  ArtsXMLTag close_tag(verbosity);
594 
595  open_tag.set_name ("Array");
596  if (name.length ())
597  open_tag.add_attribute ("name", name);
598 
599  open_tag.add_attribute ("type", "ArrayOfGridPos");
600  open_tag.add_attribute ("nelem", aagpos.nelem ());
601 
602  open_tag.write_to_stream (os_xml);
603  os_xml << '\n';
604 
605  for (Index n = 0; n < aagpos.nelem (); n++)
606  {
607  xml_write_to_stream (os_xml, aagpos[n], pbofs, "", verbosity);
608  }
609 
610  close_tag.set_name ("/Array");
611  close_tag.write_to_stream (os_xml);
612 
613  os_xml << '\n';
614 }
615 
616 //=== ArrayOfArrayOfArrayOfGridPos =====================================
617 
619 
624 void
625 xml_read_from_stream (istream& is_xml,
627  bifstream *pbifs, const Verbosity& verbosity)
628 {
629  ArtsXMLTag tag(verbosity);
630  Index nelem;
631 
632  tag.read_from_stream (is_xml);
633  tag.check_name ("Array");
634  tag.check_attribute ("type", "ArrayOfArrayOfGridPos");
635 
636  tag.get_attribute_value ("nelem", nelem);
637  aaagpos.resize (nelem);
638 
639  Index n;
640  try
641  {
642  for (n = 0; n < nelem; n++)
643  {
644  xml_read_from_stream (is_xml, aaagpos[n], pbifs, verbosity);
645  }
646  } catch (runtime_error e) {
647  ostringstream os;
648  os << "Error reading ArrayOfArrayOfArrayOfGridPos: "
649  << "\n Element: " << n
650  << "\n" << e.what();
651  throw runtime_error(os.str());
652  }
653 
654 
655  tag.read_from_stream (is_xml);
656  tag.check_name ("/Array");
657 }
658 
659 
661 
667 void
668 xml_write_to_stream (ostream& os_xml,
669  const ArrayOfArrayOfArrayOfGridPos& aaagpos,
670  bofstream *pbofs,
671  const String& name, const Verbosity& verbosity)
672 {
673  ArtsXMLTag open_tag(verbosity);
674  ArtsXMLTag close_tag(verbosity);
675 
676  open_tag.set_name ("Array");
677  if (name.length ())
678  open_tag.add_attribute ("name", name);
679 
680  open_tag.add_attribute ("type", "ArrayOfArrayOfGridPos");
681  open_tag.add_attribute ("nelem", aaagpos.nelem ());
682 
683  open_tag.write_to_stream (os_xml);
684  os_xml << '\n';
685 
686  for (Index n = 0; n < aaagpos.nelem (); n++)
687  {
688  xml_write_to_stream (os_xml, aaagpos[n], pbofs, "", verbosity);
689  }
690 
691  close_tag.set_name ("/Array");
692  close_tag.write_to_stream (os_xml);
693 
694  os_xml << '\n';
695 }
696 
697 
698 //=== ArrayOfArrayOfArrayOfArrayOfGridPos =====================================
699 
701 
706 void
707 xml_read_from_stream (istream& is_xml,
709  bifstream *pbifs, const Verbosity& verbosity)
710 {
711  ArtsXMLTag tag(verbosity);
712  Index nelem;
713 
714  tag.read_from_stream (is_xml);
715  tag.check_name ("Array");
716  tag.check_attribute ("type", "ArrayOfArrayOfArrayOfGridPos");
717 
718  tag.get_attribute_value ("nelem", nelem);
719  aaaagpos.resize (nelem);
720 
721  Index n;
722  try
723  {
724  for (n = 0; n < nelem; n++)
725  {
726  xml_read_from_stream (is_xml, aaaagpos[n], pbifs, verbosity);
727  }
728  } catch (runtime_error e) {
729  ostringstream os;
730  os << "Error reading ArrayOfArrayOfArrayOfArrayOfGridPos: "
731  << "\n Element: " << n
732  << "\n" << e.what();
733  throw runtime_error(os.str());
734  }
735 
736 
737  tag.read_from_stream (is_xml);
738  tag.check_name ("/Array");
739 }
740 
741 
743 
749 void
750 xml_write_to_stream (ostream& os_xml,
751  const ArrayOfArrayOfArrayOfArrayOfGridPos& aaaagpos,
752  bofstream *pbofs,
753  const String& name, const Verbosity& verbosity)
754 {
755  ArtsXMLTag open_tag(verbosity);
756  ArtsXMLTag close_tag(verbosity);
757 
758  open_tag.set_name ("Array");
759  if (name.length ())
760  open_tag.add_attribute ("name", name);
761 
762  open_tag.add_attribute ("type", "ArrayOfArrayOfArrayOfGridPos");
763  open_tag.add_attribute ("nelem", aaaagpos.nelem ());
764 
765  open_tag.write_to_stream (os_xml);
766  os_xml << '\n';
767 
768  for (Index n = 0; n < aaaagpos.nelem (); n++)
769  {
770  xml_write_to_stream (os_xml, aaaagpos[n], pbofs, "", verbosity);
771  }
772 
773  close_tag.set_name ("/Array");
774  close_tag.write_to_stream (os_xml);
775 
776  os_xml << '\n';
777 }
778 
779 
780 
781 //=== ArrayOfIndex ===========================================================
782 
784 
789 void
790 xml_read_from_stream (istream& is_xml,
791  ArrayOfIndex& aindex,
792  bifstream *pbifs, const Verbosity& verbosity)
793 {
794  ArtsXMLTag tag(verbosity);
795  Index nelem;
796 
797  tag.read_from_stream (is_xml);
798  tag.check_name ("Array");
799  tag.check_attribute ("type", "Index");
800 
801  tag.get_attribute_value ("nelem", nelem);
802  aindex.resize (nelem);
803 
804  Index n;
805  try
806  {
807  for (n = 0; n < nelem; n++)
808  {
809  xml_read_from_stream (is_xml, aindex[n], pbifs, verbosity);
810  }
811  } catch (runtime_error e) {
812  ostringstream os;
813  os << "Error reading ArrayOfIndex: "
814  << "\n Element: " << n
815  << "\n" << e.what();
816  throw runtime_error(os.str());
817  }
818 
819 
820  tag.read_from_stream (is_xml);
821  tag.check_name ("/Array");
822 }
823 
824 
826 
832 void
833 xml_write_to_stream (ostream& os_xml,
834  const ArrayOfIndex& aindex,
835  bofstream *pbofs,
836  const String& name, const Verbosity& verbosity)
837 {
838  ArtsXMLTag open_tag(verbosity);
839  ArtsXMLTag close_tag(verbosity);
840 
841  open_tag.set_name ("Array");
842  if (name.length ())
843  open_tag.add_attribute ("name", name);
844 
845  open_tag.add_attribute ("type", "Index");
846  open_tag.add_attribute ("nelem", aindex.nelem ());
847 
848  open_tag.write_to_stream (os_xml);
849  os_xml << '\n';
850 
851  for (Index n = 0; n < aindex.nelem (); n++)
852  {
853  xml_write_to_stream (os_xml, aindex[n], pbofs, "", verbosity);
854  }
855 
856  close_tag.set_name ("/Array");
857  close_tag.write_to_stream (os_xml);
858 
859  os_xml << '\n';
860 }
861 
862 
863 
864 //=== ArrayOfArrayOfIndex =====================================================
865 
867 
872 void
873 xml_read_from_stream (istream& is_xml,
874  ArrayOfArrayOfIndex& aaindex,
875  bifstream *pbifs, const Verbosity& verbosity)
876 {
877  ArtsXMLTag tag(verbosity);
878  Index nelem;
879 
880  tag.read_from_stream (is_xml);
881  tag.check_name ("Array");
882  tag.check_attribute ("type", "ArrayOfIndex");
883 
884  tag.get_attribute_value ("nelem", nelem);
885  aaindex.resize (nelem);
886 
887  Index n;
888  try
889  {
890  for (n = 0; n < nelem; n++)
891  {
892  xml_read_from_stream (is_xml, aaindex[n], pbifs, verbosity);
893  }
894  } catch (runtime_error e) {
895  ostringstream os;
896  os << "Error reading ArrayOfArrayOfIndex: "
897  << "\n Element: " << n
898  << "\n" << e.what();
899  throw runtime_error(os.str());
900  }
901 
902  tag.read_from_stream (is_xml);
903  tag.check_name ("/Array");
904 }
905 
906 
908 
914 void
915 xml_write_to_stream (ostream& os_xml,
916  const ArrayOfArrayOfIndex& aaindex,
917  bofstream *pbofs,
918  const String& name, const Verbosity& verbosity)
919 {
920  ArtsXMLTag open_tag(verbosity);
921  ArtsXMLTag close_tag(verbosity);
922 
923  open_tag.set_name ("Array");
924  if (name.length ())
925  open_tag.add_attribute ("name", name);
926 
927  open_tag.add_attribute ("type", "ArrayOfIndex");
928  open_tag.add_attribute ("nelem", aaindex.nelem ());
929 
930  open_tag.write_to_stream (os_xml);
931  os_xml << '\n';
932 
933  for (Index n = 0; n < aaindex.nelem (); n++)
934  {
935  xml_write_to_stream (os_xml, aaindex[n], pbofs, "", verbosity);
936  }
937 
938  close_tag.set_name ("/Array");
939  close_tag.write_to_stream (os_xml);
940 
941  os_xml << '\n';
942 }
943 
944 
945 
946 
947 //=== ArrayOfIsotopeRecord ===================================================
948 
950 
955 void
956 xml_read_from_stream (istream& is_xml,
957  Array<IsotopeRecord>& airecord,
958  bifstream *pbifs, const Verbosity& verbosity)
959 {
960  ArtsXMLTag tag(verbosity);
961  Index nelem;
962 
963  tag.read_from_stream (is_xml);
964  tag.check_name ("Array");
965  tag.check_attribute ("type", "IsotopeRecord");
966 
967  tag.get_attribute_value ("nelem", nelem);
968  airecord.resize (nelem);
969 
970  Index n;
971  try
972  {
973  for (n = 0; n < nelem; n++)
974  {
975  xml_read_from_stream (is_xml, airecord[n], pbifs, verbosity);
976  }
977  } catch (runtime_error e) {
978  ostringstream os;
979  os << "Error reading ArrayOfIsotopeRecord: "
980  << "\n Element: " << n
981  << "\n" << e.what();
982  throw runtime_error(os.str());
983  }
984 
985  tag.read_from_stream (is_xml);
986  tag.check_name ("/Array");
987 }
988 
989 
991 
997 void
998 xml_write_to_stream (ostream& os_xml,
999  const Array<IsotopeRecord>& airecord,
1000  bofstream *pbofs,
1001  const String& name, const Verbosity& verbosity)
1002 {
1003  ArtsXMLTag open_tag(verbosity);
1004  ArtsXMLTag close_tag(verbosity);
1005 
1006  open_tag.set_name ("Array");
1007  if (name.length ())
1008  open_tag.add_attribute ("name", name);
1009 
1010  open_tag.add_attribute ("type", "IsotopeRecord");
1011  open_tag.add_attribute ("nelem", airecord.nelem ());
1012 
1013  open_tag.write_to_stream (os_xml);
1014  os_xml << '\n';
1015 
1016  for (Index n = 0; n < airecord.nelem (); n++)
1017  {
1018  xml_write_to_stream (os_xml, airecord[n], pbofs, "", verbosity);
1019  }
1020 
1021  close_tag.set_name ("/Array");
1022  close_tag.write_to_stream (os_xml);
1023 
1024  os_xml << '\n';
1025 }
1026 
1027 
1028 
1029 //=== ArrayOfMatrix ==========================================================
1030 
1032 
1037 void
1038 xml_read_from_stream (istream& is_xml,
1039  ArrayOfMatrix& amatrix,
1040  bifstream *pbifs, const Verbosity& verbosity)
1041 {
1042  ArtsXMLTag tag(verbosity);
1043  Index nelem;
1044 
1045  tag.read_from_stream (is_xml);
1046  tag.check_name ("Array");
1047  tag.check_attribute ("type", "Matrix");
1048 
1049  tag.get_attribute_value ("nelem", nelem);
1050  amatrix.resize (nelem);
1051 
1052  Index n;
1053  try
1054  {
1055  for (n = 0; n < nelem; n++)
1056  {
1057  xml_read_from_stream (is_xml, amatrix[n], pbifs, verbosity);
1058  }
1059  } catch (runtime_error e) {
1060  ostringstream os;
1061  os << "Error reading ArrayOfMatrix: "
1062  << "\n Element: " << n
1063  << "\n" << e.what();
1064  throw runtime_error(os.str());
1065  }
1066 
1067 
1068  tag.read_from_stream (is_xml);
1069  tag.check_name ("/Array");
1070 }
1071 
1072 
1074 
1080 void
1081 xml_write_to_stream (ostream& os_xml,
1082  const ArrayOfMatrix& amatrix,
1083  bofstream *pbofs,
1084  const String& name, const Verbosity& verbosity)
1085 {
1086  ArtsXMLTag open_tag(verbosity);
1087  ArtsXMLTag close_tag(verbosity);
1088 
1089  open_tag.set_name ("Array");
1090  if (name.length ())
1091  open_tag.add_attribute ("name", name);
1092 
1093  open_tag.add_attribute ("type", "Matrix");
1094  open_tag.add_attribute ("nelem", amatrix.nelem ());
1095 
1096  open_tag.write_to_stream (os_xml);
1097  os_xml << '\n';
1098 
1099  for (Index n = 0; n < amatrix.nelem (); n++)
1100  {
1101  xml_write_to_stream (os_xml, amatrix[n], pbofs, "", verbosity);
1102  }
1103 
1104  close_tag.set_name ("/Array");
1105  close_tag.write_to_stream (os_xml);
1106 
1107  os_xml << '\n';
1108 }
1109 
1110 
1111 //=== ArrayOfArrayOfMatrix====================================================
1112 
1114 
1119 void
1120 xml_read_from_stream (istream& is_xml,
1121  ArrayOfArrayOfMatrix& aamatrix,
1122  bifstream *pbifs, const Verbosity& verbosity)
1123 {
1124  ArtsXMLTag tag(verbosity);
1125  Index nelem;
1126 
1127  tag.read_from_stream (is_xml);
1128  tag.check_name ("Array");
1129  tag.check_attribute ("type", "ArrayOfMatrix");
1130 
1131  tag.get_attribute_value ("nelem", nelem);
1132  aamatrix.resize (nelem);
1133 
1134  Index n;
1135  try
1136  {
1137  for (n = 0; n < nelem; n++)
1138  {
1139  xml_read_from_stream (is_xml, aamatrix[n], pbifs, verbosity);
1140  }
1141  } catch (runtime_error e) {
1142  ostringstream os;
1143  os << "Error reading ArrayOfArrayOfMatrix: "
1144  << "\n Element: " << n
1145  << "\n" << e.what();
1146  throw runtime_error(os.str());
1147  }
1148 
1149  tag.read_from_stream (is_xml);
1150  tag.check_name ("/Array");
1151 }
1152 
1153 
1155 
1161 void
1162 xml_write_to_stream (ostream& os_xml,
1163  const ArrayOfArrayOfMatrix& aamatrix,
1164  bofstream *pbofs,
1165  const String& name, const Verbosity& verbosity)
1166 {
1167  ArtsXMLTag open_tag(verbosity);
1168  ArtsXMLTag close_tag(verbosity);
1169 
1170  open_tag.set_name ("Array");
1171  if (name.length ())
1172  open_tag.add_attribute ("name", name);
1173 
1174  open_tag.add_attribute ("type", "ArrayOfMatrix");
1175  open_tag.add_attribute ("nelem", aamatrix.nelem ());
1176 
1177  open_tag.write_to_stream (os_xml);
1178  os_xml << '\n';
1179 
1180  for (Index n = 0; n < aamatrix.nelem (); n++)
1181  {
1182  xml_write_to_stream (os_xml, aamatrix[n], pbofs, "", verbosity);
1183  }
1184 
1185  close_tag.set_name ("/Array");
1186  close_tag.write_to_stream (os_xml);
1187 
1188  os_xml << '\n';
1189 }
1190 
1191 
1192 //=== ArrayOfSparse ==========================================================
1193 
1195 
1200 void
1201 xml_read_from_stream (istream& is_xml,
1202  ArrayOfSparse& asparse,
1203  bifstream *pbifs, const Verbosity& verbosity)
1204 {
1205  ArtsXMLTag tag(verbosity);
1206  Index nelem;
1207 
1208  tag.read_from_stream (is_xml);
1209  tag.check_name ("Array");
1210  tag.check_attribute ("type", "Sparse");
1211 
1212  tag.get_attribute_value ("nelem", nelem);
1213  asparse.resize (nelem);
1214 
1215  Index n;
1216  try
1217  {
1218  for (n = 0; n < nelem; n++)
1219  {
1220  xml_read_from_stream (is_xml, asparse[n], pbifs, verbosity);
1221  }
1222  } catch (runtime_error e) {
1223  ostringstream os;
1224  os << "Error reading ArrayOfSparse: "
1225  << "\n Element: " << n
1226  << "\n" << e.what();
1227  throw runtime_error(os.str());
1228  }
1229 
1230 
1231  tag.read_from_stream (is_xml);
1232  tag.check_name ("/Array");
1233 }
1234 
1235 
1237 
1243 void
1244 xml_write_to_stream (ostream& os_xml,
1245  const ArrayOfSparse& asparse,
1246  bofstream *pbofs,
1247  const String& name, const Verbosity& verbosity)
1248 {
1249  ArtsXMLTag open_tag(verbosity);
1250  ArtsXMLTag close_tag(verbosity);
1251 
1252  open_tag.set_name ("Array");
1253  if (name.length ())
1254  open_tag.add_attribute ("name", name);
1255 
1256  open_tag.add_attribute ("type", "Sparse");
1257  open_tag.add_attribute ("nelem", asparse.nelem ());
1258 
1259  open_tag.write_to_stream (os_xml);
1260  os_xml << '\n';
1261 
1262  for (Index n = 0; n < asparse.nelem (); n++)
1263  {
1264  xml_write_to_stream (os_xml, asparse[n], pbofs, "", verbosity);
1265  }
1266 
1267  close_tag.set_name ("/Array");
1268  close_tag.write_to_stream (os_xml);
1269 
1270  os_xml << '\n';
1271 }
1272 
1273 
1274 //=== ArrayOfRetrievalQuantity =======================================
1275 
1277 
1282 void
1283 xml_read_from_stream (istream& is_xml,
1285  bifstream *pbifs, const Verbosity& verbosity)
1286 {
1287  ArtsXMLTag tag(verbosity);
1288  Index nelem;
1289 
1290  tag.read_from_stream (is_xml);
1291  tag.check_name ("Array");
1292  tag.check_attribute ("type", "RetrievalQuantity");
1293 
1294  tag.get_attribute_value ("nelem", nelem);
1295  arq.resize (nelem);
1296 
1297  Index n;
1298  try
1299  {
1300  for (n = 0; n < nelem; n++)
1301  {
1302  xml_read_from_stream (is_xml, arq[n], pbifs, verbosity);
1303  }
1304  } catch (runtime_error e) {
1305  ostringstream os;
1306  os << "Error reading ArrayOfRetrievalQuantity: "
1307  << "\n Element: " << n
1308  << "\n" << e.what();
1309  throw runtime_error(os.str());
1310  }
1311 
1312  tag.read_from_stream (is_xml);
1313  tag.check_name ("/Array");
1314 }
1315 
1316 
1318 
1324 void
1325 xml_write_to_stream (ostream& os_xml,
1326  const ArrayOfRetrievalQuantity& arq,
1327  bofstream *pbofs,
1328  const String& name, const Verbosity& verbosity)
1329 {
1330  ArtsXMLTag open_tag(verbosity);
1331  ArtsXMLTag close_tag(verbosity);
1332 
1333  open_tag.set_name ("Array");
1334  if (name.length ())
1335  open_tag.add_attribute ("name", name);
1336 
1337  open_tag.add_attribute ("type", "RetrievalQuantity");
1338  open_tag.add_attribute ("nelem", arq.nelem ());
1339 
1340  open_tag.write_to_stream (os_xml);
1341  os_xml << '\n';
1342 
1343  for (Index n = 0; n < arq.nelem (); n++)
1344  {
1345  xml_write_to_stream (os_xml, arq[n], pbofs, "", verbosity);
1346  }
1347 
1348  close_tag.set_name ("/Array");
1349  close_tag.write_to_stream (os_xml);
1350 
1351  os_xml << '\n';
1352 }
1353 
1354 
1355 //=== ArrayOfSpeciesTag ================================================
1356 
1358 
1363 void
1364 xml_read_from_stream (istream& is_xml,
1365  ArrayOfSpeciesTag& astag,
1366  bifstream *pbifs, const Verbosity& verbosity)
1367 {
1368  ArtsXMLTag tag(verbosity);
1369  Index nelem;
1370 
1371  tag.read_from_stream (is_xml);
1372  tag.check_name ("Array");
1373  tag.check_attribute ("type", "SpeciesTag");
1374 
1375  tag.get_attribute_value ("nelem", nelem);
1376  astag.resize (nelem);
1377 
1378  Index n;
1379  try
1380  {
1381  for (n = 0; n < nelem; n++)
1382  {
1383  xml_read_from_stream (is_xml, astag[n], pbifs, verbosity);
1384  }
1385  } catch (runtime_error e) {
1386  ostringstream os;
1387  os << "Error reading ArrayOfSpeciesTag: "
1388  << "\n Element: " << n
1389  << "\n" << e.what();
1390  throw runtime_error(os.str());
1391  }
1392 
1393  tag.read_from_stream (is_xml);
1394  tag.check_name ("/Array");
1395 }
1396 
1397 
1399 
1405 void
1406 xml_write_to_stream (ostream& os_xml,
1407  const ArrayOfSpeciesTag& astag,
1408  bofstream *pbofs,
1409  const String& name, const Verbosity& verbosity)
1410 {
1411  ArtsXMLTag open_tag(verbosity);
1412  ArtsXMLTag close_tag(verbosity);
1413 
1414  open_tag.set_name ("Array");
1415  if (name.length ())
1416  open_tag.add_attribute ("name", name);
1417 
1418  open_tag.add_attribute ("type", "SpeciesTag");
1419  open_tag.add_attribute ("nelem", astag.nelem ());
1420 
1421  open_tag.write_to_stream (os_xml);
1422  os_xml << '\n';
1423 
1424  for (Index n = 0; n < astag.nelem (); n++)
1425  {
1426  xml_write_to_stream (os_xml, astag[n], pbofs, "", verbosity);
1427  }
1428 
1429  close_tag.set_name ("/Array");
1430  close_tag.write_to_stream (os_xml);
1431 
1432  os_xml << '\n';
1433 }
1434 
1435 
1436 //=== ArrayOfSingleScatteringData===========================================
1437 
1439 
1444 void
1445 xml_read_from_stream (istream& is_xml,
1446  ArrayOfSingleScatteringData& assdata,
1447  bifstream *pbifs, const Verbosity& verbosity)
1448 {
1449  ArtsXMLTag tag(verbosity);
1450  Index nelem;
1451 
1452  tag.read_from_stream (is_xml);
1453  tag.check_name ("Array");
1454  tag.check_attribute ("type", "SingleScatteringData");
1455 
1456  tag.get_attribute_value ("nelem", nelem);
1457  assdata.resize (nelem);
1458 
1459  Index n;
1460  try
1461  {
1462  for (n = 0; n < nelem; n++)
1463  {
1464  xml_read_from_stream (is_xml, assdata[n], pbifs, verbosity);
1465  }
1466  } catch (runtime_error e) {
1467  ostringstream os;
1468  os << "Error reading ArrayOfSingleScatteringData: "
1469  << "\n Element: " << n
1470  << "\n" << e.what();
1471  throw runtime_error(os.str());
1472  }
1473 
1474  tag.read_from_stream (is_xml);
1475  tag.check_name ("/Array");
1476 }
1477 
1479 
1485 void
1486 xml_write_to_stream (ostream& os_xml,
1487  const ArrayOfSingleScatteringData& assdata,
1488  bofstream *pbofs,
1489  const String& name, const Verbosity& verbosity)
1490 {
1491  ArtsXMLTag open_tag(verbosity);
1492  ArtsXMLTag close_tag(verbosity);
1493 
1494  open_tag.set_name ("Array");
1495  if (name.length ())
1496  open_tag.add_attribute ("name", name);
1497 
1498  open_tag.add_attribute ("type", "SingleScatteringData");
1499  open_tag.add_attribute ("nelem", assdata.nelem ());
1500 
1501  open_tag.write_to_stream (os_xml);
1502  os_xml << '\n';
1503 
1504  for (Index n = 0; n < assdata.nelem (); n++)
1505  {
1506  xml_write_to_stream (os_xml, assdata[n], pbofs, "", verbosity);
1507  }
1508 
1509  close_tag.set_name ("/Array");
1510  close_tag.write_to_stream (os_xml);
1511 
1512  os_xml << '\n';
1513 }
1514 
1515 
1516 //=== ArrayOfScatteringMetaData===========================================
1517 
1519 
1524 void
1525 xml_read_from_stream (istream& is_xml,
1526  ArrayOfScatteringMetaData& asmdata,
1527  bifstream *pbifs, const Verbosity& verbosity)
1528 {
1529  ArtsXMLTag tag(verbosity);
1530  Index nelem;
1531 
1532  tag.read_from_stream (is_xml);
1533  tag.check_name ("Array");
1534  tag.check_attribute ("type", "ScatteringMetaData");
1535 
1536  tag.get_attribute_value ("nelem", nelem);
1537  asmdata.resize (nelem);
1538 
1539  Index n;
1540  try
1541  {
1542  for (n = 0; n < nelem; n++)
1543  {
1544  xml_read_from_stream (is_xml, asmdata[n], pbifs, verbosity);
1545  }
1546  } catch (runtime_error e) {
1547  ostringstream os;
1548  os << "Error reading ArrayOfScatteringMetaData: "
1549  << "\n Element: " << n
1550  << "\n" << e.what();
1551  throw runtime_error(os.str());
1552  }
1553 
1554  tag.read_from_stream (is_xml);
1555  tag.check_name ("/Array");
1556 }
1557 
1559 
1565 void
1566 xml_write_to_stream (ostream& os_xml,
1567  const ArrayOfScatteringMetaData& asmdata,
1568  bofstream *pbofs,
1569  const String& name, const Verbosity& verbosity)
1570 {
1571  ArtsXMLTag open_tag(verbosity);
1572  ArtsXMLTag close_tag(verbosity);
1573 
1574  open_tag.set_name ("Array");
1575  if (name.length ())
1576  open_tag.add_attribute ("name", name);
1577 
1578  open_tag.add_attribute ("type", "ScatteringMetaData");
1579  open_tag.add_attribute ("nelem", asmdata.nelem ());
1580 
1581  open_tag.write_to_stream (os_xml);
1582  os_xml << '\n';
1583 
1584  for (Index n = 0; n < asmdata.nelem (); n++)
1585  {
1586  xml_write_to_stream (os_xml, asmdata[n], pbofs, "", verbosity);
1587  }
1588 
1589  close_tag.set_name ("/Array");
1590  close_tag.write_to_stream (os_xml);
1591 
1592  os_xml << '\n';
1593 }
1594 
1595 
1596 
1597 //=== ArrayOfGriddedField1 ===========================================
1598 
1600 
1605 void
1606 xml_read_from_stream (istream& is_xml,
1607  ArrayOfGriddedField1& agfield,
1608  bifstream *pbifs, const Verbosity& verbosity)
1609 {
1610  ArtsXMLTag tag(verbosity);
1611  Index nelem;
1612 
1613  tag.read_from_stream (is_xml);
1614  tag.check_name ("Array");
1615  tag.check_attribute ("type", "GriddedField1");
1616 
1617  tag.get_attribute_value ("nelem", nelem);
1618  agfield.resize (nelem);
1619 
1620  Index n;
1621  try
1622  {
1623  for (n = 0; n < nelem; n++)
1624  {
1625  xml_read_from_stream (is_xml, agfield[n], pbifs, verbosity);
1626  }
1627  } catch (runtime_error e) {
1628  ostringstream os;
1629  os << "Error reading ArrayOfGriddedField1: "
1630  << "\n Element: " << n
1631  << "\n" << e.what();
1632  throw runtime_error(os.str());
1633  }
1634 
1635  tag.read_from_stream (is_xml);
1636  tag.check_name ("/Array");
1637 }
1638 
1639 
1641 
1647 void
1648 xml_write_to_stream (ostream& os_xml,
1649  const ArrayOfGriddedField1& agfield,
1650  bofstream *pbofs,
1651  const String& name, const Verbosity& verbosity)
1652 {
1653  ArtsXMLTag open_tag(verbosity);
1654  ArtsXMLTag close_tag(verbosity);
1655 
1656  open_tag.set_name ("Array");
1657  if (name.length ())
1658  open_tag.add_attribute ("name", name);
1659 
1660  open_tag.add_attribute ("type", "GriddedField1");
1661  open_tag.add_attribute ("nelem", agfield.nelem ());
1662 
1663  open_tag.write_to_stream (os_xml);
1664  os_xml << '\n';
1665 
1666  for (Index n = 0; n < agfield.nelem (); n++)
1667  {
1668  xml_write_to_stream (os_xml, agfield[n], pbofs, "", verbosity);
1669  }
1670 
1671  close_tag.set_name ("/Array");
1672  close_tag.write_to_stream (os_xml);
1673 
1674  os_xml << '\n';
1675 }
1676 
1677 
1678 //=== ArrayOfGriddedField2 ===========================================
1679 
1681 
1686 void
1687 xml_read_from_stream (istream& is_xml,
1688  ArrayOfGriddedField2& agfield,
1689  bifstream *pbifs, const Verbosity& verbosity)
1690 {
1691  ArtsXMLTag tag(verbosity);
1692  Index nelem;
1693 
1694  tag.read_from_stream (is_xml);
1695  tag.check_name ("Array");
1696  tag.check_attribute ("type", "GriddedField2");
1697 
1698  tag.get_attribute_value ("nelem", nelem);
1699  agfield.resize (nelem);
1700 
1701  Index n;
1702  try
1703  {
1704  for (n = 0; n < nelem; n++)
1705  {
1706  xml_read_from_stream (is_xml, agfield[n], pbifs, verbosity);
1707  }
1708  } catch (runtime_error e) {
1709  ostringstream os;
1710  os << "Error reading ArrayOfGriddedField2: "
1711  << "\n Element: " << n
1712  << "\n" << e.what();
1713  throw runtime_error(os.str());
1714  }
1715 
1716  tag.read_from_stream (is_xml);
1717  tag.check_name ("/Array");
1718 }
1719 
1720 
1722 
1728 void
1729 xml_write_to_stream (ostream& os_xml,
1730  const ArrayOfGriddedField2& agfield,
1731  bofstream *pbofs,
1732  const String& name, const Verbosity& verbosity)
1733 {
1734  ArtsXMLTag open_tag(verbosity);
1735  ArtsXMLTag close_tag(verbosity);
1736 
1737  open_tag.set_name ("Array");
1738  if (name.length ())
1739  open_tag.add_attribute ("name", name);
1740 
1741  open_tag.add_attribute ("type", "GriddedField2");
1742  open_tag.add_attribute ("nelem", agfield.nelem ());
1743 
1744  open_tag.write_to_stream (os_xml);
1745  os_xml << '\n';
1746 
1747  for (Index n = 0; n < agfield.nelem (); n++)
1748  {
1749  xml_write_to_stream (os_xml, agfield[n], pbofs, "", verbosity);
1750  }
1751 
1752  close_tag.set_name ("/Array");
1753  close_tag.write_to_stream (os_xml);
1754 
1755  os_xml << '\n';
1756 }
1757 
1758 
1759 //=== ArrayOfGriddedField3 ===========================================
1760 
1762 
1767 void
1768 xml_read_from_stream (istream& is_xml,
1769  ArrayOfGriddedField3& agfield,
1770  bifstream *pbifs, const Verbosity& verbosity)
1771 {
1772  ArtsXMLTag tag(verbosity);
1773  Index nelem;
1774 
1775  tag.read_from_stream (is_xml);
1776  tag.check_name ("Array");
1777  tag.check_attribute ("type", "GriddedField3");
1778 
1779  tag.get_attribute_value ("nelem", nelem);
1780  agfield.resize (nelem);
1781 
1782  Index n;
1783  try
1784  {
1785  for (n = 0; n < nelem; n++)
1786  {
1787  xml_read_from_stream (is_xml, agfield[n], pbifs, verbosity);
1788  }
1789  } catch (runtime_error e) {
1790  ostringstream os;
1791  os << "Error reading ArrayOfGriddedField3: "
1792  << "\n Element: " << n
1793  << "\n" << e.what();
1794  throw runtime_error(os.str());
1795  }
1796 
1797  tag.read_from_stream (is_xml);
1798  tag.check_name ("/Array");
1799 }
1800 
1801 
1803 
1809 void
1810 xml_write_to_stream (ostream& os_xml,
1811  const ArrayOfGriddedField3& agfield,
1812  bofstream *pbofs,
1813  const String& name, const Verbosity& verbosity)
1814 {
1815  ArtsXMLTag open_tag(verbosity);
1816  ArtsXMLTag close_tag(verbosity);
1817 
1818  open_tag.set_name ("Array");
1819  if (name.length ())
1820  open_tag.add_attribute ("name", name);
1821 
1822  open_tag.add_attribute ("type", "GriddedField3");
1823  open_tag.add_attribute ("nelem", agfield.nelem ());
1824 
1825  open_tag.write_to_stream (os_xml);
1826  os_xml << '\n';
1827 
1828  for (Index n = 0; n < agfield.nelem (); n++)
1829  {
1830  xml_write_to_stream (os_xml, agfield[n], pbofs, "", verbosity);
1831  }
1832 
1833  close_tag.set_name ("/Array");
1834  close_tag.write_to_stream (os_xml);
1835 
1836  os_xml << '\n';
1837 }
1838 
1839 
1840 //=== ArrayOfArrayOfGriddedField1 ===========================================
1841 
1843 
1848 void
1849 xml_read_from_stream (istream& is_xml,
1850  ArrayOfArrayOfGriddedField1& aagfield,
1851  bifstream *pbifs, const Verbosity& verbosity)
1852 {
1853  ArtsXMLTag tag(verbosity);
1854  Index nelem;
1855 
1856  tag.read_from_stream (is_xml);
1857  tag.check_name ("Array");
1858  tag.check_attribute ("type", "ArrayOfGriddedField1");
1859 
1860  tag.get_attribute_value ("nelem", nelem);
1861  aagfield.resize (nelem);
1862 
1863  Index n;
1864  try
1865  {
1866  for (n = 0; n < nelem; n++)
1867  {
1868  xml_read_from_stream (is_xml, aagfield[n], pbifs, verbosity);
1869  }
1870  } catch (runtime_error e) {
1871  ostringstream os;
1872  os << "Error reading ArrayOfArrayOfGriddedField1: "
1873  << "\n Element: " << n
1874  << "\n" << e.what();
1875  throw runtime_error(os.str());
1876  }
1877 
1878  tag.read_from_stream (is_xml);
1879  tag.check_name ("/Array");
1880 }
1881 
1882 
1884 
1890 void
1891 xml_write_to_stream (ostream& os_xml,
1892  const ArrayOfArrayOfGriddedField1& aagfield,
1893  bofstream *pbofs,
1894  const String& name, const Verbosity& verbosity)
1895 {
1896  ArtsXMLTag open_tag(verbosity);
1897  ArtsXMLTag close_tag(verbosity);
1898 
1899  open_tag.set_name ("Array");
1900  if (name.length ())
1901  open_tag.add_attribute ("name", name);
1902 
1903  open_tag.add_attribute ("type", "ArrayGriddedField1");
1904  open_tag.add_attribute ("nelem", aagfield.nelem ());
1905 
1906  open_tag.write_to_stream (os_xml);
1907  os_xml << '\n';
1908 
1909  for (Index n = 0; n < aagfield.nelem (); n++)
1910  {
1911  xml_write_to_stream (os_xml, aagfield[n], pbofs, "", verbosity);
1912  }
1913 
1914  close_tag.set_name ("/Array");
1915  close_tag.write_to_stream (os_xml);
1916 
1917  os_xml << '\n';
1918 }
1919 
1920 
1921 //=== ArrayOfArrayOfGriddedField3 ===========================================
1922 
1924 
1929 void
1930 xml_read_from_stream (istream& is_xml,
1931  ArrayOfArrayOfGriddedField3& aagfield,
1932  bifstream *pbifs, const Verbosity& verbosity)
1933 {
1934  ArtsXMLTag tag(verbosity);
1935  Index nelem;
1936 
1937  tag.read_from_stream (is_xml);
1938  tag.check_name ("Array");
1939  tag.check_attribute ("type", "ArrayOfGriddedField3");
1940 
1941  tag.get_attribute_value ("nelem", nelem);
1942  aagfield.resize (nelem);
1943 
1944  Index n;
1945  try
1946  {
1947  for (n = 0; n < nelem; n++)
1948  {
1949  xml_read_from_stream (is_xml, aagfield[n], pbifs, verbosity);
1950  }
1951  } catch (runtime_error e) {
1952  ostringstream os;
1953  os << "Error reading ArrayOfArrayOfGriddedField3: "
1954  << "\n Element: " << n
1955  << "\n" << e.what();
1956  throw runtime_error(os.str());
1957  }
1958 
1959  tag.read_from_stream (is_xml);
1960  tag.check_name ("/Array");
1961 }
1962 
1963 
1965 
1971 void
1972 xml_write_to_stream (ostream& os_xml,
1973  const ArrayOfArrayOfGriddedField3& aagfield,
1974  bofstream *pbofs,
1975  const String& name, const Verbosity& verbosity)
1976 {
1977  ArtsXMLTag open_tag(verbosity);
1978  ArtsXMLTag close_tag(verbosity);
1979 
1980  open_tag.set_name ("Array");
1981  if (name.length ())
1982  open_tag.add_attribute ("name", name);
1983 
1984  open_tag.add_attribute ("type", "ArrayGriddedField3");
1985  open_tag.add_attribute ("nelem", aagfield.nelem ());
1986 
1987  open_tag.write_to_stream (os_xml);
1988  os_xml << '\n';
1989 
1990  for (Index n = 0; n < aagfield.nelem (); n++)
1991  {
1992  xml_write_to_stream (os_xml, aagfield[n], pbofs, "", verbosity);
1993  }
1994 
1995  close_tag.set_name ("/Array");
1996  close_tag.write_to_stream (os_xml);
1997 
1998  os_xml << '\n';
1999 }
2000 
2001 
2002 //=== ArrayOfGriddedField4 ===========================================
2003 
2005 
2010 void
2011 xml_read_from_stream (istream& is_xml,
2012  ArrayOfGriddedField4& agfield,
2013  bifstream *pbifs, const Verbosity& verbosity)
2014 {
2015  ArtsXMLTag tag(verbosity);
2016  Index nelem;
2017 
2018  tag.read_from_stream (is_xml);
2019  tag.check_name ("Array");
2020  tag.check_attribute ("type", "GriddedField4");
2021 
2022  tag.get_attribute_value ("nelem", nelem);
2023  agfield.resize (nelem);
2024 
2025  Index n;
2026  try
2027  {
2028  for (n = 0; n < nelem; n++)
2029  {
2030  xml_read_from_stream (is_xml, agfield[n], pbifs, verbosity);
2031  }
2032  } catch (runtime_error e) {
2033  ostringstream os;
2034  os << "Error reading ArrayOfGriddedField4: "
2035  << "\n Element: " << n
2036  << "\n" << e.what();
2037  throw runtime_error(os.str());
2038  }
2039 
2040  tag.read_from_stream (is_xml);
2041  tag.check_name ("/Array");
2042 }
2043 
2044 
2046 
2052 void
2053 xml_write_to_stream (ostream& os_xml,
2054  const ArrayOfGriddedField4& agfield,
2055  bofstream *pbofs,
2056  const String& name, const Verbosity& verbosity)
2057 {
2058  ArtsXMLTag open_tag(verbosity);
2059  ArtsXMLTag close_tag(verbosity);
2060 
2061  open_tag.set_name ("Array");
2062  if (name.length ())
2063  open_tag.add_attribute ("name", name);
2064 
2065  open_tag.add_attribute ("type", "GriddedField4");
2066  open_tag.add_attribute ("nelem", agfield.nelem ());
2067 
2068  open_tag.write_to_stream (os_xml);
2069  os_xml << '\n';
2070 
2071  for (Index n = 0; n < agfield.nelem (); n++)
2072  {
2073  xml_write_to_stream (os_xml, agfield[n], pbofs, "", verbosity);
2074  }
2075 
2076  close_tag.set_name ("/Array");
2077  close_tag.write_to_stream (os_xml);
2078 
2079  os_xml << '\n';
2080 }
2081 
2082 
2083 //=== ArrayOfLineRecord ===========================================
2084 
2086 
2091 void
2092 xml_read_from_stream (istream& is_xml,
2093  ArrayOfLineRecord& alrecord,
2094  bifstream * pbifs, const Verbosity& verbosity)
2095 {
2096  xml_read_from_stream (is_xml, alrecord, NAN, NAN, pbifs, verbosity);
2097 }
2098 
2099 
2102 
2109 void
2110 xml_read_from_stream (istream& is_xml,
2111  ArrayOfLineRecord& alrecord,
2112  const Numeric fmin,
2113  const Numeric fmax,
2114  bifstream * pbifs _U_, const Verbosity& verbosity)
2115 {
2116  ArtsXMLTag tag(verbosity);
2117  Index nelem;
2118 
2119  tag.read_from_stream (is_xml);
2120  tag.check_name ("ArrayOfLineRecord");
2121 
2122  tag.get_attribute_value ("nelem", nelem);
2123 
2124  LineRecord dummy_line_record;
2125  String version;
2126  tag.get_attribute_value ("version", version);
2127 
2128  Index artscat_version;
2129 
2130  if (version == "3")
2131  {
2132  artscat_version = 3;
2133  }
2134  else if (version.substr (0,8) != "ARTSCAT-")
2135  {
2136  ostringstream os;
2137  os << "The ARTS line file you are trying to read does not contain a valid version tag.\n"
2138  << "Probably it was created with an older version of ARTS that used different units.";
2139  throw runtime_error (os.str());
2140  }
2141  else {
2142  istringstream is(version.substr(8));
2143  is >> artscat_version;
2144  }
2145 
2146  if (artscat_version < 3 or artscat_version > 4)
2147  {
2148  ostringstream os;
2149  os << "Unknown ARTS line file version: " << version;
2150  throw runtime_error (os.str());
2151  }
2152 
2153  alrecord.resize (0);
2154 
2155  Index n;
2156  try
2157  {
2158  for (n = 0; n < nelem; n++)
2159  {
2160  LineRecord lr;
2161  switch (artscat_version)
2162  {
2163  case 3:
2164  if (lr.ReadFromArtscat3Stream (is_xml, verbosity))
2165  throw runtime_error ("Cannot read line from file");
2166  break;
2167  case 4:
2168  if (lr.ReadFromArtscat4Stream (is_xml, verbosity))
2169  throw runtime_error ("Cannot read line from file");
2170  break;
2171  default:
2172  throw runtime_error ("Programmer error. This should never be reached.\n"
2173  "Fix version number check above!");
2174  break;
2175  }
2176 
2177  if ( (isnan(fmin) || fmin <= lr.F()) && (isnan(fmax) || lr.F() <= fmax ))
2178  alrecord.push_back (lr);
2179  }
2180  } catch (runtime_error e) {
2181  ostringstream os;
2182  os << "Error reading ArrayOfLineRecord: "
2183  << "\n Element: " << n
2184  << "\n" << e.what();
2185  throw runtime_error(os.str());
2186  }
2187 
2188  tag.read_from_stream (is_xml);
2189  tag.check_name ("/ArrayOfLineRecord");
2190 }
2191 
2192 
2194 
2200 void
2201 xml_write_to_stream (ostream& os_xml,
2202  const ArrayOfLineRecord& alrecord,
2203  bofstream * pbofs _U_,
2204  const String& name, const Verbosity& verbosity)
2205 
2206 {
2207  ArtsXMLTag open_tag(verbosity);
2208  ArtsXMLTag close_tag(verbosity);
2209  LineRecord dummy_line_record;
2210 
2211  open_tag.set_name ("ArrayOfLineRecord");
2212  if (name.length ())
2213  open_tag.add_attribute ("name", name);
2214 
2215  open_tag.add_attribute ("version", dummy_line_record.Version ());
2216  open_tag.add_attribute ("nelem", alrecord.nelem ());
2217 
2218  open_tag.write_to_stream (os_xml);
2219  os_xml << '\n';
2220 
2221  for ( Index n = 0; n < alrecord.nelem(); n++ )
2222  {
2223  os_xml << alrecord[n] << "\n";
2224  }
2225 
2226  close_tag.set_name ("/ArrayOfLineRecord");
2227  close_tag.write_to_stream (os_xml);
2228 
2229  os_xml << '\n';
2230 }
2231 
2232 
2233 //=== ArrayOfArrayOfLineRecord ===========================================
2234 
2236 
2241 void
2242 xml_read_from_stream (istream& is_xml,
2243  ArrayOfArrayOfLineRecord& aalrecord,
2244  bifstream *pbifs, const Verbosity& verbosity)
2245 {
2246  ArtsXMLTag tag(verbosity);
2247  Index nelem;
2248 
2249  tag.read_from_stream (is_xml);
2250  tag.check_name ("Array");
2251  tag.check_attribute ("type", "ArrayOfLineRecord");
2252 
2253  tag.get_attribute_value ("nelem", nelem);
2254  aalrecord.resize (nelem);
2255 
2256  Index n;
2257  try
2258  {
2259  for (n = 0; n < nelem; n++)
2260  {
2261  xml_read_from_stream (is_xml, aalrecord[n], pbifs, verbosity);
2262  }
2263  } catch (runtime_error e) {
2264  ostringstream os;
2265  os << "Error reading ArrayOfArrayOfLineRecord: "
2266  << "\n Element: " << n
2267  << "\n" << e.what();
2268  throw runtime_error(os.str());
2269  }
2270 
2271 
2272  tag.read_from_stream (is_xml);
2273  tag.check_name ("/Array");
2274 }
2275 
2276 
2278 
2284 void
2285 xml_write_to_stream (ostream& os_xml,
2286  const ArrayOfArrayOfLineRecord& aalrecord,
2287  bofstream *pbofs,
2288  const String& name, const Verbosity& verbosity)
2289 
2290 {
2291  ArtsXMLTag open_tag(verbosity);
2292  ArtsXMLTag close_tag(verbosity);
2293 
2294  open_tag.set_name ("Array");
2295  if (name.length ())
2296  open_tag.add_attribute ("name", name);
2297 
2298  open_tag.add_attribute ("type", "ArrayOfLineRecord");
2299  open_tag.add_attribute ("nelem", aalrecord.nelem ());
2300 
2301  open_tag.write_to_stream (os_xml);
2302  os_xml << '\n';
2303 
2304  for (Index n = 0; n < aalrecord.nelem (); n++)
2305  {
2306  xml_write_to_stream (os_xml, aalrecord[n], pbofs, "", verbosity);
2307  }
2308 
2309  close_tag.set_name ("/Array");
2310  close_tag.write_to_stream (os_xml);
2311 
2312  os_xml << '\n';
2313 }
2314 
2315 
2316 //=== ArrayOfLineshapeSpec ===========================================
2317 
2319 
2324 void
2325 xml_read_from_stream (istream& is_xml _U_,
2326  ArrayOfLineshapeSpec& alspec _U_,
2327  bifstream * pbifs _U_, const Verbosity&)
2328 {
2329  // FIXME OLE: Implement this.
2330  throw runtime_error ("Boo. Not yet implemented.");
2331 }
2332 
2333 
2335 
2341 void
2342 xml_write_to_stream (ostream& os_xml _U_,
2343  const ArrayOfLineshapeSpec& alspec _U_,
2344  bofstream * pbofs _U_,
2345  const String& name _U_,
2346  const Verbosity&)
2347 
2348 {
2349  // FIXME OLE: Implement this.
2350  throw runtime_error ("Boo. Not yet implemented.");
2351 }
2352 
2353 
2354 //=== ArrayOfTensor3=========================================================
2355 
2357 
2362 void
2363 xml_read_from_stream (istream& is_xml,
2364  ArrayOfTensor3& atensor3,
2365  bifstream *pbifs, const Verbosity& verbosity)
2366 {
2367  ArtsXMLTag tag(verbosity);
2368  Index nelem;
2369 
2370  tag.read_from_stream (is_xml);
2371  tag.check_name ("Array");
2372  tag.check_attribute ("type", "Tensor3");
2373 
2374  tag.get_attribute_value ("nelem", nelem);
2375  atensor3.resize (nelem);
2376 
2377  Index n;
2378  try
2379  {
2380  for (n = 0; n < nelem; n++)
2381  {
2382  xml_read_from_stream (is_xml, atensor3[n], pbifs, verbosity);
2383  }
2384  } catch (runtime_error e) {
2385  ostringstream os;
2386  os << "Error reading ArrayOfTensor3: "
2387  << "\n Element: " << n
2388  << "\n" << e.what();
2389  throw runtime_error(os.str());
2390  }
2391 
2392 
2393  tag.read_from_stream (is_xml);
2394  tag.check_name ("/Array");
2395 }
2396 
2397 
2399 
2405 void
2406 xml_write_to_stream (ostream& os_xml,
2407  const ArrayOfTensor3& atensor3,
2408  bofstream *pbofs,
2409  const String& name, const Verbosity& verbosity)
2410 {
2411  ArtsXMLTag open_tag(verbosity);
2412  ArtsXMLTag close_tag(verbosity);
2413 
2414  open_tag.set_name ("Array");
2415  if (name.length ())
2416  open_tag.add_attribute ("name", name);
2417 
2418  open_tag.add_attribute ("type", "Tensor3");
2419  open_tag.add_attribute ("nelem", atensor3.nelem ());
2420 
2421  open_tag.write_to_stream (os_xml);
2422  os_xml << '\n';
2423 
2424  for (Index n = 0; n < atensor3.nelem (); n++)
2425  {
2426  xml_write_to_stream (os_xml, atensor3[n], pbofs, "", verbosity);
2427  }
2428 
2429  close_tag.set_name ("/Array");
2430  close_tag.write_to_stream (os_xml);
2431 
2432  os_xml << '\n';
2433 }
2434 
2435 
2436 
2437 //=== ArrayOfTensor4=========================================================
2438 
2440 
2445 void
2446 xml_read_from_stream (istream& is_xml,
2447  ArrayOfTensor4& atensor4,
2448  bifstream *pbifs, const Verbosity& verbosity)
2449 {
2450  ArtsXMLTag tag(verbosity);
2451  Index nelem;
2452 
2453  tag.read_from_stream (is_xml);
2454  tag.check_name ("Array");
2455  tag.check_attribute ("type", "Tensor4");
2456 
2457  tag.get_attribute_value ("nelem", nelem);
2458  atensor4.resize (nelem);
2459 
2460  Index n;
2461  try
2462  {
2463  for (n = 0; n < nelem; n++)
2464  {
2465  xml_read_from_stream (is_xml, atensor4[n], pbifs, verbosity);
2466  }
2467  } catch (runtime_error e) {
2468  ostringstream os;
2469  os << "Error reading ArrayOfTensor4: "
2470  << "\n Element: " << n
2471  << "\n" << e.what();
2472  throw runtime_error(os.str());
2473  }
2474 
2475 
2476  tag.read_from_stream (is_xml);
2477  tag.check_name ("/Array");
2478 }
2479 
2480 
2482 
2488 void
2489 xml_write_to_stream (ostream& os_xml,
2490  const ArrayOfTensor4& atensor4,
2491  bofstream *pbofs,
2492  const String& name, const Verbosity& verbosity)
2493 {
2494  ArtsXMLTag open_tag(verbosity);
2495  ArtsXMLTag close_tag(verbosity);
2496 
2497  open_tag.set_name ("Array");
2498  if (name.length ())
2499  open_tag.add_attribute ("name", name);
2500 
2501  open_tag.add_attribute ("type", "Tensor4");
2502  open_tag.add_attribute ("nelem", atensor4.nelem ());
2503 
2504  open_tag.write_to_stream (os_xml);
2505  os_xml << '\n';
2506 
2507  for (Index n = 0; n < atensor4.nelem (); n++)
2508  {
2509  xml_write_to_stream (os_xml, atensor4[n], pbofs, "", verbosity);
2510  }
2511 
2512  close_tag.set_name ("/Array");
2513  close_tag.write_to_stream (os_xml);
2514 
2515  os_xml << '\n';
2516 }
2517 
2518 
2519 
2520 //=== ArrayOfTensor6=========================================================
2521 
2523 
2528 void
2529 xml_read_from_stream (istream& is_xml,
2530  ArrayOfTensor6& atensor6,
2531  bifstream *pbifs, const Verbosity& verbosity)
2532 {
2533  ArtsXMLTag tag(verbosity);
2534  Index nelem;
2535 
2536  tag.read_from_stream (is_xml);
2537  tag.check_name ("Array");
2538  tag.check_attribute ("type", "Tensor6");
2539 
2540  tag.get_attribute_value ("nelem", nelem);
2541  atensor6.resize (nelem);
2542 
2543  Index n;
2544  try
2545  {
2546  for (n = 0; n < nelem; n++)
2547  {
2548  xml_read_from_stream (is_xml, atensor6[n], pbifs, verbosity);
2549  }
2550  } catch (runtime_error e) {
2551  ostringstream os;
2552  os << "Error reading ArrayOfTensor6: "
2553  << "\n Element: " << n
2554  << "\n" << e.what();
2555  throw runtime_error(os.str());
2556  }
2557 
2558  tag.read_from_stream (is_xml);
2559  tag.check_name ("/Array");
2560 }
2561 
2562 
2564 
2570 void
2571 xml_write_to_stream (ostream& os_xml,
2572  const ArrayOfTensor6& atensor6,
2573  bofstream *pbofs,
2574  const String& name, const Verbosity& verbosity)
2575 {
2576  ArtsXMLTag open_tag(verbosity);
2577  ArtsXMLTag close_tag(verbosity);
2578 
2579  open_tag.set_name ("Array");
2580  if (name.length ())
2581  open_tag.add_attribute ("name", name);
2582 
2583  open_tag.add_attribute ("type", "Tensor6");
2584  open_tag.add_attribute ("nelem", atensor6.nelem ());
2585 
2586  open_tag.write_to_stream (os_xml);
2587  os_xml << '\n';
2588 
2589  for (Index n = 0; n < atensor6.nelem (); n++)
2590  {
2591  xml_write_to_stream (os_xml, atensor6[n], pbofs, "", verbosity);
2592  }
2593 
2594  close_tag.set_name ("/Array");
2595  close_tag.write_to_stream (os_xml);
2596 
2597  os_xml << '\n';
2598 }
2599 
2600 
2601 //=== ArrayOfTensor7=========================================================
2602 
2604 
2609 void
2610 xml_read_from_stream (istream& is_xml,
2611  ArrayOfTensor7& atensor7,
2612  bifstream *pbifs, const Verbosity& verbosity)
2613 {
2614  ArtsXMLTag tag(verbosity);
2615  Index nelem;
2616 
2617  tag.read_from_stream (is_xml);
2618  tag.check_name ("Array");
2619  tag.check_attribute ("type", "Tensor7");
2620 
2621  tag.get_attribute_value ("nelem", nelem);
2622  atensor7.resize (nelem);
2623 
2624  Index n;
2625  try
2626  {
2627  for (n = 0; n < nelem; n++)
2628  {
2629  xml_read_from_stream (is_xml, atensor7[n], pbifs, verbosity);
2630  }
2631  } catch (runtime_error e) {
2632  ostringstream os;
2633  os << "Error reading ArrayOfTensor7: "
2634  << "\n Element: " << n
2635  << "\n" << e.what();
2636  throw runtime_error(os.str());
2637  }
2638 
2639  tag.read_from_stream (is_xml);
2640  tag.check_name ("/Array");
2641 }
2642 
2643 
2645 
2651 void
2652 xml_write_to_stream (ostream& os_xml,
2653  const ArrayOfTensor7& atensor7,
2654  bofstream *pbofs,
2655  const String& name, const Verbosity& verbosity)
2656 {
2657  ArtsXMLTag open_tag(verbosity);
2658  ArtsXMLTag close_tag(verbosity);
2659 
2660  open_tag.set_name ("Array");
2661  if (name.length ())
2662  open_tag.add_attribute ("name", name);
2663 
2664  open_tag.add_attribute ("type", "Tensor7");
2665  open_tag.add_attribute ("nelem", atensor7.nelem ());
2666 
2667  open_tag.write_to_stream (os_xml);
2668  os_xml << '\n';
2669 
2670  for (Index n = 0; n < atensor7.nelem (); n++)
2671  {
2672  xml_write_to_stream (os_xml, atensor7[n], pbofs, "", verbosity);
2673  }
2674 
2675  close_tag.set_name ("/Array");
2676  close_tag.write_to_stream (os_xml);
2677 
2678  os_xml << '\n';
2679 }
2680 
2681 
2682 //=== ArrayOfString ==========================================================
2683 
2685 
2691 void
2692 xml_parse_from_stream (istream& is_xml,
2693  ArrayOfString& astring,
2694  bifstream *pbifs,
2695  ArtsXMLTag& tag,
2696  const Verbosity& verbosity)
2697 {
2698  Index nelem;
2699 
2700  tag.check_attribute ("type", "String");
2701 
2702  tag.get_attribute_value ("nelem", nelem);
2703  astring.resize (nelem);
2704 
2705  Index n;
2706  try
2707  {
2708  for (n = 0; n < nelem; n++)
2709  {
2710  xml_read_from_stream (is_xml, astring[n], pbifs, verbosity);
2711  }
2712  } catch (runtime_error e) {
2713  ostringstream os;
2714  os << "Error reading ArrayOfString: "
2715  << "\n Element: " << n
2716  << "\n" << e.what();
2717  throw runtime_error(os.str());
2718  }
2719 }
2720 
2721 
2723 
2728 void
2729 xml_read_from_stream (istream& is_xml,
2730  ArrayOfString& astring,
2731  bifstream *pbifs, const Verbosity& verbosity)
2732 {
2733  ArtsXMLTag tag(verbosity);
2734 
2735  tag.read_from_stream (is_xml);
2736  tag.check_name ("Array");
2737 
2738  xml_parse_from_stream (is_xml, astring, pbifs, tag, verbosity);
2739 
2740  tag.read_from_stream (is_xml);
2741  tag.check_name ("/Array");
2742 }
2743 
2744 
2746 
2752 void
2753 xml_write_to_stream (ostream& os_xml,
2754  const ArrayOfString& astring,
2755  bofstream *pbofs,
2756  const String& name, const Verbosity& verbosity)
2757 {
2758  ArtsXMLTag open_tag(verbosity);
2759  ArtsXMLTag close_tag(verbosity);
2760 
2761  open_tag.set_name ("Array");
2762  if (name.length ())
2763  open_tag.add_attribute ("name", name);
2764 
2765  open_tag.add_attribute ("type", "String");
2766  open_tag.add_attribute ("nelem", astring.nelem ());
2767 
2768  open_tag.write_to_stream (os_xml);
2769  os_xml << '\n';
2770 
2771  for (Index n = 0; n < astring.nelem (); n++)
2772  {
2773  xml_write_to_stream (os_xml, astring[n], pbofs, "", verbosity);
2774  }
2775 
2776  close_tag.set_name ("/Array");
2777  close_tag.write_to_stream (os_xml);
2778 
2779  os_xml << '\n';
2780 }
2781 
2782 //=== ArrayOfVector ==========================================================
2783 
2785 
2790 void
2791 xml_read_from_stream (istream& is_xml,
2792  ArrayOfVector& avector,
2793  bifstream *pbifs, const Verbosity& verbosity)
2794 {
2795  ArtsXMLTag tag(verbosity);
2796  Index nelem;
2797 
2798  tag.read_from_stream (is_xml);
2799  tag.check_name ("Array");
2800  tag.check_attribute ("type", "Vector");
2801 
2802  tag.get_attribute_value ("nelem", nelem);
2803  avector.resize (nelem);
2804 
2805  Index n;
2806  try
2807  {
2808  for (n = 0; n < nelem; n++)
2809  {
2810  xml_read_from_stream (is_xml, avector[n], pbifs, verbosity);
2811  }
2812  } catch (runtime_error e) {
2813  ostringstream os;
2814  os << "Error reading ArrayOfVector: "
2815  << "\n Element: " << n
2816  << "\n" << e.what();
2817  throw runtime_error(os.str());
2818  }
2819 
2820 
2821  tag.read_from_stream (is_xml);
2822  tag.check_name ("/Array");
2823 }
2824 
2825 
2827 
2833 void
2834 xml_write_to_stream (ostream& os_xml,
2835  const ArrayOfVector& avector,
2836  bofstream *pbofs,
2837  const String& name, const Verbosity& verbosity)
2838 {
2839  ArtsXMLTag open_tag(verbosity);
2840  ArtsXMLTag close_tag(verbosity);
2841 
2842  open_tag.set_name ("Array");
2843  if (name.length ())
2844  open_tag.add_attribute ("name", name);
2845 
2846  open_tag.add_attribute ("type", "Vector");
2847  open_tag.add_attribute ("nelem", avector.nelem ());
2848 
2849  open_tag.write_to_stream (os_xml);
2850  os_xml << '\n';
2851 
2852  for (Index n = 0; n < avector.nelem (); n++)
2853  {
2854  xml_write_to_stream (os_xml, avector[n], pbofs, "", verbosity);
2855  }
2856 
2857  close_tag.set_name ("/Array");
2858  close_tag.write_to_stream (os_xml);
2859 
2860  os_xml << '\n';
2861 }
2862 
LineRecord::ReadFromArtscat3Stream
bool ReadFromArtscat3Stream(istream &is, const Verbosity &verbosity)
Read one line from a stream associated with an ARTSCAT-3 file.
Definition: absorption.cc:1825
ArtsXMLTag::check_name
void check_name(const String &expected_name)
Check tag name.
Definition: xml_io.cc:56
xml_write_to_stream
void xml_write_to_stream(ostream &os_xml, const Array< SpeciesRecord > &asrecord, bofstream *pbofs, const String &name, const Verbosity &verbosity)
Writes SpeciesData to XML output stream.
Definition: xml_io_array_types.cc:93
xml_parse_from_stream
void xml_parse_from_stream(istream &is_xml, ArrayOfString &astring, bifstream *pbifs, ArtsXMLTag &tag, const Verbosity &verbosity)
Parse ArrayOfString from XML input stream.
Definition: xml_io_array_types.cc:2692
ArtsXMLTag::get_attribute_value
void get_attribute_value(const String &aname, String &value)
Returns value of attribute as String.
Definition: xml_io.cc:140
ArtsXMLTag::check_attribute
void check_attribute(const String &aname, const String &value)
Checks whether attribute has the expected value.
Definition: xml_io.cc:110
ArtsXMLTag::write_to_stream
void write_to_stream(ostream &os)
Write XML tag.
Definition: xml_io.cc:333
Array
This can be used to make arrays out of anything.
Definition: array.h:103
xml_io_private.h
This file contains private function declarations and template instantiation to handle XML data files.
_U_
#define _U_
Definition: config.h:158
ArtsXMLTag::read_from_stream
void read_from_stream(istream &is)
Reads next XML tag.
Definition: xml_io.cc:194
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:62
xml_io_types.h
This file contains private function declarations and template instantiation to handle XML data files.
jacobian.h
Declarations required for the calculation of jacobians.
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:50
ArtsXMLTag::add_attribute
void add_attribute(const String &aname, const String &value)
Adds a String attribute to tag.
Definition: xml_io.cc:74
bifstream
Binary output file stream class.
Definition: bifstream.h:45
LineRecord
Spectral line catalog data.
Definition: absorption.h:481
LineRecord::ReadFromArtscat4Stream
bool ReadFromArtscat4Stream(istream &is, const Verbosity &verbosity)
Read one line from a stream associated with an ARTSCAT-4 file.
Definition: absorption.cc:2020
LineRecord::Version
Index Version() const
Return the version number.
Definition: absorption.h:581
xml_read_from_stream
void xml_read_from_stream(istream &is_xml, Array< SpeciesRecord > &asrecord, bifstream *pbifs, const Verbosity &verbosity)
Reads SpeciesData from XML input stream.
Definition: xml_io_array_types.cc:50
ArtsXMLTag
The ARTS XML tag class.
Definition: xml_io_private.h:83
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
LineRecord::F
Numeric F() const
The line center frequency in Hz.
Definition: absorption.h:599
ArtsXMLTag::set_name
void set_name(const String &new_name)
Definition: xml_io_private.h:94
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:172
arts.h
The global header file for ARTS.
bofstream
Binary output file stream class.
Definition: bofstream.h:45