KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KICAD_FORMAT Namespace Reference

Functions

void FormatBool (OUTPUTFORMATTER *aOut, const wxString &aKey, bool aValue)
 Writes a boolean to the formatter, in the style (aKey [yes|no])
 
void FormatOptBool (OUTPUTFORMATTER *aOut, const wxString &aKey, std::optional< bool > aValue)
 Writes an optional boolean to the formatter.
 
void FormatUuid (OUTPUTFORMATTER *aOut, const KIID &aUuid)
 
void FormatCustomProperties (OUTPUTFORMATTER *aOut, const EDA_ITEM &aItem)
 Writes the item's custom properties as a series of (custom_property "key" "value")
 
void FormatStreamData (OUTPUTFORMATTER &aOut, const wxStreamBuffer &aStream)
 Write binary data to the formatter as base 64 encoded string.
 
void Prettify (std::string &aSource, FORMAT_MODE aMode=FORMAT_MODE::NORMAL)
 Pretty-prints s-expression text according to KiCad format rules.
 

Function Documentation

◆ FormatBool()

KICOMMON_API void KICAD_FORMAT::FormatBool ( OUTPUTFORMATTER * aOut,
const wxString & aKey,
bool aValue )

Writes a boolean to the formatter, in the style (aKey [yes|no])

Parameters
aOutis the output formatter to write to
aKeyis the name of the boolean flag
aValueis the value to write

Definition at line 39 of file kicad_io_utils.cpp.

References OUTPUTFORMATTER::Print().

Referenced by EDA_TEXT::Format(), PCB_PLOT_PARAMS::Format(), SCH_IO_KICAD_SEXPR::Format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), formatArc(), formatBezier(), BOARD_STACKUP::FormatBoardStackup(), formatCircle(), PCB_IO_KICAD_SEXPR::formatDrillSymbolProfile(), formatEllipse(), formatEllipseArc(), PCB_IO_KICAD_SEXPR::formatGeneral(), FormatOptBool(), formatPoly(), formatRect(), PCB_IO_KICAD_SEXPR::formatSetup(), PCB_IO_KICAD_SEXPR::formatTableData(), PCB_IO_KICAD_SEXPR::formatTeardropParameters(), SCH_IO_KICAD_SEXPR::saveBitmap(), SCH_IO_KICAD_SEXPR::saveBusEntry(), SCH_IO_KICAD_SEXPR::saveField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField(), SCH_IO_KICAD_SEXPR::saveGroup(), SCH_IO_KICAD_SEXPR::saveJunction(), SCH_IO_KICAD_SEXPR::saveLine(), SCH_IO_KICAD_SEXPR::saveNoConnect(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin(), SCH_IO_KICAD_SEXPR::saveRuleArea(), SCH_IO_KICAD_SEXPR::saveSheet(), SCH_IO_KICAD_SEXPR_LIB_CACHE::SaveSymbol(), SCH_IO_KICAD_SEXPR::saveSymbol(), SCH_IO_KICAD_SEXPR::saveTable(), SCH_IO_KICAD_SEXPR::saveText(), and SCH_IO_KICAD_SEXPR::saveTextBox().

◆ FormatCustomProperties()

KICOMMON_API void KICAD_FORMAT::FormatCustomProperties ( OUTPUTFORMATTER * aOut,
const EDA_ITEM & aItem )

Writes the item's custom properties as a series of (custom_property "key" "value")

Parameters
aOutis the output formatter to write to
aItemis the item to write properties of

Definition at line 59 of file kicad_io_utils.cpp.

References EDA_ITEM::GetCustomProperties(), EDA_ITEM::HasCustomProperties(), OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

Referenced by PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::format(), PCB_IO_KICAD_SEXPR::formatTableData(), SCH_IO_KICAD_SEXPR::saveBitmap(), SCH_IO_KICAD_SEXPR::saveBusEntry(), SCH_IO_KICAD_SEXPR::saveField(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveField(), SCH_IO_KICAD_SEXPR::saveGroup(), SCH_IO_KICAD_SEXPR::saveJunction(), SCH_IO_KICAD_SEXPR::saveLine(), SCH_IO_KICAD_SEXPR::saveNoConnect(), SCH_IO_KICAD_SEXPR_LIB_CACHE::savePin(), SCH_IO_KICAD_SEXPR::saveRuleArea(), SCH_IO_KICAD_SEXPR::saveSheet(), SCH_IO_KICAD_SEXPR::saveSymbol(), SCH_IO_KICAD_SEXPR::saveTable(), SCH_IO_KICAD_SEXPR::saveText(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveText(), SCH_IO_KICAD_SEXPR::saveTextBox(), and SCH_IO_KICAD_SEXPR_LIB_CACHE::saveTextBox().

◆ FormatOptBool()

KICOMMON_API void KICAD_FORMAT::FormatOptBool ( OUTPUTFORMATTER * aOut,
const wxString & aKey,
std::optional< bool > aValue )

Writes an optional boolean to the formatter.

If a value is present, calls FormatBool. If no value is present, Writes (aKey none).

Parameters
aOutis the output formatter to write to
aKeyis the name of the boolean flag
aValueis the value to write

Definition at line 44 of file kicad_io_utils.cpp.

References FormatBool(), and OUTPUTFORMATTER::Print().

Referenced by PCB_IO_KICAD_SEXPR::format(), and PCB_IO_KICAD_SEXPR::format().

◆ FormatStreamData()

KICOMMON_API void KICAD_FORMAT::FormatStreamData ( OUTPUTFORMATTER & aOut,
const wxStreamBuffer & aStream )

Write binary data to the formatter as base 64 encoded string.

Definition at line 69 of file kicad_io_utils.cpp.

References MIME_BASE64_LENGTH, OUTPUTFORMATTER::Print(), and TO_UTF8.

Referenced by BOOST_AUTO_TEST_CASE(), DS_DATA_MODEL_IO::format(), PCB_IO_KICAD_SEXPR::format(), and SCH_IO_KICAD_SEXPR::saveBitmap().

◆ FormatUuid()

◆ Prettify()

KICOMMON_API void KICAD_FORMAT::Prettify ( std::string & aSource,
FORMAT_MODE aMode = FORMAT_MODE::NORMAL )

Pretty-prints s-expression text according to KiCad format rules.

Formatting rules:

  • All extra (non-indentation) whitespace is trimmed
  • Indentation is one tab
  • Starting a new list (open paren) starts a new line with one deeper indentation
  • Lists with no inner lists go on a single line
  • End of multi-line lists (close paren) goes on a single line at same indentation as its start

For example: (first (second (third list) (another list) ) (fifth) (sixth thing with lots of tokens (and a sub list) ) )

Definition at line 111 of file kicad_io_utils.cpp.

References cursor, and next().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), LOCAL_HISTORY::commitInBackground(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), SYMBOL_EDIT_FRAME::CopySymbolToClipboard(), BITMAPCONV_INFO::createDrawingSheetData(), SCH_EDITOR_CONTROL::doCopy(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), PRETTIFIED_FILE_OUTPUTFORMATTER::Finish(), XNODE::Format(), API_HANDLER_SCH::handleSaveDocumentToString(), API_HANDLER_SCH::handleSaveSelectionToString(), LOCAL_HISTORY::RunRegisteredSaversAsAutosaveFiles(), CLIPBOARD_IO::SaveBoard(), and CLIPBOARD_IO::SaveSelection().