operator<< for VarInt

This commit is contained in:
2025-03-04 11:44:40 +01:00
parent d501c0181d
commit fa6ba74068
2 changed files with 12 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <ostream>
namespace sp { namespace sp {
@@ -55,6 +56,11 @@ class VarInt {
* \param var The variable integer to deserialize * \param var The variable integer to deserialize
*/ */
friend DataBuffer& operator>>(DataBuffer& in, VarInt& var); friend DataBuffer& operator>>(DataBuffer& in, VarInt& var);
/**
* \brief overriding stream operator
*/
friend std::ostream& operator<<(std::ostream& a_Stream, const sp::VarInt& a_VarInt);
}; };
} // namespace sp } // namespace sp

View File

@@ -1,7 +1,7 @@
#include <sp/common/VarInt.h> #include <sp/common/VarInt.h>
#include <stdexcept>
#include <sp/common/DataBuffer.h> #include <sp/common/DataBuffer.h>
#include <stdexcept>
namespace sp { namespace sp {
@@ -49,4 +49,9 @@ DataBuffer& operator>>(DataBuffer& in, VarInt& var) {
return in; return in;
} }
std::ostream& operator<<(std::ostream& a_Stream, const sp::VarInt& a_VarInt) {
a_Stream << a_VarInt.GetValue();
return a_Stream;
}
} // namespace sp } // namespace sp