KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_io_kicad_sexpr_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_IO_KICAD_SEXPR_LIB_CACHE_H_
23#define SCH_IO_KICAD_SEXPR_LIB_CACHE_H_
24
26
28class SCH_PIN;
29class SCH_TEXT;
30class SCH_TEXTBOX;
31class LINE_READER;
33
38{
39public:
40 SCH_IO_KICAD_SEXPR_LIB_CACHE( const wxString& aLibraryPath );
42
43 // Most all functions in this class throw IO_ERROR exceptions. There are no
44 // error codes nor user interface calls from here, nor in any SCH_IO objects.
45 // Catch these exceptions higher up please.
46
48 void Save( const std::optional<bool>& aOpt = std::nullopt ) override;
49
50 void Load() override;
51
52 void DeleteSymbol( const wxString& aName ) override;
53
54 static void SaveSymbol( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter,
55 int aNestLevel = 0, const wxString& aLibName = wxEmptyString );
56
57 void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
59
60private:
62
64
65 static void saveSymbolDrawItem( SCH_ITEM* aItem, OUTPUTFORMATTER& aFormatter,
66 int aNestLevel );
67 static void saveField( SCH_FIELD* aField, OUTPUTFORMATTER& aFormatter, int aNestLevel );
68 static void savePin( SCH_PIN* aPin, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );
69 static void saveText( SCH_TEXT* aText, OUTPUTFORMATTER& aFormatter, int aNestLevel = 0 );
70 static void saveTextBox( SCH_TEXTBOX* aTextBox, OUTPUTFORMATTER& aFormatter,
71 int aNestLevel = 0 );
72
73 static void saveDcmInfoAsFields( LIB_SYMBOL* aSymbol, OUTPUTFORMATTER& aFormatter,
74 int& aNextFreeFieldId, int aNestLevel );
75};
76
77#endif // SCH_IO_KICAD_SEXPR_LIB_CACHE_H_
A LINE_READER that reads from an open file.
Definition: richio.h:185
Define a library symbol object.
Definition: lib_symbol.h:77
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 the KiCad s-expression symbol libraries.
static void saveField(SCH_FIELD *aField, OUTPUTFORMATTER &aFormatter, int aNestLevel)
static void saveTextBox(SCH_TEXTBOX *aTextBox, OUTPUTFORMATTER &aFormatter, int aNestLevel=0)
static void saveDcmInfoAsFields(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int &aNextFreeFieldId, int aNestLevel)
static void SaveSymbol(LIB_SYMBOL *aSymbol, OUTPUTFORMATTER &aFormatter, int aNestLevel=0, const wxString &aLibName=wxEmptyString)
static void saveText(SCH_TEXT *aText, OUTPUTFORMATTER &aFormatter, int aNestLevel=0)
static void saveSymbolDrawItem(SCH_ITEM *aItem, OUTPUTFORMATTER &aFormatter, int aNestLevel)
void DeleteSymbol(const wxString &aName) override
void Save(const std::optional< bool > &aOpt=std::nullopt) override
Save the entire library to file m_libFileName;.
static void savePin(SCH_PIN *aPin, OUTPUTFORMATTER &aFormatter, int aNestLevel=0)
A SCH_IO derivation for loading schematic files using the new s-expression file format.
A base cache assistant implementation for the symbol library portion of the SCH_IO API.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174