25#ifndef PCB_IO_KICAD_SEXPR_H_ 
   26#define PCB_IO_KICAD_SEXPR_H_ 
   38#include <boost/ptr_container/ptr_map.hpp> 
  199#define SEXPR_BOARD_FILE_VERSION      20251028   
  201#define BOARD_FILE_HOST_VERSION       20200825   
  202#define LEGACY_ARC_FORMATTING         20210925   
  203#define LEGACY_NET_TIES               20220815   
  205#define FIRST_NORMALIZED_VERISON      20230924   
  211#define CTL_FOR_CLIPBOARD           (CTL_OMIT_INITIAL_COMMENTS)  
  214#define CTL_FOR_LIBRARY \ 
  215    ( CTL_OMIT_PAD_NETS | CTL_OMIT_UUIDS | CTL_OMIT_PATH | CTL_OMIT_AT | CTL_OMIT_LIBNAME ) 
 
  219#define CTL_FOR_BOARD               (CTL_OMIT_INITIAL_COMMENTS|CTL_OMIT_FOOTPRINT_VERSION) 
  280    void Remove( 
const wxString& aFootprintName );
 
  287    static long long GetTimestamp( 
const wxString& aLibPath );
 
  305    bool IsPath( 
const wxString& aPath ) 
const;
 
  307    void SetPath( 
const wxString& aPath );
 
 
  339                                                   wxString aOKButtonTitle )> aCallback )
 override 
 
  344    bool CanReadBoard( 
const wxString& aFileName ) 
const override;
 
  347                    const std::map<std::string, UTF8>* aProperties = 
nullptr ) 
override;
 
  350                      const std::map<std::string, UTF8>* aProperties = 
nullptr,
 
  351                      PROJECT* aProject = 
nullptr ) 
override;
 
  356    void FootprintEnumerate( wxArrayString& aFootprintNames, 
const wxString& aLibraryPath,
 
  357                             bool aBestEfforts, 
const std::map<std::string,
 
  358                             UTF8>* aProperties = 
nullptr ) 
override;
 
  361                                             const wxString& aFootprintName,
 
  362                                             const std::map<std::string,
 
  363                                             UTF8>* aProperties = 
nullptr ) 
override;
 
  365    bool FootprintExists( 
const wxString& aLibraryPath, 
const wxString& aFootprintName,
 
  366                          const std::map<std::string, UTF8>* aProperties = 
nullptr ) 
override;
 
  369                                const std::map<std::string, UTF8>* aProperties = 
nullptr ) 
override;
 
  372                              bool  aKeepUUID = 
false,
 
  373                              const std::map<std::string, UTF8>* aProperties = 
nullptr ) 
override;
 
  376                        const std::map<std::string, UTF8>* aProperties = 
nullptr ) 
override;
 
  378    void FootprintDelete( 
const wxString& aLibraryPath, 
const wxString& aFootprintName,
 
  379                          const std::map<std::string, UTF8>* aProperties = 
nullptr ) 
override;
 
  384                        const std::map<std::string, UTF8>* aProperties = 
nullptr) 
override;
 
  387                        const std::map<std::string, UTF8>* aProperties = 
nullptr ) 
override;
 
  405        std::string ret = 
m_sf.GetString();
 
 
  418    void validateCache( 
const wxString& aLibraryPath, 
bool checkModified = 
true );
 
  421                                   const std::map<std::string, UTF8>* aProperties,
 
  422                                   bool checkModified );
 
  424    void init( 
const std::map<std::string, UTF8>* aProperties );
 
  478                        const FOOTPRINT* aParentFP = 
nullptr ) 
const;
 
  484    void formatLayers( 
LSET aLayerMask, 
bool aEnumerateLayers, 
bool aIsZone = 
false ) 
const;
 
 
Container for design settings for a BOARD object.
 
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
 
Information pertinent to a Pcbnew printed circuit board.
 
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
 
std::unique_ptr< FOOTPRINT > m_footprint
 
void SetFilePath(const wxString &aFilePath)
 
