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 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()

◆ 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 40 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 55 of file kicad_io_utils.cpp.

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

Referenced by 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 97 of file kicad_io_utils.cpp.

References cursor, and next().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), SYMBOL_EDIT_FRAME::CopySymbolToClipboard(), SCH_EDITOR_CONTROL::doCopy(), FOOTPRINT_EDIT_FRAME::ExportFootprint(), PRETTIFIED_FILE_OUTPUTFORMATTER::Finish(), XNODE::Format(), CLIPBOARD_IO::SaveBoard(), and CLIPBOARD_IO::SaveSelection().