mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
|
#include <cstring>
|
||
|
|
||
|
#include "dxbc_reader.h"
|
||
|
|
||
|
namespace dxvk {
|
||
|
|
||
|
DxbcTag DxbcReader::readTag() {
|
||
|
DxbcTag tag;
|
||
|
this->read(&tag, 4);
|
||
|
return tag;
|
||
|
}
|
||
|
|
||
|
|
||
|
std::string DxbcReader::readString() {
|
||
|
std::string result;
|
||
|
|
||
|
while (m_data[m_pos] != '\0')
|
||
|
result.push_back(m_data[m_pos++]);
|
||
|
|
||
|
m_pos++;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
|
||
|
void DxbcReader::read(void* dst, size_t n) {
|
||
|
if (m_pos + n > m_size)
|
||
|
throw DxvkError("DxbcReader::read: Unexpected end of file");
|
||
|
std::memcpy(dst, m_data + m_pos, n);
|
||
|
m_pos += n;
|
||
|
}
|
||
|
|
||
|
|
||
|
void DxbcReader::skip(size_t n) {
|
||
|
if (m_pos + n > m_size)
|
||
|
throw DxvkError("DxbcReader::skip: Unexpected end of file");
|
||
|
m_pos += n;
|
||
|
}
|
||
|
|
||
|
|
||
|
DxbcReader DxbcReader::clone(size_t pos) const {
|
||
|
if (pos > m_size)
|
||
|
throw DxvkError("DxbcReader::clone: Invalid offset");
|
||
|
return DxbcReader(m_data + pos, m_size - pos);
|
||
|
}
|
||
|
|
||
|
|
||
|
DxbcReader DxbcReader::resize(size_t size) const {
|
||
|
if (size > m_size)
|
||
|
throw DxvkError("DxbcReader::resize: Invalid size");
|
||
|
return DxbcReader(m_data, size, m_pos);
|
||
|
}
|
||
|
|
||
|
}
|