1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Move Internals::byte_array into crypto.cpp

This commit is contained in:
Matias Fontanini
2017-04-30 09:53:11 -07:00
parent 6bfc0c84f0
commit 0cda2287a8
2 changed files with 46 additions and 52 deletions

View File

@@ -52,57 +52,6 @@ class ICMPExtensionsStructure;
namespace Internals {
template<size_t n>
class byte_array {
public:
typedef uint8_t* iterator;
typedef const uint8_t* const_iterator;
byte_array() {
std::fill(begin(), end(), 0);
}
template<typename InputIterator>
byte_array(InputIterator start, InputIterator last) {
std::copy(start, last, data);
}
template<typename InputIterator>
byte_array(InputIterator start) {
std::copy(start, n, data);
}
uint8_t& operator[](size_t i) {
return data[i];
}
uint8_t operator[](size_t i) const{
return data[i];
}
iterator begin() {
return data;
}
iterator end() {
return data + n;
}
const_iterator begin() const {
return data;
}
const_iterator end() const {
return data + n;
}
size_t size() const {
return n;
}
private:
uint8_t data[n];
};
void skip_line(std::istream& input);
bool from_hex(const std::string& str, uint32_t& result);
bool from_hex(const std::string& str, std::string& result);