KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_kicad_legacy_lib_cache.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * @author Wayne Stambaugh <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef _SCH_LEGACY_LIB_PLUGIN_CACHE_
23#define _SCH_LEGACY_LIB_PLUGIN_CACHE_
24
25#include <memory>
26
27#include <eda_shape.h> // FILL_T
28
30
32class SCH_PIN;
33class SCH_FIELD;
34class SCH_SHAPE;
35class SCH_TEXT;
36class LINE_READER;
38
39
44{
45public:
46 SCH_IO_KICAD_LEGACY_LIB_CACHE( const wxString& aLibraryPath );
48
49 // Most all functions in this class throw IO_ERROR exceptions. There are no
50 // error codes nor user interface calls from here, nor in any SCH_IO objects.
51 // Catch these exceptions higher up please.
52
54 void Save( const std::optional<bool>& aOpt ) override;
55
56 void Load() override;
57
58 void DeleteSymbol( const wxString& aName ) override;
59
60 static LIB_SYMBOL* LoadPart( LINE_READER& aReader, int aMajorVersion, int aMinorVersion,
61 LIB_SYMBOL_MAP* aMap = nullptr );
62 static void SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter,
63 LIB_SYMBOL_MAP* aMap = nullptr );
64
65private:
67
68 void loadHeader( FILE_LINE_READER& aReader );
69 static void loadAliases( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader,
70 LIB_SYMBOL_MAP* aMap = nullptr );
71 static void loadField( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
72 static void loadDrawEntries( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader,
73 int aMajorVersion, int aMinorVersion );
74 static void loadFootprintFilters( std::unique_ptr<LIB_SYMBOL>& aSymbol,
75 LINE_READER& aReader );
76 void loadDocs();
77 static SCH_SHAPE* loadArc( LINE_READER& aReader );
78 static SCH_SHAPE* loadCircle( LINE_READER& aReader );
79 static SCH_TEXT* loadText( LINE_READER& aReader, int aMajorVersion, int aMinorVersion );
80 static SCH_SHAPE* loadRect( LINE_READER& aReader );
81 static SCH_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
82 static SCH_SHAPE* loadPolyLine( LINE_READER& aReader );
83 static SCH_SHAPE* loadBezier( LINE_READER& aReader );
84
85 static FILL_T parseFillMode( LINE_READER& aReader, const char* aLine, const char** aOutput );
86
87 void saveDocFile();
88 static void saveArc( SCH_SHAPE* aArc, OUTPUTFORMATTER& aFormatter );
89 static void saveBezier( SCH_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter );
90 static void saveCircle( SCH_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter );
91 static void saveField( const SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter );
92 static void savePin( const SCH_PIN* aPin, OUTPUTFORMATTER& aFormatter );
93 static void savePolyLine( SCH_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter );
94 static void saveRectangle( SCH_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter );
95 static void saveText( const SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter );
96
99};
100
101#endif // _SCH_LEGACY_LIB_PLUGIN_CACHE_
A LINE_READER that reads from an open file.
Definition: richio.h:185
Define a library symbol object.
Definition: lib_symbol.h:78
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:322
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
A cache assistant for KiCad legacy symbol libraries.
static void loadDrawEntries(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
void loadHeader(FILE_LINE_READER &aReader)
static SCH_SHAPE * loadBezier(LINE_READER &aReader)
static void saveArc(SCH_SHAPE *aArc, OUTPUTFORMATTER &aFormatter)
static void saveCircle(SCH_SHAPE *aCircle, OUTPUTFORMATTER &aFormatter)
static SCH_SHAPE * loadArc(LINE_READER &aReader)
static void loadField(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void saveField(const SCH_FIELD *aField, OUTPUTFORMATTER &aFormatter)
static LIB_SYMBOL * LoadPart(LINE_READER &aReader, int aMajorVersion, int aMinorVersion, LIB_SYMBOL_MAP *aMap=nullptr)
static void savePolyLine(SCH_SHAPE *aPolyLine, OUTPUTFORMATTER &aFormatter)
static SCH_SHAPE * loadPolyLine(LINE_READER &aReader)
static void saveBezier(SCH_SHAPE *aBezier, OUTPUTFORMATTER &aFormatter)
static SCH_SHAPE * loadCircle(LINE_READER &aReader)
void Save(const std::optional< bool > &aOpt) override
Save the entire library to file m_libFileName;.
static SCH_SHAPE * loadRect(LINE_READER &aReader)
static void loadAliases(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, LIB_SYMBOL_MAP *aMap=nullptr)
static void loadFootprintFilters(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static SCH_TEXT * loadText(LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
void DeleteSymbol(const wxString &aName) override
static void savePin(const SCH_PIN *aPin, OUTPUTFORMATTER &aFormatter)
static SCH_PIN * loadPin(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static FILL_T parseFillMode(LINE_READER &aReader, const char *aLine, const char **aOutput)
static void saveRectangle(SCH_SHAPE *aRectangle, OUTPUTFORMATTER &aFormatter)
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, LIB_SYMBOL_MAP *aMap=nullptr)
static void saveText(const SCH_TEXT *aText, OUTPUTFORMATTER &aFormatter)
A SCH_IO derivation for loading schematic files created before the new s-expression file format.
A base cache assistant implementation for the symbol library portion of the SCH_IO API.
FILL_T
Definition: eda_shape.h:55
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP