KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pads_binary_utils.h File Reference
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <optional>
#include <fstream>
#include <string>
#include <vector>
#include <wx/string.h>
#include <ki_exception.h>
#include <string_utils.h>

Go to the source code of this file.

Classes

struct  PADS_IO::SDB_FOOTER_ERROR
 Where a footer check failed and what was wrong with it. More...
 
class  PADS_IO::BINARY_CURSOR
 Bounds-checked little-endian read cursor over a PADS binary buffer. More...
 
class  PADS_IO::SDB_RECORD
 A bounds-checked reader positioned at one record inside a buffer. More...
 

Namespaces

namespace  PADS_IO
 

Functions

uint8_t PADS_IO::getU8 (const std::vector< uint8_t > &aData, size_t aOffset)
 Little-endian byte assembly with no bounds checking.
 
uint16_t PADS_IO::getU16LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
uint32_t PADS_IO::getU32LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
double PADS_IO::getF64LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
float PADS_IO::getF32LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
bool PADS_IO::ReadFileHeader (const wxString &aFileName, std::vector< uint8_t > &aOut, size_t aCount)
 Read at most aCount leading bytes of aFileName into aOut, which is sized to what was actually read.
 
bool PADS_IO::ReadFileToBuffer (const wxString &aFileName, std::vector< uint8_t > &aOut)
 Read an entire file into aOut.
 
std::string PADS_IO::readFixedStringRaw (const std::vector< uint8_t > &aData, size_t aOffset, size_t aMaxLen)
 Read a NUL-terminated fixed-width field starting at aOffset, scanning at most aMaxLen bytes, WITHOUT trimming.
 
std::string PADS_IO::readFixedString (const std::vector< uint8_t > &aData, size_t aOffset, size_t aMaxLen)
 As readFixedStringRaw, then trim trailing spaces.
 
bool PADS_IO::HasSdbMagic (const std::vector< uint8_t > &aData, uint8_t aMagic1)
 Check the PADS SDB container magic, a leading 0x00 followed by a format-specific second byte.
 
std::optional< SDB_FOOTER_ERRORPADS_IO::CheckSdbFooter (const std::vector< uint8_t > &aData, size_t aFooterStart, const char *aGuid, size_t aGuidLen)
 Check a PADS SDB footer at aFooterStart: the ASCII GUID followed by an absolute back-pointer to the serialized container-item array.
 
void PADS_IO::ValidateSdbFooter (const std::vector< uint8_t > &aData, size_t aFooterStart, const char *aGuid, size_t aGuidLen)
 As CheckSdbFooter, throwing a bare IO_ERROR on failure.
 

Variables

constexpr uint16_t PADS_IO::SDB_RECORD_SENTINEL = 0xFFFE
 
constexpr double PADS_IO::SDB_BASIC_PER_MIL = 38100.0