UListIO.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 "UList.H"
00028 #include "Ostream.H"
00029 #include "token.H"
00030 #include "contiguous.H"
00031
00032
00033
00034 template<class T>
00035 void Foam::UList<T>::writeEntry(Ostream& os) const
00036 {
00037 if
00038 (
00039 size()
00040 && token::compound::isCompound
00041 (
00042 "List<" + word(pTraits<T>::typeName) + '>'
00043 )
00044 )
00045 {
00046 os << word("List<" + word(pTraits<T>::typeName) + '>') << " ";
00047 }
00048
00049 os << *this;
00050 }
00051
00052
00053 template<class T>
00054 void Foam::UList<T>::writeEntry(const word& keyword, Ostream& os) const
00055 {
00056 os.writeKeyword(keyword);
00057 writeEntry(os);
00058 os << token::END_STATEMENT << endl;
00059 }
00060
00061
00062 template<class T>
00063 Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList<T>& L)
00064 {
00065
00066 if (os.format() == IOstream::ASCII || !contiguous<T>())
00067 {
00068 bool uniform = false;
00069
00070 if (L.size() > 1 && contiguous<T>())
00071 {
00072 uniform = true;
00073
00074 forAll(L, i)
00075 {
00076 if (L[i] != L[0])
00077 {
00078 uniform = false;
00079 break;
00080 }
00081 }
00082 }
00083
00084 if (uniform)
00085 {
00086
00087 os << L.size() << token::BEGIN_BLOCK;
00088
00089
00090 os << L[0];
00091
00092
00093 os << token::END_BLOCK;
00094 }
00095 else if (L.size() < 11 && contiguous<T>())
00096 {
00097
00098 os << L.size() << token::BEGIN_LIST;
00099
00100
00101 forAll(L, i)
00102 {
00103 if (i > 0) os << token::SPACE;
00104 os << L[i];
00105 }
00106
00107
00108 os << token::END_LIST;
00109 }
00110 else
00111 {
00112
00113 os << nl << L.size() << nl << token::BEGIN_LIST;
00114
00115
00116 forAll(L, i)
00117 {
00118 os << nl << L[i];
00119 }
00120
00121
00122 os << nl << token::END_LIST << nl;
00123 }
00124 }
00125 else
00126 {
00127 os << nl << L.size() << nl;
00128 if (L.size())
00129 {
00130 os.write(reinterpret_cast<const char*>(L.v_), L.byteSize());
00131 }
00132 }
00133
00134
00135 os.check("Ostream& operator<<(Ostream&, const UList&)");
00136
00137 return os;
00138 }
00139
00140
00141
Copyright © 2000-2009 OpenCFD Ltd