Added DataUtils

This commit is contained in:
Sebastian Messmer 2015-12-14 17:18:53 +01:00
parent c6658839e0
commit 10ac4eef29
2 changed files with 29 additions and 0 deletions

12
data/DataUtils.cpp Normal file
View 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
View 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