Ignore:
Timestamp:
Nov 2, 2009, 1:31:19 AM (15 years ago)
Author:
mies
Message:

Changed Data to Message conversion constructor in Message to explicit
Fixed some general bugs in Data: operator<<
Fixed bug in DHTMessage: allow unspecified key/values
Added local DHT message delivery
Adapted sources to work with gcc 4.4.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/utility/serialization/Data.hpp

    r5870 r6786  
    4949template<typename T = uint8_t, typename DataModel = DefaultDataModel<uint8_t> > class DataTpl;
    5050typedef DataTpl<> Data;
    51 template<typename T, typename DataModel> std::ostream& operator<<(std::ostream& stream, DataTpl<T, DataModel>& data);
     51template<typename T, typename DataModel> std::ostream& operator<<(std::ostream& stream, const DataTpl<T, DataModel>& data);
    5252
    5353//== internal includes ==
     
    324324};
    325325
    326 /* default human readable text output */
    327 template<typename T, typename DataModel>
    328 std::ostream& operator<<(std::ostream& stream, DataTpl<T, DataModel>& data) {
    329         stream << "[" << bitstr(data.getBuffer(), data.getLength(), 4)
    330                         << "|'";
    331         char* buffer = (char*) data.getBuffer();
    332         for (size_t i = 0; i < data.getLength() / 8; i++) {
    333                 char c = buffer[i] < 32 ? '.' : buffer[i];
    334                 stream << c;
    335         }
    336         stream << "']";
    337         return stream;
    338 }
    339 
    340326/* unspecified type */
    341327template<typename T, typename DataModel>
     
    397383
    398384        finline int32_t length() const {
    399                 return bufferLen;
     385                return (bufferLen == -1) ? 0 : bufferLen;
    400386        }
    401387
     
    442428}sznEnd();
    443429
     430/* default human readable text output */
     431template<typename T, typename DataModel>
     432std::ostream& operator<<(std::ostream& stream, const DataTpl<T, DataModel>& data) {
     433        stream << "[" << bitstr(data.getBuffer(), data.getLength(), 4)
     434                        << "|'";
     435        const char* buffer = (const char*) data.getBuffer();
     436        for (size_t i = 0; i < data.getLength() / 8; i++) {
     437                char c = buffer[i] < 32 ? '.' : buffer[i];
     438                stream << c;
     439        }
     440        stream << "']";
     441        return stream;
     442}
    444443#endif /* DATA_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.