Move the * and + Bytes methods onto Bytes itself.

This commit is contained in:
dg
2022-12-18 22:00:16 +00:00
parent 9bd8b8915e
commit 339ea3b5a4
4 changed files with 21 additions and 36 deletions

View File

@@ -215,6 +215,24 @@ Bytes Bytes::reverseBits() const
return output;
}
Bytes Bytes::operator + (const Bytes& other)
{
Bytes output;
ByteWriter bw(output);
bw += *this;
bw += other;
return output;
}
Bytes Bytes::operator * (size_t count)
{
Bytes output;
ByteWriter bw(output);
while (count--)
bw += *this;
return output;
}
uint8_t toByte(
std::vector<bool>::const_iterator start,
std::vector<bool>::const_iterator end)

View File

@@ -64,6 +64,9 @@ public:
std::vector<bool> toBits() const;
Bytes reverseBits() const;
Bytes operator + (const Bytes& other);
Bytes operator * (size_t count);
ByteReader reader() const;
ByteWriter writer();

View File

@@ -5,24 +5,6 @@
#include "fluxmap.h"
#include "lib/usb/greaseweazle.h"
static Bytes operator + (const Bytes& left, const Bytes& right)
{
Bytes output;
ByteWriter bw(output);
bw += left;
bw += right;
return output;
}
static Bytes operator * (const Bytes& left, size_t count)
{
Bytes output;
ByteWriter bw(output);
while (count--)
bw += left;
return output;
}
#define E28(val) \
(1 | ((val)<<1) & 0xff), \
(1 | ((val)>>6) & 0xff), \

View File

@@ -5,24 +5,6 @@
#include "fluxmap.h"
#include "fluxsource/kryoflux.h"
static Bytes operator + (const Bytes& left, const Bytes& right)
{
Bytes output;
ByteWriter bw(output);
bw += left;
bw += right;
return output;
}
static Bytes operator * (const Bytes& left, size_t count)
{
Bytes output;
ByteWriter bw(output);
while (count--)
bw += left;
return output;
}
static void test_convert(const Bytes& kryofluxbytes, const Bytes& fluxmapbytes)
{
std::unique_ptr<Fluxmap> fluxmap = readStream(kryofluxbytes);