doxygen @ tags replaced to \
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*! @file pibytearray.h
|
||||
* @brief Byte array
|
||||
/*! \file pibytearray.h
|
||||
* \brief Byte array
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -39,16 +39,16 @@ class PIString;
|
||||
class PIByteArray;
|
||||
|
||||
|
||||
/*! @class PIByteArray
|
||||
* @brief The PIByteArray class provides an array of bytes
|
||||
* @details PIByteArray used to store raw bytes.
|
||||
/*! \class PIByteArray
|
||||
* \brief The PIByteArray class provides an array of bytes
|
||||
* \details PIByteArray used to store raw bytes.
|
||||
* It can be constructed from any data and size.
|
||||
* You can use PIByteArray as binary stream
|
||||
* to serialize/deserialize any objects and data.
|
||||
* This class based on PIDeque<uchar> and provide some handle function
|
||||
* to manipulate it.
|
||||
*
|
||||
* @section PIByteArray_sec0 Usage
|
||||
* \section PIByteArray_sec0 Usage
|
||||
* %PIByteArray can be used to store custom data and manipulate it. There are many
|
||||
* stream operators to store/restore common types to byte array. Store operators
|
||||
* places data at the end of array, restore operators takes data from the beginning
|
||||
@@ -57,22 +57,22 @@ class PIByteArray;
|
||||
*
|
||||
* One of the major usage of %PIByteArray is stream functions. You can form binary
|
||||
* packet from many types (also dynamic types, e.g. PIVector) with one line:
|
||||
* @snippet pibytearray.cpp 0
|
||||
* \snippet pibytearray.cpp 0
|
||||
*
|
||||
* Or you can descibe stream operator of your own type and store/restore vectors of
|
||||
* your type:
|
||||
* @snippet pibytearray.cpp 1
|
||||
* \snippet pibytearray.cpp 1
|
||||
*
|
||||
* For store/restore custom data blocks there is PIByteArray::RawData class. Stream
|
||||
* operators of this class simply store/restore data block to/from byte array.
|
||||
* @snippet pibytearray.cpp 2
|
||||
* \snippet pibytearray.cpp 2
|
||||
*
|
||||
* @section PIByteArray_sec1 Attention
|
||||
* \section PIByteArray_sec1 Attention
|
||||
* Stream operator of %PIByteArray store byte array as vector, not simply append
|
||||
* content of byte array. This operators useful to transmit custom data as %PIByteArray
|
||||
* packed into parent byte array, e.g. to form packet from %PIByteArray.
|
||||
* To append one byte array to another use funtion \a append().
|
||||
* @snippet pibytearray.cpp 3
|
||||
* \snippet pibytearray.cpp 3
|
||||
*
|
||||
*
|
||||
*/
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
|
||||
};
|
||||
|
||||
//! \relatesalso PIByteArray @brief Byte arrays compare operator
|
||||
//! \relatesalso PIByteArray \brief Byte arrays compare operator
|
||||
inline bool operator <(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
if (v0.size() == v1.size()) {
|
||||
if (v0.isEmpty()) return false;
|
||||
@@ -205,7 +205,7 @@ inline bool operator <(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
return v0.size() < v1.size();
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Byte arrays compare operator
|
||||
//! \relatesalso PIByteArray \brief Byte arrays compare operator
|
||||
inline bool operator >(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
if (v0.size() == v1.size()) {
|
||||
if (v0.isEmpty()) return false;
|
||||
@@ -214,7 +214,7 @@ inline bool operator >(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
return v0.size() > v1.size();
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Byte arrays compare operator
|
||||
//! \relatesalso PIByteArray \brief Byte arrays compare operator
|
||||
inline bool operator ==(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
if (v0.size() == v1.size()) {
|
||||
if (v0.isEmpty()) return true;
|
||||
@@ -223,7 +223,7 @@ inline bool operator ==(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Byte arrays compare operator
|
||||
//! \relatesalso PIByteArray \brief Byte arrays compare operator
|
||||
inline bool operator !=(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
if (v0.size() == v1.size()) {
|
||||
if (v0.isEmpty()) return false;
|
||||
@@ -233,11 +233,11 @@ inline bool operator !=(const PIByteArray & v0, const PIByteArray & v1) {
|
||||
}
|
||||
|
||||
#ifdef PIP_STD_IOSTREAM
|
||||
//! \relatesalso PIByteArray @brief Output to std::ostream operator
|
||||
//! \relatesalso PIByteArray \brief Output to std::ostream operator
|
||||
inline std::ostream & operator <<(std::ostream & s, const PIByteArray & ba);
|
||||
#endif
|
||||
|
||||
//! \relatesalso PIByteArray @brief Output to PICout operator
|
||||
//! \relatesalso PIByteArray \brief Output to PICout operator
|
||||
PIP_EXPORT PICout operator <<(PICout s, const PIByteArray & ba);
|
||||
|
||||
|
||||
@@ -246,16 +246,16 @@ PIP_EXPORT PICout operator <<(PICout s, const PIByteArray & ba);
|
||||
// store operators for basic types
|
||||
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator
|
||||
//! \relatesalso PIByteArray \brief Store operator
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const bool v) {s.push_back(v); return s;}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator
|
||||
//! \relatesalso PIByteArray \brief Store operator
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const char v) {s.push_back(v); return s;}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator
|
||||
//! \relatesalso PIByteArray \brief Store operator
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const uchar v) {s.push_back(v); return s;}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator for any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Store operator for any trivial copyable type
|
||||
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray::StreamRef operator <<(PIByteArray & s, const T & v) {
|
||||
int os = s.size_s();
|
||||
@@ -264,10 +264,10 @@ inline PIByteArray::StreamRef operator <<(PIByteArray & s, const T & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator, see \ref PIByteArray_sec1 for details
|
||||
//! \relatesalso PIByteArray \brief Store operator, see \ref PIByteArray_sec1 for details
|
||||
PIP_EXPORT PIByteArray & operator <<(PIByteArray & s, const PIByteArray & v);
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator, see \ref PIByteArray_sec1 for details
|
||||
//! \relatesalso PIByteArray \brief Store operator, see \ref PIByteArray_sec1 for details
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIByteArray::RawData & v) {
|
||||
int os = s.size_s();
|
||||
if (v.s > 0) {
|
||||
@@ -277,7 +277,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIByteArray::RawData & v
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator for PIVector of any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Store operator for PIVector of any trivial copyable type
|
||||
template<typename T,
|
||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||
typename std::enable_if< std::is_same<decltype(std::declval<PIByteArray&>() << std::declval<const T &>()), PIByteArray::StreamRef>::value, int>::type = 0>
|
||||
@@ -299,7 +299,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator for PIDeque of any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Store operator for PIDeque of any trivial copyable type
|
||||
template<typename T,
|
||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||
typename std::enable_if< std::is_same<decltype(std::declval<PIByteArray&>() << std::declval<const T &>()), PIByteArray::StreamRef>::value, int>::type = 0>
|
||||
@@ -321,7 +321,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator for PIVector2D of any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Store operator for PIVector2D of any trivial copyable type
|
||||
template<typename T,
|
||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||
typename std::enable_if< std::is_same<decltype(std::declval<PIByteArray&>() << std::declval<const T &>()), PIByteArray::StreamRef>::value, int>::type = 0>
|
||||
@@ -342,10 +342,10 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator
|
||||
//! \relatesalso PIByteArray \brief Store operator
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIBitArray & v) {s << v.size_ << v.data_; return s;}
|
||||
|
||||
//! \relatesalso PIPair @brief Store operator
|
||||
//! \relatesalso PIPair \brief Store operator
|
||||
template<typename Type0, typename Type1>
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIPair<Type0, Type1> & v) {s << v.first << v.second; return s;}
|
||||
|
||||
@@ -355,16 +355,16 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIPair<Type0, Type1> & v
|
||||
// restore operators for basic types
|
||||
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator
|
||||
//! \relatesalso PIByteArray \brief Restore operator
|
||||
inline PIByteArray & operator >>(PIByteArray & s, bool & v) {assert(s.size() >= 1u); v = s.take_front(); return s;}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator
|
||||
//! \relatesalso PIByteArray \brief Restore operator
|
||||
inline PIByteArray & operator >>(PIByteArray & s, char & v) {assert(s.size() >= 1u); v = s.take_front(); return s;}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator
|
||||
//! \relatesalso PIByteArray \brief Restore operator
|
||||
inline PIByteArray & operator >>(PIByteArray & s, uchar & v) {assert(s.size() >= 1u); v = s.take_front(); return s;}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator for any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Restore operator for any trivial copyable type
|
||||
template<typename T, typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray::StreamRef operator >>(PIByteArray & s, T & v) {
|
||||
if (s.size() < sizeof(v)) {
|
||||
@@ -376,10 +376,10 @@ inline PIByteArray::StreamRef operator >>(PIByteArray & s, T & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator, see \ref PIByteArray_sec1 for details
|
||||
//! \relatesalso PIByteArray \brief Restore operator, see \ref PIByteArray_sec1 for details
|
||||
PIP_EXPORT PIByteArray & operator >>(PIByteArray & s, PIByteArray & v);
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator, see \ref PIByteArray_sec1 for details
|
||||
//! \relatesalso PIByteArray \brief Restore operator, see \ref PIByteArray_sec1 for details
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIByteArray::RawData v) {
|
||||
if (s.size_s() < v.s) {
|
||||
printf("error with RawData %d < %d\n", (int)s.size_s(), v.s);
|
||||
@@ -392,7 +392,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIByteArray::RawData v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator for PIVector of any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Restore operator for PIVector of any trivial copyable type
|
||||
template<typename T,
|
||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||
typename std::enable_if< std::is_same<decltype(std::declval<PIByteArray&>() << std::declval<const T &>()), PIByteArray::StreamRef>::value, int>::type = 0>
|
||||
@@ -423,7 +423,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator for PIDeque of any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Restore operator for PIDeque of any trivial copyable type
|
||||
template<typename T,
|
||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||
typename std::enable_if< std::is_same<decltype(std::declval<PIByteArray&>() << std::declval<const T &>()), PIByteArray::StreamRef>::value, int>::type = 0>
|
||||
@@ -454,7 +454,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator for PIVector2D of any trivial copyable type
|
||||
//! \relatesalso PIByteArray \brief Restore operator for PIVector2D of any trivial copyable type
|
||||
template<typename T,
|
||||
typename std::enable_if< std::is_trivially_copyable<T>::value, int>::type = 0,
|
||||
typename std::enable_if< std::is_same<decltype(std::declval<PIByteArray&>() << std::declval<const T &>()), PIByteArray::StreamRef>::value, int>::type = 0>
|
||||
@@ -487,10 +487,10 @@ inline PIByteArray & operator >>(PIByteArray & s, PIVector2D<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator
|
||||
//! \relatesalso PIByteArray \brief Restore operator
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIBitArray & v) {assert(s.size_s() >= 8); s >> v.size_ >> v.data_; return s;}
|
||||
|
||||
//! \relatesalso PIPair @brief Restore operator
|
||||
//! \relatesalso PIPair \brief Restore operator
|
||||
template<typename Type0, typename Type1>
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIPair<Type0, Type1> & v) {s >> v.first >> v.second; return s;}
|
||||
|
||||
@@ -500,7 +500,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIPair<Type0, Type1> & v) {s >
|
||||
// store operators for complex types
|
||||
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator for PIVector of any compound type
|
||||
//! \relatesalso PIByteArray \brief Store operator for PIVector of any compound type
|
||||
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {
|
||||
s << int(v.size_s());
|
||||
@@ -508,7 +508,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator for PIDeque of any compound type
|
||||
//! \relatesalso PIByteArray \brief Store operator for PIDeque of any compound type
|
||||
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {
|
||||
s << int(v.size_s());
|
||||
@@ -516,7 +516,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Store operator for PIVector2D of any compound type
|
||||
//! \relatesalso PIByteArray \brief Store operator for PIVector2D of any compound type
|
||||
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {
|
||||
s << int(v.rows()) << int(v.cols()) << v.toPlainVector();
|
||||
@@ -529,7 +529,7 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVector2D<T> & v) {
|
||||
// restore operators for complex types
|
||||
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator for PIVector of any compound type
|
||||
//! \relatesalso PIByteArray \brief Restore operator for PIVector of any compound type
|
||||
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {
|
||||
if (s.size_s() < 4) {
|
||||
@@ -542,7 +542,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator for PIDeque of any compound type
|
||||
//! \relatesalso PIByteArray \brief Restore operator for PIDeque of any compound type
|
||||
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {
|
||||
if (s.size_s() < 4) {
|
||||
@@ -555,7 +555,7 @@ inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
//! \relatesalso PIByteArray @brief Restore operator for PIVector2D of any compound type
|
||||
//! \relatesalso PIByteArray \brief Restore operator for PIVector2D of any compound type
|
||||
template<typename T, typename std::enable_if<!std::is_trivially_copyable<T>::value, int>::type = 0>
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVector2D<T> & v) {
|
||||
if (s.size_s() < 8) {
|
||||
|
||||
Reference in New Issue
Block a user