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/rtcBinaryOutputHandler.h"
00022
00023
00024 namespace rtc {
00025
00026
00027
00029 BinaryOutputHandler::BinaryOutputHandler()
00030 : OutputHandler()
00031 {
00032 }
00033
00035 BinaryOutputHandler::BinaryOutputHandler(std::ostream& os)
00036 : OutputHandler(os)
00037 {
00038 }
00039
00041 BinaryOutputHandler::~BinaryOutputHandler()
00042 {
00043 }
00044
00046 bool BinaryOutputHandler::binary() const
00047 {
00048 return true;
00049 }
00050
00052 bool BinaryOutputHandler::writeName(const std::string& name)
00053 {
00054 return true;
00055 }
00057 bool BinaryOutputHandler::writeSeparator()
00058 {
00059 return true;
00060 }
00061
00063 bool BinaryOutputHandler::writeEOL()
00064 {
00065 return true;
00066 }
00067
00068 bool BinaryOutputHandler::write(const std::string& data) {
00069 if(!outStream) return false;
00070 size_t size = data.size();
00071
00072 outStream->write(reinterpret_cast<const char*>(&size),sizeof(size));
00073
00074 if(size>0) {
00075 *outStream << data;
00076
00077
00078 }
00079 return outStream->good();
00080 };
00081
00082 bool BinaryOutputHandler::write(const double& data) {
00083 if(!outStream) return false;
00084 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00085 return outStream->good();
00086 }
00087
00088 bool BinaryOutputHandler::write(const float& data) {
00089 if(!outStream) return false;
00090 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00091 return outStream->good();
00092 }
00093
00094 bool BinaryOutputHandler::write(const int& data) {
00095 if(!outStream) return false;
00096 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00097 return outStream->good();
00098 }
00099
00100 bool BinaryOutputHandler::write(const unsigned int& data) {
00101 if(!outStream) return false;
00102 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00103 return outStream->good();
00104 }
00105
00106 bool BinaryOutputHandler::write(const char& data) {
00107 if(!outStream) return false;
00108 outStream->put(data);
00109 return outStream->good();
00110 }
00111
00112 bool BinaryOutputHandler::write(const unsigned char& data) {
00113 if(!outStream) return false;
00114 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00115 return outStream->good();
00116 }
00117
00118 bool BinaryOutputHandler::write(const bool& data) {
00119 if(!outStream) return false;
00120 if (data) {
00121 return BinaryOutputHandler::write(char(1));
00122 } else {
00123 return BinaryOutputHandler::write(char(0));
00124 }
00125 }
00126
00127 bool BinaryOutputHandler::write(const long& data) {
00128 if(!outStream) return false;
00129 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00130 return outStream->good();
00131 }
00132
00133 bool BinaryOutputHandler::write(const unsigned long& data) {
00134 if(!outStream) return false;
00135 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00136 return outStream->good();
00137 }
00138
00139 bool BinaryOutputHandler::write(const short& data) {
00140 if(!outStream) return false;
00141 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00142 return outStream->good();
00143 }
00144
00145 bool BinaryOutputHandler::write(const unsigned short& data) {
00146 if(!outStream) return false;
00147 outStream->write(reinterpret_cast<const char*>(&data),sizeof(data));
00148 return outStream->good();
00149 }
00150
00151 bool BinaryOutputHandler::write(const char* data, long n) {
00152 if(!outStream) return false;
00153 outStream->write(data,n);
00154 return outStream->good();
00155 }
00156
00157
00158 }
00159