rtcIOObject.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009
00003  * Robert Bosch LLC
00004  * Research and Technology Center North America
00005  * Palo Alto, California
00006  *
00007  * All rights reserved.
00008  *
00009  *------------------------------------------------------------------------------
00010  * project ....: Autonomous Technologies
00011  * file .......: rtcIOObject.cpp
00012  * authors ....: Benjamin Pitzer
00013  * organization: Robert Bosch LLC
00014  * creation ...: 10/16/2006
00015  * modified ...: $Date: 2009-01-21 18:19:16 -0800 (Wed, 21 Jan 2009) $
00016  * changed by .: $Author: benjaminpitzer $
00017  * revision ...: $Revision: 14 $
00018  */
00019 
00020 //== INCLUDES ==================================================================
00021 #include <stdio.h>
00022 #include <fstream>
00023 #include <iostream>
00024 #include <string>
00025 #include "rtc/rtcIOObject.h"
00026 
00027 //== NAMESPACES ================================================================
00028 namespace rtc {
00029 
00030 //== IMPLEMENTATION ============================================================
00031 
00032 // default constructor
00033 IOObject::IOObject()
00034 {
00035 }
00036 
00037 // destructor
00038 IOObject::~IOObject()
00039 {
00040 }
00041 
00042 bool IOObject::readFromFile(InputHandler& ih, const char* filename)
00043 {
00044   bool res;
00045   std::fstream fin;
00046   if(ih.binary()) fin.open(filename,std::ios::in|std::ios::binary);
00047   else fin.open(filename,std::ios::in);
00048   if (fin.is_open()) {
00049     ih.use(fin);
00050     res = read(ih);
00051   } else {
00052     return false;
00053   }
00054   fin.close();
00055   return res;
00056 }
00057 
00058 bool IOObject::writeToFile(OutputHandler& oh, const char* filename)
00059 {
00060   bool res;
00061   std::fstream fout;
00062   if(oh.binary()) fout.open(filename,std::ios::out|std::ios::binary);
00063   else fout.open(filename,std::ios::out);
00064   if (fout.is_open()) {
00065     oh.use(fout);
00066     res = write(oh);
00067   } else {
00068     return false;
00069   }
00070   fout.close();
00071   return res;
00072 }
00073 
00074 //==============================================================================
00075 } // namespace rtc
00076 //==============================================================================


rtc
Author(s): Benjamin Pitzer
autogenerated on Mon Oct 6 2014 10:07:34