-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
class UtlBuffer | ||
{ | ||
private: | ||
std::vector<uint8_t> m_Buff; | ||
uint32_t m_Offset; | ||
|
||
public: | ||
UtlBuffer() | ||
: m_Offset(0) | ||
{} | ||
|
||
std::vector<uint8_t>& GetBuffer() | ||
{ | ||
return m_Buff; | ||
} | ||
|
||
uint32_t Write(const void* pubData, uint32_t cubData) | ||
{ | ||
m_Buff.resize(m_Buff.size() + cubData); | ||
memcpy_s(m_Buff.data() + m_Offset, cubData, pubData, cubData); | ||
m_Offset += cubData; | ||
|
||
return cubData; | ||
} | ||
|
||
template<class T> | ||
uint32_t Write(const std::vector<T>& data) | ||
{ | ||
return Write(data.data(), data.size()); | ||
} | ||
|
||
template<class T> | ||
uint32_t Write(const T& data) | ||
{ | ||
return Write(&data, sizeof(T)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,4 @@ static int WSAGetLastError() | |
#include <condition_variable> | ||
|
||
#include "UtlSemaphore.h" | ||
#include "UtlBuffer.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters