rtcASCIIInputHandler.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 .......: rtcBinaryASCIIInputHandler.cpp
00012  * authors ....: Benjamin Pitzer
00013  * organization: Robert Bosch LLC
00014  * creation ...: 01/20/2009
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 "rtc/rtcASCIIInputHandler.h"
00022 
00023 //== NAMESPACES ================================================================
00024 namespace rtc {
00025 
00026 //== IMPLEMENTATION ============================================================
00027 
00029 ASCIIInputHandler::ASCIIInputHandler()
00030 : InputHandler()
00031 {
00032 }
00033 
00035 ASCIIInputHandler::ASCIIInputHandler(std::istream& is)
00036 : InputHandler(is)
00037 {
00038 }
00039 
00041 ASCIIInputHandler::~ASCIIInputHandler()
00042 {
00043 }
00044 
00046 bool ASCIIInputHandler::binary() const
00047 {
00048   return false;
00049 }
00050 
00052 bool ASCIIInputHandler::readName(const std::string& name)
00053 {
00054   if(!inStream) return false;
00055   std::string buf;
00056   // read the name
00057   *inStream >> buf;
00058   if (buf != name)
00059    return false;
00060   else
00061     return inStream->good();
00062 }
00063 
00065 bool ASCIIInputHandler::readSeparator()
00066 {
00067   return true;
00068 }
00069 
00070 bool ASCIIInputHandler::read(std::string& data) {
00071   if(!inStream) return false;
00072   *inStream >> data;
00073   return inStream->good();
00074 }
00075 
00076 bool ASCIIInputHandler::read(double& data) {
00077   if(!inStream) return false;
00078   *inStream >> data;
00079   return inStream->good();
00080 }
00081 
00082 bool ASCIIInputHandler::read(float& data)  {
00083   if(!inStream) return false;
00084   *inStream >> data;
00085   return inStream->good();
00086 }
00087 
00088 bool ASCIIInputHandler::read(int& data)  {
00089   if(!inStream) return false;
00090   *inStream >> data;
00091   return inStream->good();
00092 }
00093 
00094 bool ASCIIInputHandler::read(unsigned int& data)  {
00095   if(!inStream) return false;
00096   *inStream >> data;
00097   return inStream->good();
00098 }
00099 
00100 bool ASCIIInputHandler::read(char& data)  {
00101   if(!inStream) return false;
00102   *inStream >> data;
00103   return inStream->good();
00104 }
00105 
00106 bool ASCIIInputHandler::read(unsigned char& data)  {
00107   if(!inStream) return false;
00108   *inStream >> data;
00109   return inStream->good();
00110 }
00111 
00112 bool ASCIIInputHandler::read(bool& data) {
00113   if(!inStream) return false;
00114   char tmp;
00115   ASCIIInputHandler::read(tmp);
00116   if (tmp == 0 || tmp == 1) {
00117     data=(tmp == 1);
00118     return inStream->good();
00119   } else {
00120     return false;
00121   }
00122 }
00123 
00124 bool ASCIIInputHandler::read(long& data)  {
00125   if(!inStream) return false;
00126   *inStream >> data;
00127   return inStream->good();
00128 }
00129 
00130 bool ASCIIInputHandler::read(unsigned long& data)  {
00131   if(!inStream) return false;
00132   *inStream >> data;
00133   return inStream->good();
00134 }
00135 
00136 bool ASCIIInputHandler::read(short& data)  {
00137   if(!inStream) return false;
00138   *inStream >> data;
00139   return inStream->good();
00140 }
00141 
00142 bool ASCIIInputHandler::read(unsigned short& data)  {
00143   if(!inStream) return false;
00144   *inStream >> data;
00145   return inStream->good();
00146 }
00147 
00148 bool ASCIIInputHandler::read(char* data, long n) {
00149   if(!inStream) return false;
00150   inStream->read(data,n);
00151   return inStream->good();
00152 }
00153 
00154 //==============================================================================
00155 } // namespace rtc
00156 //==============================================================================


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