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 #include "rtc/rtcBinaryInputHandler.h"
00022 #include <vector>
00023
00024
00025 namespace rtc {
00026
00027
00028
00030 BinaryInputHandler::BinaryInputHandler()
00031 : InputHandler()
00032 {
00033 }
00034
00036 BinaryInputHandler::BinaryInputHandler(std::istream& is)
00037 : InputHandler(is)
00038 {
00039 }
00040
00042 BinaryInputHandler::~BinaryInputHandler()
00043 {
00044 }
00045
00047 bool BinaryInputHandler::binary() const
00048 {
00049 return true;
00050 }
00051
00053 bool BinaryInputHandler::readName(const std::string& name)
00054 {
00055 return true;
00056 }
00057
00059 bool BinaryInputHandler::readSeparator()
00060 {
00061 return true;
00062 }
00063
00064 bool BinaryInputHandler::read(std::string& data) {
00065 if(!inStream) return false;
00066 size_t size;
00067 inStream->read(reinterpret_cast<char*>(&size),sizeof(size));
00068 if(size>0) {
00069 std::vector<char> tmp(size);
00070 inStream->read(&tmp[0], size);
00071 data.assign(&tmp[0], size);
00072 }
00073 return inStream->good();
00074 }
00075
00076 bool BinaryInputHandler::read(double& data) {
00077 if(!inStream) return false;
00078 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00079 return inStream->good();
00080 }
00081
00082 bool BinaryInputHandler::read(float& data) {
00083 if(!inStream) return false;
00084 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00085 return inStream->good();
00086 }
00087
00088 bool BinaryInputHandler::read(int& data) {
00089 if(!inStream) return false;
00090 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00091 return inStream->good();
00092 }
00093
00094 bool BinaryInputHandler::read(unsigned int& data) {
00095 if(!inStream) return false;
00096 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00097 return inStream->good();
00098 }
00099
00100 bool BinaryInputHandler::read(char& data) {
00101 if(!inStream) return false;
00102 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00103 return inStream->good();
00104 }
00105
00106 bool BinaryInputHandler::read(unsigned char& data) {
00107 if(!inStream) return false;
00108 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00109 return inStream->good();
00110 }
00111
00112 bool BinaryInputHandler::read(bool& data) {
00113 if(!inStream) return false;
00114 char tmp;
00115 BinaryInputHandler::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 BinaryInputHandler::read(long& data) {
00125 if(!inStream) return false;
00126 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00127 return inStream->good();
00128 }
00129
00130 bool BinaryInputHandler::read(unsigned long& data) {
00131 if(!inStream) return false;
00132 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00133 return inStream->good();
00134 }
00135
00136 bool BinaryInputHandler::read(short& data) {
00137 if(!inStream) return false;
00138 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00139 return inStream->good();
00140 }
00141
00142 bool BinaryInputHandler::read(unsigned short& data) {
00143 if(!inStream) return false;
00144 inStream->read(reinterpret_cast<char*>(&data),sizeof(data));
00145 return inStream->good();
00146 }
00147
00148 bool BinaryInputHandler::read(char* data, long n) {
00149 if(!inStream) return false;
00150 inStream->read(data,n);
00151 return inStream->good();
00152 }
00153
00154
00155 }
00156