Go to the documentation of this file.00001
00002 #ifndef mbl_parse_tuple_h_
00003 #define mbl_parse_tuple_h_
00004
00005
00006
00007
00008
00009
00010 #include <vcl_istream.h>
00011 #include <vcl_sstream.h>
00012 #include <mbl/mbl_exception.h>
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 template <class T, class U>
00030 inline void mbl_parse_tuple(vcl_istream &afs, T& a, U& b)
00031 {
00032 if (!afs) return;
00033 char brace1, brace2;
00034 afs >> vcl_ws >> brace1;
00035 if (afs.eof())
00036 throw mbl_exception_parse_error("mbl_parse_tuple failed unexpected eof");
00037 if ( brace1 == '{')
00038 {
00039 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> brace2;
00040 if (!afs)
00041 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00042 if (brace2 != '}')
00043 {
00044 afs.putback(brace2);
00045 afs.clear(vcl_ios::failbit);
00046
00047 throw mbl_exception_parse_error("mbl_parse_tuple failed to find closing brace");
00048 }
00049 }
00050 else
00051 {
00052 afs.putback(brace1);
00053 afs >> vcl_ws >> a >> vcl_ws >> b;
00054 if (!afs)
00055 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00056 }
00057 }
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 template <class T, class U, class V>
00075 inline void mbl_parse_tuple(vcl_istream &afs, T& a, U& b, V& c)
00076 {
00077 if (!afs) return;
00078 char brace1, brace2;
00079 afs >> vcl_ws >> brace1;
00080 if (afs.eof())
00081 throw mbl_exception_parse_error("mbl_parse_tuple failed unexpected eof");
00082 if ( brace1 == '{')
00083 {
00084 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c >> vcl_ws >> brace2;
00085 if (!afs)
00086 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00087 if (brace2 != '}')
00088 {
00089 afs.putback(brace2);
00090 afs.clear(vcl_ios::failbit);
00091
00092 throw mbl_exception_parse_error("mbl_parse_tuple failed to find closing brace");
00093 }
00094 }
00095 else
00096 {
00097 afs.putback(brace1);
00098 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c;
00099 if (!afs)
00100 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00101 }
00102 }
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 template <class T, class U, class V, class W>
00122 inline void mbl_parse_tuple(vcl_istream &afs, T& a, U& b, V& c, W& d)
00123 {
00124 if (!afs) return;
00125 char brace1, brace2;
00126 afs >> vcl_ws >> brace1;
00127 if (afs.eof())
00128 throw mbl_exception_parse_error("mbl_parse_tuple failed unexpected eof");
00129 if ( brace1 == '{')
00130 {
00131 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c >> vcl_ws >> d >> vcl_ws >> brace2;
00132 if (!afs)
00133 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00134 if (brace2 != '}')
00135 {
00136 afs.putback(brace2);
00137 afs.clear(vcl_ios::failbit);
00138
00139 throw mbl_exception_parse_error("mbl_parse_tuple failed to find closing brace");
00140 }
00141 }
00142 else
00143 {
00144 afs.putback(brace1);
00145 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c >> vcl_ws >> d;
00146 if (!afs)
00147 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00148 }
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 template <class T, class U, class V, class W, class X>
00169 inline void mbl_parse_tuple(vcl_istream &afs, T& a, U& b, V& c, W& d, X& e)
00170 {
00171 if (!afs) return;
00172 char brace1, brace2;
00173 afs >> vcl_ws >> brace1;
00174 if (afs.eof())
00175 throw mbl_exception_parse_error("mbl_parse_tuple failed unexpected eof");
00176 if ( brace1 == '{')
00177 {
00178 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c >> vcl_ws >> d >> vcl_ws >> e >> vcl_ws >> brace2;
00179 if (!afs)
00180 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00181 if (brace2 != '}')
00182 {
00183 afs.putback(brace2);
00184 afs.clear(vcl_ios::failbit);
00185
00186 throw mbl_exception_parse_error("mbl_parse_tuple failed to find closing brace");
00187 }
00188 }
00189 else
00190 {
00191 afs.putback(brace1);
00192 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c >> vcl_ws >> d >> vcl_ws >> e;
00193 if (!afs)
00194 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00195 }
00196 }
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 template <class T, class U, class V, class W, class X, class Y>
00217 inline void mbl_parse_tuple(vcl_istream &afs, T& a, U& b, V& c, W& d, X& e, Y& f)
00218 {
00219 if (!afs) return;
00220 char brace1, brace2;
00221 afs >> vcl_ws >> brace1;
00222 if (afs.eof())
00223 throw mbl_exception_parse_error("mbl_parse_tuple failed unexpected eof");
00224 if ( brace1 == '{')
00225 {
00226 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c >> vcl_ws >> d >> vcl_ws >>
00227 e >> vcl_ws >> f >> vcl_ws >> brace2;
00228 if (!afs)
00229 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00230 if (brace2 != '}')
00231 {
00232 afs.putback(brace2);
00233 afs.clear(vcl_ios::failbit);
00234
00235 throw mbl_exception_parse_error("mbl_parse_tuple failed to find closing brace");
00236 }
00237 }
00238 else
00239 {
00240 afs.putback(brace1);
00241 afs >> vcl_ws >> a >> vcl_ws >> b >> vcl_ws >> c >> vcl_ws >> d >>
00242 vcl_ws >> e >> vcl_ws >> f;
00243 if (!afs)
00244 throw mbl_exception_parse_error("mbl_parse_tuple failed with stream error");
00245 }
00246 }
00247 #endif // mbl_parse_tuple_h_