25#ifndef ALTIUM_PARSER_H
26#define ALTIUM_PARSER_H
39class CompoundFileReader;
40struct COMPOUND_FILE_ENTRY;
48std::string
FormatPath(
const std::vector<std::string>& aVectorPath );
66 const CFB::COMPOUND_FILE_ENTRY*
FindStream(
const std::vector<std::string>& aStreamPath )
const;
69 std::unique_ptr<CFB::CompoundFileReader>
m_reader;
78 ALTIUM_PARSER( std::unique_ptr<
char[]>& aContent,
size_t aSize );
81 template <
typename Type>
85 if( remainingBytes >=
sizeof( Type ) )
87 Type val = *(Type*) (
m_pos );
88 m_pos +=
sizeof( Type );
93 m_pos += remainingBytes;
99 template <
typename Type>
102 char*
const oldPos =
m_pos;
104 Type result = Read<Type>();
112 uint8_t len = Read<uint8_t>();
117 wxString val = wxString(
m_pos, wxConvISO8859_1, len );
124 return wxString(
"" );
130 std::map<uint32_t, wxString> table;
133 while( remaining >= 8 )
135 uint32_t index = Read<uint32_t>();
136 uint32_t length = Read<uint32_t>();
144 if( length > remaining )
147 str = wxString(
m_pos, wxMBConvUTF16LE(), length - 2 );
150 table.emplace( index, str );
167 std::vector<char> data(
m_pos,
m_pos + aSize );
204 uint32_t length = Read<uint32_t>();
213 static int ReadInt(
const std::map<wxString, wxString>& aProps,
214 const wxString& aKey,
int aDefault );
216 static double ReadDouble(
const std::map<wxString, wxString>& aProps,
217 const wxString& aKey,
double aDefault );
219 static bool ReadBool(
const std::map<wxString, wxString>& aProps,
220 const wxString& aKey,
bool aDefault );
222 static int32_t
ReadKicadUnit(
const std::map<wxString, wxString>& aProps,
223 const wxString& aKey,
const wxString& aDefault );
225 static wxString
ReadString(
const std::map<wxString, wxString>& aProps,
226 const wxString& aKey,
const wxString& aDefault );
std::string FormatPath(const std::vector< std::string > &aVectorPath)
Helper for debug logging (vector -> string)
const CFB::CompoundFileReader & GetCompoundFileReader() const
~ALTIUM_COMPOUND_FILE()=default
ALTIUM_COMPOUND_FILE & operator=(const ALTIUM_COMPOUND_FILE &temp_obj)=delete
std::vector< char > m_buffer
std::unique_ptr< CFB::CompoundFileReader > m_reader
const CFB::COMPOUND_FILE_ENTRY * FindStream(const std::vector< std::string > &aStreamPath) const
ALTIUM_COMPOUND_FILE(const ALTIUM_COMPOUND_FILE &temp_obj)=delete
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
size_t GetRemainingBytes() const
std::map< wxString, wxString > ReadProperties()
size_t GetRemainingSubrecordBytes() const
static wxString ReadString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
std::map< uint32_t, wxString > ReadWideStringTable()
std::unique_ptr< char[]> m_content
size_t ReadAndSetSubrecordLength()
std::vector< char > ReadVector(size_t aSize)
static double ReadDouble(const std::map< wxString, wxString > &aProps, const wxString &aKey, double aDefault)
VECTOR2I ReadVector2ISize()
static int32_t ConvertToKicadUnit(const double aValue)
static bool ReadBool(const std::map< wxString, wxString > &aProps, const wxString &aKey, bool aDefault)
VECTOR2I ReadVector2IPos()
void Skip(size_t aLength)