KiCad PCB EDA Suite
sch_sexpr_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_SEXPR_LIB_PLUGIN_CACHE_
23#define _SCH_SEXPR_LIB_PLUGIN_CACHE_
24
25#include "../sch_lib_plugin_cache.h"
26
28class LIB_FIELD;
29class LIB_ITEM;
30class LIB_PIN;
31class LIB_TEXT;
32class LIB_TEXTBOX;
33class LINE_READER;
35
40{
41public:
42 SCH_SEXPR_PLUGIN_CACHE( const wxString& aLibraryPath );
44
45 // Most all functions in this class throw IO_ERROR exceptions. There are no
46 // error codes nor user interface calls from here, nor in any SCH_PLUGIN objects.
47 // Catch these exceptions higher up please.
48
50 void Save( const std::optional<bool>& aOpt = std::nullopt ) override;
51
52 void Load() override;
53
54 void DeleteSymbol( const wxString& aName ) override;
55
56 static void SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter,
57 int aNestLevel = 0, const wxString& aLibName = wxEmptyString );
58
59private:
61
62 static void saveSymbolDrawItem( LIB_ITEM* aItem, OUTPUTFORMATTER& aFormatter,
63 int aNestLevel );
64 static void saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel );
65 static void savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );
66 static void saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );
67 static void saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter,
68 int aNestLevel = 0 );
69
70 static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter,
71 int& aNextFreeFieldId, int aNestLevel );
72
74};
75
76#endif // _SCH_SEXPR_LIB_PLUGIN_CACHE_
A LINE_READER that reads from an open file.
Definition: richio.h:173
Field object used in symbol libraries.
Definition: lib_field.h:60
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
Define a library symbol object.
Definition: lib_symbol.h:98
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:81
An interface used to output 8 bit text in a convenient way.
Definition: richio.h:310
A base cache assistant implementation for the symbol library portion of the SCH_PLUGIN API.
A cache assistant for the KiCad s-expression symbol libraries.
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int aNestLevel=0, const wxString &aLibName=wxEmptyString)
static void savePin(LIB_PIN *aPin, OUTPUTFORMATTER &aFormatter, int aNestLevel=0)
static void saveText(LIB_TEXT *aText, OUTPUTFORMATTER &aFormatter, int aNestLevel=0)
static void saveSymbolDrawItem(LIB_ITEM *aItem, OUTPUTFORMATTER &aFormatter, int aNestLevel)
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
SCH_SEXPR_PLUGIN_CACHE(const wxString &aLibraryPath)
static void saveField(LIB_FIELD *aField, OUTPUTFORMATTER &aFormatter, int aNestLevel)
static void saveTextBox(LIB_TEXTBOX *aTextBox, OUTPUTFORMATTER &aFormatter, int aNestLevel=0)
static void saveDcmInfoAsFields(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int &aNextFreeFieldId, int aNestLevel)
void DeleteSymbol(const wxString &aName) override
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.