UIndirectListIO.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "UIndirectList.H"
00028 #include "Ostream.H"
00029 #include "token.H"
00030 #include "contiguous.H"
00031
00032
00033
00034 template<class T>
00035 Foam::Ostream& Foam::operator<<
00036 (
00037 Foam::Ostream& os,
00038 const Foam::UIndirectList<T>& L
00039 )
00040 {
00041
00042 if (os.format() == IOstream::ASCII || !contiguous<T>())
00043 {
00044 bool uniform = false;
00045
00046 if (L.size() > 1 && contiguous<T>())
00047 {
00048 uniform = true;
00049
00050 forAll(L, i)
00051 {
00052 if (L[i] != L[0])
00053 {
00054 uniform = false;
00055 break;
00056 }
00057 }
00058 }
00059
00060 if (uniform)
00061 {
00062
00063 os << L.size() << token::BEGIN_BLOCK;
00064
00065
00066 os << L[0];
00067
00068
00069 os << token::END_BLOCK;
00070 }
00071 else if (L.size() < 11 && contiguous<T>())
00072 {
00073
00074 os << L.size() << token::BEGIN_LIST;
00075
00076
00077 forAll(L, i)
00078 {
00079 if (i) os << token::SPACE;
00080 os << L[i];
00081 }
00082
00083
00084 os << token::END_LIST;
00085 }
00086 else
00087 {
00088
00089 os << nl << L.size() << nl << token::BEGIN_LIST;
00090
00091
00092 forAll(L, i)
00093 {
00094 os << nl << L[i];
00095 }
00096
00097
00098 os << nl << token::END_LIST << nl;
00099 }
00100 }
00101 else
00102 {
00103
00104
00105 os << nl << L.size() << nl;
00106
00107 if (L.size())
00108 {
00109 List<T> lst = L();
00110
00111 os.write
00112 (
00113 reinterpret_cast<const char*>(lst.cdata()),
00114 lst.byteSize()
00115 );
00116 }
00117 }
00118
00119
00120 os.check("Ostream& operator<<(Ostream&, const UIndirectList&)");
00121
00122 return os;
00123 }
00124
00125
00126
Copyright © 2000-2009 OpenCFD Ltd