FP_CACHE_ENTRY(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
 
const WX_FILENAME & GetFileName() const
 
std::unique_ptr< FOOTPRINT > & GetFootprint()
 
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
 
boost::ptr_map< wxString, FP_CACHE_ENTRY > m_footprints
 
PCB_IO_KICAD_SEXPR * m_owner
 
bool IsModified()
Return true if the cache is not up-to-date.
 
long long m_cache_timestamp
 
void SetPath(const wxString &aPath)
 
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
 
void Save(FOOTPRINT *aFootprintFilter=nullptr)
Save the footprint cache or a single footprint from it to disk.
 
FP_CACHE(PCB_IO_KICAD_SEXPR *aOwner, const wxString &aLibraryPath)
 
boost::ptr_map< wxString, FP_CACHE_ENTRY > & GetFootprints()
 
void Remove(const wxString &aFootprintName)
 
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
 
LSET is a set of PCB_LAYER_IDs.
 
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
 
A set of BOARD_ITEMs (i.e., without duplicates).
 
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
 
A #PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
 
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
 
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
 
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
 
void formatProperties(const BOARD *aBoard) const
formats the Nets and Netclasses
 
FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
 
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
 
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
 
bool IsLibraryWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
 
void formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams) const
 
bool DeleteLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Delete an existing library and returns true, or if library does not exist returns false,...
 
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
 
void CreateLibrary(const wxString &aLibraryPath, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Create a new empty library at aLibraryPath empty.
 
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
 
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, const FOOTPRINT *aParentFP=nullptr) const
 
const IO_BASE::IO_FILE_DESC GetLibraryFileDesc() const override
Get the descriptor for the individual library elements that this IO plugin operates on.
 
FP_CACHE * m_cache
Footprint library cache.
 
void formatBoardLayers(const BOARD *aBoard) const
formats the board layer information
 
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PC...
 
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
 
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Check for the existence of a footprint.
 
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
 
void format(const BOARD *aBoard) const
 
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
 
void formatLayers(LSET aLayerMask, bool aEnumerateLayers, bool aIsZone=false) const
 
void formatGeneral(const BOARD *aBoard) const
formats the General section of the file
 
void SetQueryUserCallback(std::function< bool(wxString aTitle, int aIcon, wxString aMessage, wxString aOKButtonTitle)> aCallback) override
 
void formatSetup(const BOARD *aBoard) const
formats the board setup information
 
wxString m_filename
for saves only, name is in m_reader for loads
 
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> m_queryUserCallback
 
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
 
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
 
void init(const std::map< std::string, UTF8 > *aProperties)
 
void Format(const BOARD_ITEM *aItem) const
Output aItem to aFormatter in s-expression format.
 
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
 
void formatHeader(const BOARD *aBoard) const
writes everything that comes before the board_items, like settings and layers etc
 
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const std::map< std::string, UTF8 > *aProperties, bool checkModified)
 
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
 
PCB_IO_KICAD_SEXPR(int aControlFlags=CTL_FOR_BOARD)
 
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
 
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
 
virtual ~PCB_IO_KICAD_SEXPR()
 
std::string GetStringOutput(bool doClear)
 
void formatRenderCache(const EDA_TEXT *aText) const
 
LINE_READER * m_reader
no ownership
 
wxString m_error
for throwing exceptions
 
PCB_IO(const wxString &aName)
 
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
 
Object to handle a bitmap image that can be inserted in a PCB.
 
A progress reporter interface for use in multi-threaded environments.
 
Container for project specific data.
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
 
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
 
A wrapper around a wxFileName which is much more performant with a subset of the API.
 
Handle a list of polygons defining a copper zone.
 
PCB_LAYER_ID
A quick note on layer IDs:
 
#define CTL_FOR_BOARD
The zero arg constructor when PCB_PLUGIN is used for PLUGIN::Load() and PLUGIN::Save()ing a BOARD fil...
 
Container that describes file type info.
 
Class ZONE_SETTINGS used to handle zones parameters in dialogs.