Added DataUtils
This commit is contained in:
parent
c6658839e0
commit
10ac4eef29
12
data/DataUtils.cpp
Normal file
12
data/DataUtils.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "DataUtils.h"
|
||||
|
||||
namespace cpputils {
|
||||
namespace DataUtils {
|
||||
Data resize(Data data, size_t newSize) {
|
||||
Data newData(newSize);
|
||||
newData.FillWithZeroes(); // TODO Only fill region after copied old data with zeroes
|
||||
std::memcpy(newData.data(), data.data(), std::min(newData.size(), data.size()));
|
||||
return newData;
|
||||
}
|
||||
}
|
||||
}
|
17
data/DataUtils.h
Normal file
17
data/DataUtils.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#ifndef MESSMER_CPPUTILS_DATA_DATAUTILS_H
|
||||
#define MESSMER_CPPUTILS_DATA_DATAUTILS_H
|
||||
|
||||
#include "Data.h"
|
||||
|
||||
namespace cpputils {
|
||||
namespace DataUtils {
|
||||
//TODO Test
|
||||
|
||||
//Return a new data object with the given size and initialize as much as possible with the given input data.
|
||||
//If the new data object is larger, then the remaining bytes will be zero filled.
|
||||
Data resize(Data data, size_t newSize);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user