mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-05-09 14:04:57 +00:00
chore: make some zone classes use const references
This commit is contained in:
parent
897a571a41
commit
778361728c
@ -2,7 +2,7 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
AbstractSalsa20Processor::AbstractSalsa20Processor(const int streamCount, std::string& zoneName, const uint8_t* salsa20Key, size_t keySize)
|
||||
AbstractSalsa20Processor::AbstractSalsa20Processor(const int streamCount, const std::string& zoneName, const uint8_t* salsa20Key, const size_t keySize)
|
||||
: m_stream_count(streamCount),
|
||||
m_stream_contexts(std::make_unique<StreamContext[]>(streamCount)),
|
||||
m_stream_block_indices(std::make_unique<unsigned int[]>(streamCount))
|
||||
@ -19,9 +19,9 @@ uint8_t* AbstractSalsa20Processor::GetHashBlock(const int streamNumber) const
|
||||
return &m_block_hashes[blockIndexOffset + streamOffset];
|
||||
}
|
||||
|
||||
void AbstractSalsa20Processor::InitStreams(std::string& zoneName, const uint8_t* salsa20Key, size_t keySize) const
|
||||
void AbstractSalsa20Processor::InitStreams(const std::string& zoneName, const uint8_t* salsa20Key, const size_t keySize) const
|
||||
{
|
||||
const int zoneNameLength = zoneName.length();
|
||||
const auto zoneNameLength = zoneName.length();
|
||||
const size_t blockHashBufferSize = BLOCK_HASHES_COUNT * m_stream_count * SHA1_HASH_SIZE;
|
||||
|
||||
assert(blockHashBufferSize % 4 == 0);
|
||||
|
@ -28,11 +28,11 @@ protected:
|
||||
std::unique_ptr<uint8_t[]> m_block_hashes;
|
||||
std::unique_ptr<unsigned int[]> m_stream_block_indices;
|
||||
|
||||
AbstractSalsa20Processor(int streamCount, std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
|
||||
AbstractSalsa20Processor(int streamCount, const std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
|
||||
|
||||
_NODISCARD uint8_t* GetHashBlock(int streamNumber) const;
|
||||
|
||||
void InitStreams(std::string& zoneName, const uint8_t* salsa20Key, size_t keySize) const;
|
||||
void InitStreams(const std::string& zoneName, const uint8_t* salsa20Key, size_t keySize) const;
|
||||
|
||||
public:
|
||||
virtual ~AbstractSalsa20Processor() = default;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <cassert>
|
||||
|
||||
XChunkProcessorSalsa20Encryption::XChunkProcessorSalsa20Encryption(const int streamCount,
|
||||
std::string& zoneName,
|
||||
const std::string& zoneName,
|
||||
const uint8_t* salsa20Key,
|
||||
const size_t keySize)
|
||||
: AbstractSalsa20Processor(streamCount, zoneName, salsa20Key, keySize)
|
||||
|
@ -8,7 +8,7 @@
|
||||
class XChunkProcessorSalsa20Encryption final : public IXChunkProcessor, public AbstractSalsa20Processor
|
||||
{
|
||||
public:
|
||||
XChunkProcessorSalsa20Encryption(int streamCount, std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
|
||||
XChunkProcessorSalsa20Encryption(int streamCount, const std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
|
||||
|
||||
size_t Process(int streamNumber, const uint8_t* input, size_t inputLength, uint8_t* output, size_t outputBufferSize) override;
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "WritingException.h"
|
||||
#include "WritingFileStream.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
@ -42,7 +43,7 @@ void ZoneWriter::AddStreamProcessor(std::unique_ptr<OutputStreamProcessor> strea
|
||||
m_processor_chain_dirty = true;
|
||||
}
|
||||
|
||||
void ZoneWriter::RemoveStreamProcessor(OutputStreamProcessor* streamProcessor)
|
||||
void ZoneWriter::RemoveStreamProcessor(const OutputStreamProcessor* streamProcessor)
|
||||
{
|
||||
for (auto i = m_processors.begin(); i < m_processors.end(); ++i)
|
||||
{
|
||||
@ -72,12 +73,12 @@ bool ZoneWriter::WriteZone(std::ostream& stream)
|
||||
}
|
||||
catch (WritingException& e)
|
||||
{
|
||||
std::cout << "Writing fastfile failed: " << e.Message() << "\n";
|
||||
std::cout << std::format("Writing fastfile failed: {}\n", e.Message());
|
||||
return false;
|
||||
}
|
||||
catch (std::runtime_error& e)
|
||||
{
|
||||
std::cout << "Writing fastfile failed: " << e.what() << "\n";
|
||||
std::cout << std::format("Writing fastfile failed: {}\n", e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
void AddWritingStep(std::unique_ptr<IWritingStep> step);
|
||||
void AddStreamProcessor(std::unique_ptr<OutputStreamProcessor> streamProcessor);
|
||||
|
||||
void RemoveStreamProcessor(OutputStreamProcessor* streamProcessor);
|
||||
void RemoveStreamProcessor(const OutputStreamProcessor* streamProcessor);
|
||||
|
||||
bool WriteZone(std::ostream& stream);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user