6#include <compoundfilereader.h>
33std::tuple<wxString, const CFB::COMPOUND_FILE_ENTRY*>
42 return { wxEmptyString,
nullptr };
44 return { it->first, it->second };
67 const CFB::COMPOUND_FILE_ENTRY* root =
m_reader->GetRootEntry();
73 [
this](
const CFB::COMPOUND_FILE_ENTRY* tentry,
const CFB::utf16string& dir,
int level ) ->
int
79 [&](
const CFB::COMPOUND_FILE_ENTRY* entry,
const CFB::utf16string&,
int ) ->
int
81 std::wstring fileName = UTF16ToWstring( entry->name, entry->nameLen );
83 if( m_reader->IsStream( entry ) && fileName == L
"Parameters" )
85 ALTIUM_BINARY_PARSER parametersReader( *this, entry );
86 std::map<wxString, wxString> parameterProperties =
87 parametersReader.ReadProperties();
89 wxString key = ALTIUM_PROPS_UTILS::ReadString(
90 parameterProperties, wxT(
"PATTERN" ), wxT(
"" ) );
91 wxString fpName = ALTIUM_PROPS_UTILS::ReadUnicodeString(
92 parameterProperties, wxT(
"PATTERN" ), wxT(
"" ) );
94 m_libFootprintDirNameCache[key] = fpName;
95 m_libFootprintNameCache[fpName] = tentry;
107 const CFB::COMPOUND_FILE_ENTRY* models_root =
nullptr;
108 const CFB::COMPOUND_FILE_ENTRY* models_data =
nullptr;
114 models_data =
FindStream( {
"Library",
"Models",
"Data" } );
124 std::vector<AMODEL> models;
130 models.push_back( elem );
134 m_reader->EnumFiles(
m_reader->GetRootEntry(), 2, [&](
const CFB::COMPOUND_FILE_ENTRY* entry,
const CFB::utf16string& dir,
int ) ->
int
139 if( m_reader->IsStream( entry ) )
142 std::string dir_str = UTF16ToUTF8( dir.c_str() );
143 std::string entry_str = UTF16ToUTF8( entry->name );
145 if( dir_str.compare(
"Library" ) == 0 && entry_str.compare(
"Models" ) == 0 )
160 [&](
const CFB::COMPOUND_FILE_ENTRY* stepEntry,
const CFB::utf16string&,
int ) ->
int
163 wxString fileName = UTF16ToUTF8( stepEntry->name, stepEntry->nameLen );
165 if( !fileName.ToLong( &fileNumber ) )
168 if( !m_reader->IsStream( stepEntry ) || fileNumber >=
long( models.size() ) )
171 size_t stepSize =
static_cast<size_t>( stepEntry->size );
172 std::vector<char> stepContent( stepSize );
175 m_reader->ReadFile( stepEntry, 0, stepContent.data(), stepSize );
177 if( stepContent.empty() )
183 wxString modelName = models[fileNumber].id;
184 m_libModelsCache.emplace( modelName, std::make_pair( std::move( models[fileNumber] ),
185 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)