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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef _CVR_IO_HANDLER_H_
00053 #define _CVR_IO_HANDLER_H_
00054
00055
00056 #include "cvrObject.h"
00057 #include "cvrTypes.h"
00058 #include "cvrStatus.h"
00059 #include <string>
00060 #include <iosfwd>
00061
00062 namespace cvr {
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 class ioHandler : public object, public status {
00083 public:
00084
00085
00086
00087
00088 ioHandler();
00089
00090
00091
00092
00093 ioHandler(const ioHandler& other);
00094
00095
00096
00097
00098 virtual ~ioHandler();
00099
00100
00101
00102
00103
00104
00105 ioHandler& copy(const ioHandler& other);
00106
00107
00108
00109
00110 virtual const std::string& name() const = 0;
00111
00112
00113
00114
00115 virtual ioHandler* clone() const = 0;
00116
00117
00118
00119
00120 virtual ioHandler* newInstance() const = 0;
00121
00122
00123
00124
00125
00126
00127
00128 virtual void use(std::ostream& aStream) = 0;
00129
00130
00131
00132
00133
00134
00135
00136 virtual void use(std::istream& aStream) = 0;
00137
00138
00139
00140
00141 virtual bool writeBegin();
00142
00143
00144
00145
00146 virtual bool writeEnd();
00147
00148
00149
00150
00151 virtual bool readBegin();
00152
00153
00154
00155
00156 virtual bool readEnd();
00157
00158
00159
00160
00161
00162
00163
00164
00165 virtual bool write(const std::string& data) = 0;
00166 virtual bool write(const char* data) = 0;
00167 virtual bool write(const double& data) = 0;
00168 virtual bool write(const float& data) = 0;
00169 virtual bool write(const int data) = 0;
00170 virtual bool write(const unsigned int& data) = 0;
00171 virtual bool write(const char& data) = 0;
00172 virtual bool write(const byte& data) = 0;
00173 virtual bool write(const ubyte& data) = 0;
00174 virtual bool write(const bool data) = 0;
00175 virtual bool write(const long& data) = 0;
00176 virtual bool write(const unsigned long& data) = 0;
00177 virtual bool write(const short& data) = 0;
00178 virtual bool write(const unsigned short& data) = 0;
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 virtual bool write(const std::string& name,const std::string& data);
00190 virtual bool write(const std::string& name,const char* data);
00191 virtual bool write(const std::string& name,const double& data);
00192 virtual bool write(const std::string& name,const float& data);
00193 virtual bool write(const std::string& name,const int data);
00194 virtual bool write(const std::string& name,const unsigned int& data);
00195 virtual bool write(const std::string& name,const char& data);
00196 virtual bool write(const std::string& name,const byte& data);
00197 virtual bool write(const std::string& name,const ubyte& data);
00198 virtual bool write(const std::string& name,const bool data);
00199 virtual bool write(const std::string& name,const long& data);
00200 virtual bool write(const std::string& name,const unsigned long& data);
00201 virtual bool write(const std::string& name,const short& data);
00202 virtual bool write(const std::string& name,const unsigned short& data);
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 virtual bool read(std::string& data) = 0;
00213 virtual bool read(double& data) = 0;
00214 virtual bool read(float& data) = 0;
00215 virtual bool read(int& data) = 0;
00216 virtual bool read(unsigned int& data) = 0;
00217 virtual bool read(char& data) = 0;
00218 virtual bool read(byte& data) = 0;
00219 virtual bool read(ubyte& data) = 0;
00220 virtual bool read(bool& data) = 0;
00221 virtual bool read(long& data) = 0;
00222 virtual bool read(unsigned long& data) = 0;
00223 virtual bool read(short& data) = 0;
00224 virtual bool read(unsigned short& data) = 0;
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 virtual bool read(const std::string& name, std::string& data);
00235 virtual bool read(const std::string& name, double& data);
00236 virtual bool read(const std::string& name, float& data);
00237 virtual bool read(const std::string& name, int& data);
00238 virtual bool read(const std::string& name, unsigned int& data);
00239 virtual bool read(const std::string& name, char& data);
00240 virtual bool read(const std::string& name, byte& data);
00241 virtual bool read(const std::string& name, ubyte& data);
00242 virtual bool read(const std::string& name, bool& data);
00243 virtual bool read(const std::string& name, long& data);
00244 virtual bool read(const std::string& name, unsigned long& data);
00245 virtual bool read(const std::string& name, short& data);
00246 virtual bool read(const std::string& name, unsigned short& data);
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 virtual bool writeSymbol(const std::string& data) = 0;
00258
00259
00260
00261
00262
00263 virtual bool writeComment(const std::string& data) = 0;
00264
00265
00266
00267
00268
00269 virtual bool writeComment(const char* data) = 0;
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 virtual bool readSymbol(std::string& data) = 0;
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 virtual bool trySymbol(const std::string& data) = 0;
00293
00294
00295
00296
00297
00298
00299
00300 virtual bool tryBegin() = 0;
00301
00302
00303
00304
00305
00306
00307
00308 virtual bool tryEnd() = 0;
00309
00310
00311
00312
00313
00314
00315 virtual bool writeSpaces(const int s=1) = 0;
00316
00317
00318
00319
00320
00321 virtual bool writeEOL() = 0;
00322
00323
00324
00325
00326
00327
00328 virtual bool writeKeyValueSeparator() = 0;
00329
00330
00331
00332
00333
00334 virtual bool writeDataSeparator() = 0;
00335
00336
00337
00338
00339 virtual bool readKeyValueSeparator() = 0;
00340
00341
00342
00343
00344 virtual bool readDataSeparator() = 0;
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 virtual const int& getLevel() const;
00366
00367
00368
00369
00370
00371 virtual bool restoreLevel() = 0;
00372
00373
00374
00375
00376
00377 virtual void resetLevel(const int theLevel = 0);
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391 virtual void appendContextStatus() const;
00392
00393
00394 protected:
00395
00396
00397
00398 int level_;
00399
00400 };
00401
00402
00403
00404
00405
00406 bool read(ioHandler& handler,std::string& data);
00407 bool read(ioHandler& handler,double& data);
00408 bool read(ioHandler& handler,float& data);
00409 bool read(ioHandler& handler,int& data);
00410 bool read(ioHandler& handler,unsigned int& data);
00411 bool read(ioHandler& handler,char& data);
00412 bool read(ioHandler& handler,byte& data);
00413 bool read(ioHandler& handler,ubyte& data);
00414 bool read(ioHandler& handler,bool& data);
00415 bool read(ioHandler& handler,long& data);
00416 bool read(ioHandler& handler,unsigned long& data);
00417 bool read(ioHandler& handler,short& data);
00418 bool read(ioHandler& handler,unsigned short& data);
00419
00420
00421
00422
00423
00424
00425 bool write(ioHandler& handler,const std::string& data);
00426 bool write(ioHandler& handler,const char* data);
00427 bool write(ioHandler& handler,const double& data);
00428 bool write(ioHandler& handler,const float& data);
00429 bool write(ioHandler& handler, const int data);
00430 bool write(ioHandler& handler,const unsigned int& data);
00431 bool write(ioHandler& handler,const char& data);
00432 bool write(ioHandler& handler,const byte& data);
00433 bool write(ioHandler& handler,const ubyte& data);
00434 bool write(ioHandler& handler,const bool data);
00435 bool write(ioHandler& handler,const long& data);
00436 bool write(ioHandler& handler,const unsigned long& data);
00437 bool write(ioHandler& handler,const short& data);
00438 bool write(ioHandler& handler,const unsigned short& data);
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450 bool read(ioHandler& handler, const std::string& name,
00451 std::string& data, const bool complete=true);
00452 bool read(ioHandler& handler, const std::string& name,
00453 double& data, const bool complete=true);
00454 bool read(ioHandler& handler, const std::string& name,
00455 float& data, const bool complete=true);
00456 bool read(ioHandler& handler, const std::string& name,
00457 int& data, const bool complete=true);
00458 bool read(ioHandler& handler, const std::string& name,
00459 unsigned int& data, const bool complete=true);
00460 bool read(ioHandler& handler, const std::string& name,
00461 char& data, const bool complete=true);
00462 bool read(ioHandler& handler, const std::string& name,
00463 byte& data, const bool complete=true);
00464 bool read(ioHandler& handler, const std::string& name,
00465 ubyte& data, const bool complete=true);
00466 bool read(ioHandler& handler, const std::string& name,
00467 bool& data, const bool complete=true);
00468 bool read(ioHandler& handler, const std::string& name,
00469 long& data, const bool complete=true);
00470 bool read(ioHandler& handler, const std::string& name,
00471 unsigned long& data, const bool complete=true);
00472 bool read(ioHandler& handler, const std::string& name,
00473 short& data, const bool complete=true);
00474 bool read(ioHandler& handler, const std::string& name,
00475 unsigned short& data, const bool complete=true);
00476
00477 template <class T>
00478 bool read(ioHandler& handler,const std::string& name,
00479 T& data,const bool complete=true);
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489 bool write(ioHandler& handler, const std::string& name,
00490 const std::string& data, const bool complete=true);
00491 bool write(ioHandler& handler, const std::string& name,
00492 const char* data, const bool complete=true);
00493 bool write(ioHandler& handler, const std::string& name,
00494 const double& data, const bool complete=true);
00495 bool write(ioHandler& handler, const std::string& name,
00496 const float& data, const bool complete=true);
00497 bool write(ioHandler& handler, const std::string& name,
00498 const int data, const bool complete=true);
00499 bool write(ioHandler& handler, const std::string& name,
00500 const unsigned int& data, const bool complete=true);
00501 bool write(ioHandler& handler, const std::string& name,
00502 const char& data, const bool complete=true);
00503 bool write(ioHandler& handler, const std::string& name,
00504 const byte& data, const bool complete=true);
00505 bool write(ioHandler& handler, const std::string& name,
00506 const ubyte& data, const bool complete=true);
00507 bool write(ioHandler& handler, const std::string& name,
00508 const bool data, const bool complete=true);
00509 bool write(ioHandler& handler, const std::string& name,
00510 const long& data, const bool complete=true);
00511 bool write(ioHandler& handler, const std::string& name,
00512 const unsigned long& data, const bool complete=true);
00513 bool write(ioHandler& handler, const std::string& name,
00514 const short& data, const bool complete=true);
00515 bool write(ioHandler& handler, const std::string& name,
00516 const unsigned short& data, const bool complete=true);
00517
00518 template <class T>
00519 bool write(ioHandler& handler,const std::string& name,
00520 const T& data,const bool complete=true);
00521
00522
00523 }
00524
00525 #include "cvrIoHandler_template.h"
00526
00527 #endif
00528