24#include <compoundfilereader.h>
51std::tuple<wxString, const CFB::COMPOUND_FILE_ENTRY*>
60 return { wxEmptyString,
nullptr };
62 return { it->first, it->second };
85 const CFB::COMPOUND_FILE_ENTRY* root =
m_reader->GetRootEntry();
91 [
this](
const CFB::COMPOUND_FILE_ENTRY* tentry,
const CFB::utf16string& dir,
int level ) ->
int
97 [&](
const CFB::COMPOUND_FILE_ENTRY* entry,
const CFB::utf16string&,
int ) ->
int
99 std::wstring fileName = UTF16ToWstring( entry->name, entry->nameLen );
101 if( m_reader->IsStream( entry ) && fileName == L
"Parameters" )
103 ALTIUM_BINARY_PARSER parametersReader( *this, entry );
104 std::map<wxString, wxString> parameterProperties =
105 parametersReader.ReadProperties();
107 wxString key = ALTIUM_PROPS_UTILS::ReadString(
108 parameterProperties, wxT(
"PATTERN" ), wxT(
"" ) );
109 wxString fpName = ALTIUM_PROPS_UTILS::ReadUnicodeString(
110 parameterProperties, wxT(
"PATTERN" ), wxT(
"" ) );
112 m_libFootprintDirNameCache[key] = fpName;
113 m_libFootprintNameCache[fpName] = tentry;
125 const CFB::COMPOUND_FILE_ENTRY* models_root =
nullptr;
126 const CFB::COMPOUND_FILE_ENTRY* models_data =
nullptr;
132 models_data =
FindStream( {
"Library",
"Models",
"Data" } );
142 std::vector<AMODEL> models;
148 models.push_back( elem );
152 m_reader->EnumFiles(
m_reader->GetRootEntry(), 2, [&](
const CFB::COMPOUND_FILE_ENTRY* entry,
const CFB::utf16string& dir,
int ) ->
int
157 if( m_reader->IsStream( entry ) )
160 std::string dir_str = UTF16ToUTF8( dir.c_str() );
161 std::string entry_str = UTF16ToUTF8( entry->name );
163 if( dir_str.compare(
"Library" ) == 0 && entry_str.compare(
"Models" ) == 0 )
178 [&](
const CFB::COMPOUND_FILE_ENTRY* stepEntry,
const CFB::utf16string&,
int ) ->
int
181 wxString fileName = UTF16ToUTF8( stepEntry->name, stepEntry->nameLen );
183 if( !fileName.ToLong( &fileNumber ) )
186 if( !m_reader->IsStream( stepEntry ) || fileNumber >=
long( models.size() ) )
189 size_t stepSize =
static_cast<size_t>( stepEntry->size );
190 std::vector<char> stepContent( stepSize );
193 m_reader->ReadFile( stepEntry, 0, stepContent.data(), stepSize );
195 if( stepContent.empty() )
201 wxString modelName = models[fileNumber].id;
202 m_libModelsCache.emplace( modelName, std::make_pair( std::move( models[fileNumber] ),
203 std::move( stepContent ) ) );
size_t GetRemainingBytes() const
std::unique_ptr< CFB::CompoundFileReader > m_reader
const CFB::COMPOUND_FILE_ENTRY * FindStream(const std::vector< std::string > &aStreamPath) const
friend class ALTIUM_PCB_COMPOUND_FILE
std::map< wxString, wxString > ListLibFootprints()
void cacheLibFootprintNames()
const std::pair< AMODEL, std::vector< char > > * GetLibModel(const wxString &aModelID) const
std::map< wxString, wxString > m_libFootprintDirNameCache
std::map< wxString, std::pair< AMODEL, std::vector< char > > > m_libModelsCache
std::map< wxString, const CFB::COMPOUND_FILE_ENTRY * > m_libFootprintNameCache
~ALTIUM_PCB_COMPOUND_FILE()
std::tuple< wxString, const CFB::COMPOUND_FILE_ENTRY * > FindLibFootprintDirName(const wxString &aFpUnicodeName)