KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_legacy_lib_plugin_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
29#include "../sch_lib_plugin_cache.h"
30
32class LIB_FIELD;
33class LIB_PIN;
34class LIB_SHAPE;
35class LIB_TEXT;
36class LINE_READER;
38
39
44{
45public:
46 SCH_LEGACY_PLUGIN_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_PLUGIN 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 LIB_SHAPE* loadArc( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
78 static LIB_SHAPE* loadCircle( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
79 static LIB_TEXT* loadText( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader,
80 int aMajorVersion, int aMinorVersion );
81 static LIB_SHAPE* loadRect( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
82 static LIB_PIN* loadPin( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
83 static LIB_SHAPE* loadPolyLine( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
84 static LIB_SHAPE* loadBezier( std::unique_ptr<LIB_SYMBOL>& aSymbol, LINE_READER& aReader );
85
86 static FILL_T parseFillMode( LINE_READER& aReader, const char* aLine, const char** aOutput );
87
88 void saveDocFile();
89 static void saveArc( LIB_SHAPE* aArc, OUTPUTFORMATTER& aFormatter );
90 static void saveBezier( LIB_SHAPE* aBezier, OUTPUTFORMATTER& aFormatter );
91 static void saveCircle( LIB_SHAPE* aCircle, OUTPUTFORMATTER& aFormatter );
92 static void saveField( const LIB_FIELD* aField, OUTPUTFORMATTER& aFormatter );
93 static void savePin( const LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter );
94 static void savePolyLine( LIB_SHAPE* aPolyLine, OUTPUTFORMATTER& aFormatter );
95 static void saveRectangle( LIB_SHAPE* aRectangle, OUTPUTFORMATTER& aFormatter );
96 static void saveText( const LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter );
97
100};
101
102#endif // _SCH_LEGACY_LIB_PLUGIN_CACHE_
A LINE_READER that reads from an open file.
Definition: richio.h:185
Field object used in symbol libraries.
Definition: lib_field.h:62
Define a library symbol object.
Definition: lib_symbol.h:99
Define a symbol library graphical text item.
Definition: lib_text.h:40
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
A cache assistant for KiCad legacy symbol libraries.
static void saveField(const LIB_FIELD *aField, OUTPUTFORMATTER &aFormatter)
static void loadField(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
void Save(const std::optional< bool > &aOpt) override
Save the entire library to file m_libFileName;.
static LIB_SHAPE * loadCircle(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
void DeleteSymbol(const wxString &aName) override
static LIB_SHAPE * loadPolyLine(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static LIB_SHAPE * loadBezier(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static FILL_T parseFillMode(LINE_READER &aReader, const char *aLine, const char **aOutput)
static void savePin(const LIB_PIN *aPin, OUTPUTFORMATTER &aFormatter)
static LIB_TEXT * loadText(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
static void saveRectangle(LIB_SHAPE *aRectangle, OUTPUTFORMATTER &aFormatter)
static void saveBezier(LIB_SHAPE *aBezier, OUTPUTFORMATTER &aFormatter)
static void saveCircle(LIB_SHAPE *aCircle, OUTPUTFORMATTER &aFormatter)
static void loadFootprintFilters(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
void loadHeader(FILE_LINE_READER &aReader)
static void saveText(const LIB_TEXT *aText, OUTPUTFORMATTER &aFormatter)
static LIB_SHAPE * loadRect(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, LIB_SYMBOL_MAP *aMap=nullptr)
static void savePolyLine(LIB_SHAPE *aPolyLine, OUTPUTFORMATTER &aFormatter)
static void loadDrawEntries(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, int aMajorVersion, int aMinorVersion)
static LIB_PIN * loadPin(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void loadAliases(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader, LIB_SYMBOL_MAP *aMap=nullptr)
static LIB_SHAPE * loadArc(std::unique_ptr< LIB_SYMBOL > &aSymbol, LINE_READER &aReader)
static void saveArc(LIB_SHAPE *aArc, OUTPUTFORMATTER &aFormatter)
static LIB_SYMBOL * LoadPart(LINE_READER &aReader, int aMajorVersion, int aMinorVersion, LIB_SYMBOL_MAP *aMap=nullptr)
A SCH_PLUGIN 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_PLUGIN API.
FILL_T
Definition: eda_shape.h:54
std::map< wxString, LIB_SYMBOL *, LibSymbolMapSort > LIB_SYMBOL_MAP