[+] Added move and copy operators + constructors for types that are either struct members in the public API or are likely to be copied by the user

This commit is contained in:
Reece Wilson 2022-05-27 18:13:08 +01:00
parent e665714341
commit 131f7de43b
19 changed files with 71 additions and 18 deletions

View File

@ -11,6 +11,8 @@ namespace Aurora::Compression
{
struct CompressionInfo
{
AU_COPY_MOVE_DEF(CompressionInfo);
ECompressionType type;
/**

View File

@ -9,9 +9,8 @@
namespace Aurora::Crypto::ECC
{
class IECCPrivate
struct IECCPrivate
{
public:
virtual bool Sign(const Memory::MemoryViewRead &plainText,
EHashType method,
Memory::ByteBuffer &out) = 0;

View File

@ -9,9 +9,8 @@
namespace Aurora::Crypto::ECC
{
class IECCPublic
struct IECCPublic
{
public:
virtual bool Verify(const Memory::MemoryViewRead &hash,
const Memory::MemoryViewRead &signature) = 0;

View File

@ -11,6 +11,8 @@ namespace Aurora::Crypto::RSA
{
struct RSAKey
{
AU_COPY_MOVE_DEF(RSAKey);
RSAMeta meta;
DerBuffer blob;
};

View File

@ -11,6 +11,8 @@ namespace Aurora::Crypto::RSA
{
struct RSAMeta
{
AU_COPY_MOVE_DEF(RSAMeta);
ERSAKeyType type;
EKeyType side;
};

View File

@ -20,6 +20,7 @@ namespace Aurora::Crypto::X509
struct CertName
{
AU_COPY_MOVE_DEF(CertName);
AuString commonName; // Tbs
AuString department; // Tbs
@ -34,18 +35,22 @@ namespace Aurora::Crypto::X509
struct DecodedCertificate
{
AU_COPY_MOVE_DEF(DecodedCertificate);
// TODO:
//SignatureAlgorithm signature;
struct Issuer : CertName
{
AU_COPY_MOVE_DEF(Issuer);
Memory::ByteBuffer id;
} issuer;
struct Subject : CertName
{
AU_COPY_MOVE_DEF(Subject);
Memory::ByteBuffer id;
} subject;
struct Vaildity // Tbs
{ // Tbs
AU_COPY_MOVE_DEF(Vaildity);
AuUInt issued; // Tbs
AuUInt expire; // Tbs
} validity; // Tbs

View File

@ -11,6 +11,8 @@ namespace Aurora::Data
{
struct TypedValue
{
AU_COPY_MOVE(TypedValue);
EDataType type;
Value value;

View File

@ -11,6 +11,8 @@ namespace Aurora::Data
{
struct Value
{
AU_COPY_MOVE(Value);
#define CONSTRUCTOR(type, member)\
Value(type val)\
{\

View File

@ -11,6 +11,8 @@ namespace Aurora::HWInfo
{
struct AUKN_SYM CpuId
{
AU_COPY_MOVE_DEF(CpuId);
bool SSE3() const;
bool PCLMULQDQ() const;
bool MONITOR() const;

View File

@ -14,6 +14,8 @@ namespace Aurora::HWInfo
{
struct CpuInfo
{
AU_COPY_MOVE_DEF(CpuInfo);
Aurora::Build::EArchitecture cpuArch;
/// Total number of sockets reported by the hypervisor

View File

@ -13,8 +13,8 @@ namespace Aurora::IO::FS
{
AU_NO_COPY_NO_MOVE(FileSeekableReader)
FileSeekableReader() {}
~FileSeekableReader() {}
inline FileSeekableReader() {}
inline ~FileSeekableReader() {}
template<typename... T>
bool OpenFile(T... args)

View File

@ -11,6 +11,8 @@ namespace Aurora::IO::FS
{
struct Stat
{
AU_COPY_MOVE_DEF(Stat);
bool exists;
bool existsFile, existsDirectory, existsSystemResource;
bool symLink;

View File

@ -88,7 +88,7 @@ namespace Aurora::Memory
* @brief Move constructor
* @param buffer
*/
ByteBuffer(ByteBuffer &&buffer)
inline ByteBuffer(ByteBuffer &&buffer)
{
this->base = buffer.base;
this->length = buffer.length;
@ -113,7 +113,7 @@ namespace Aurora::Memory
* @param buffer
* @param preservePointers
*/
ByteBuffer(const ByteBuffer &buffer, bool preservePointers = true)
inline ByteBuffer(const ByteBuffer &buffer, bool preservePointers = true)
{
this->base = FAlloc<AuUInt8 *>(buffer.length);
if (!this->base)
@ -146,7 +146,7 @@ namespace Aurora::Memory
* @param circular
* @param expandable
*/
ByteBuffer(const void *in, AuUInt length, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
inline ByteBuffer(const void *in, AuUInt length, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
{
this->base = FAlloc<AuUInt8 *>(length);
if (!this->base)
@ -162,7 +162,7 @@ namespace Aurora::Memory
this->scaleSize = kBufferInitialPower;
}
ByteBuffer(const AuList<AuUInt8> &vector, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
inline ByteBuffer(const AuList<AuUInt8> &vector, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
{
this->base = FAlloc<AuUInt8 *>(vector.size());
if (!this->base)
@ -178,7 +178,7 @@ namespace Aurora::Memory
this->scaleSize = kBufferInitialPower;
}
ByteBuffer(AuUInt length, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
inline ByteBuffer(AuUInt length, bool circular = false, bool expandable = false) : flagCircular(circular), flagExpandable(expandable), flagReadError(0), flagWriteError(0)
{
if (!length)
{
@ -219,7 +219,7 @@ namespace Aurora::Memory
/**
* @brief Default constructor, allocates an auto-expanding linear bytebuffer
*/
ByteBuffer() : flagCircular(0), flagExpandable(true), flagReadError(0), flagWriteError(0)
inline ByteBuffer() : flagCircular(0), flagExpandable(true), flagReadError(0), flagWriteError(0)
{
this->base = {};
this->length = {};
@ -229,7 +229,7 @@ namespace Aurora::Memory
this->scaleSize = kBufferInitialPower;
}
~ByteBuffer()
inline ~ByteBuffer()
{
if (this->base)
{
@ -269,6 +269,7 @@ namespace Aurora::Memory
// utils: Move assignment
inline ByteBuffer &operator =(ByteBuffer &&);
inline ByteBuffer &operator =(const ByteBuffer &buffer);
// utils: &byteArray[n]
inline AuUInt8 &operator [](AuUInt idx) const;

View File

@ -147,6 +147,33 @@ namespace Aurora::Memory
return *this;
}
ByteBuffer &ByteBuffer::operator =(const ByteBuffer &buffer)
{
this->base = FAlloc<AuUInt8 *>(buffer.length);
if (!this->base)
{
Reset();
return *this;
}
this->length = buffer.length;
this->allocSize = buffer.length;
if (true) //preservePointers
{
this->writePtr = this->base + (buffer.writePtr - buffer.base);
this->readPtr = this->base + (buffer.readPtr - buffer.base);
}
//else
//{
// this->writePtr = this->base;
// this->readPtr = this->base;
//}
AuMemcpy(this->base, buffer.base, this->length);
this->flagCircular = buffer.flagCircular;
this->flagExpandable = buffer.flagExpandable;
this->scaleSize = buffer.scaleSize;
return *this;
}
AuList<AuUInt8> ByteBuffer::RemainingBytesToVector(bool endAtWrite) const
{
AuList<AuUInt8> vec;

View File

@ -11,6 +11,8 @@ namespace Aurora::Processes
{
struct StartupParmaters
{
AU_COPY_MOVE_DEF(StartupParmaters);
/**
* @brief Relative or absolute path to the executable binary
*/

View File

@ -11,6 +11,8 @@ namespace Aurora::RNG
{
struct RandomDef
{
AU_COPY_MOVE_DEF(RandomDef);
bool secure;
AuOptional<AuUInt32> seed;
AuOptional<AuUInt64> seed64;

View File

@ -14,6 +14,8 @@ namespace Aurora::Registry
struct AUKN_SYM IOPath
{
AU_COPY_MOVE(IOPath);
IOPath();
IOPath(const AuString &path);

View File

@ -34,7 +34,7 @@ namespace Aurora::SWInfo
public:
OSInformation() : kKernelString(&_kIgnore), kUserlandDesktopEnv(&_kIgnore), kUserlandBrand(&_kIgnore), kBuildString(&_kIgnore), ePlatform(Build::EPlatform::eEnumInvalid)
inline OSInformation() : kKernelString(&_kIgnore), kUserlandDesktopEnv(&_kIgnore), kUserlandBrand(&_kIgnore), kBuildString(&_kIgnore), ePlatform(Build::EPlatform::eEnumInvalid)
{
}
@ -45,7 +45,7 @@ namespace Aurora::SWInfo
kBuildString,
ePlatform
))
AU_NO_COPY(OSInformation);
AU_MOVE(OSInformation);
AU_COPY_MOVE(OSInformation);
};
}