62 aOut->
Print(
"(%ls %s)", aKey.wc_str(), aValue ?
"yes" :
"no" );
68 if( aValue.has_value() )
71 aOut->
Print(
"(%ls none)", aKey.wc_str() );
98 aOut.
Print(
"(data" );
99 const wxString encoded = wxBase64Encode( aStream.GetBufferStart(), aStream.GetBufferSize() );
101 for(
size_t first = 0; first < encoded.Length(); first += 76 )
102 aOut.
Print(
"\n\"%s\"",
TO_UTF8( encoded( first, 76 ) ) );
120 THROW_IO_ERROR( wxT(
"Unreviewed line style in a frozen writer." ) );
127 const auto color = aStroke.
GetColor();
131 aOut->
Print(
"(stroke (width %s) (type %s))",
137 aOut->
Print(
"(stroke (width %s) (type %s) (color %d %d %d %s))",
167 THROW_IO_ERROR( wxT(
"Unreviewed paper type in a frozen writer." ) );
179 aOut->
Print(
" portrait" );
196 aOut->
Print(
" portrait" );
207 for(
int ii = 0; ii < 9; ++ii )
213 aOut->
Print(
"(title_block" );
218 if( !aTitle.
GetDate().IsEmpty() )
227 for(
int ii = 0; ii < 9; ++ii )
240 aOut->
Print(
"(effects(font" );
265 aOut->
Print(
"(color %d %d %d %s)",
KiROUND( color.r * 255.0 ),
KiROUND( color.g * 255.0 ),
274 aOut->
Print(
"(justify" );
283 aOut->
Print(
" mirror" );
291 if( !( aControlBits & ( 1 << 12 ) ) && aText.
HasHyperlink() )
300 FormatText( aOut, aText, aScale, aControlBits,
true );
306 FormatText( aOut, aText, aScale, aControlBits,
false );
318 if( payload->empty() )
324 THROW_IO_ERROR( wxT(
"Cannot decode embedded file for an older KiCad version: " ) + aFile.
name );
331 hash.
addDataV1(
reinterpret_cast<const uint8_t*
>( payload->data() ), payload->size() );
338 aOut.
Print(
"(embedded_files " );
342 const auto& file = *entry;
344 if( !aV9 && file.compressedEncodedData.empty() )
348 if( aV9 && aWriteData && file.compressedEncodedData.empty() )
349 THROW_IO_ERROR( wxT(
"Empty embedded file data cannot be written for KiCad 9." ) );
351 const char* type =
nullptr;
360 default:
THROW_IO_ERROR( wxT(
"Unreviewed embedded file type in a frozen writer." ) );
364 aOut.
Print(
"(file (name %s)(type %s)", aOut.
Quotew( file.name ).c_str(), type );
368 aOut.
Print(
"(data" );
370 for(
size_t first = 0; first < file.compressedEncodedData.length(); first += 76 )
372 const size_t remaining = file.compressedEncodedData.length() - first;
373 const int length =
static_cast<int>( std::min<size_t>( remaining, 76 ) );
374 aOut.
Print(
"\n%1s%.*s%s\n", first ?
"" :
"|", length, file.compressedEncodedData.data() + first,
375 remaining ==
size_t( length ) ?
"|" :
"" );
381 aOut.
Print(
"(checksum %s))", aOut.
Quotew( checksum ).c_str() );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
COLOR4D GetTextColor() const
wxString GetFontName() const
bool IsMultilineAllowed() const
virtual bool IsVisible() const
virtual int GetTextHeight() const
KIFONT::FONT * GetFont() const
virtual bool HasHyperlink() const
wxString GetHyperlink() const
virtual int GetTextWidth() const
GR_TEXT_H_ALIGN_T GetHorizJustify() const
bool GetAutoThickness() const
double GetLineSpacing() const
GR_TEXT_V_ALIGN_T GetVertJustify() const
virtual int GetTextThickness() const
static RETURN_CODE DecompressAndDecode(EMBEDDED_FILE &aFile, bool aAllowEmptyHash=false)
Takes data from the compressedEncodedData buffer and Base64 decodes it.
const std::map< wxString, std::shared_ptr< EMBEDDED_FILE > > & EmbeddedFileMap() const
Provide an iterable view of the file collection.
const wxString & GetName() const
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
wxString AsString() const
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
A streaming C++ equivalent for MurmurHash3_x64_128.
FORCE_INLINE void addDataV1(const uint8_t *data, size_t length)
FORCE_INLINE HASH_128 digest()
Describe the page size and margins of a paper page on which to eventually print or plot.
double GetHeightMils() const
double GetWidthMils() const
const PAGE_SIZE_TYPE & GetType() const
Simple container to manage line stroke parameters.
LINE_STYLE GetLineStyle() const
KIGFX::COLOR4D GetColor() const
Hold the information shown in the lower right corner of a plot, printout, or editing view.
const wxString & GetCompany() const
const wxString & GetRevision() const
const wxString & GetDate() const
const wxString & GetComment(int aIdx) const
const wxString & GetTitle() const
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
static bool empty(const wxTextEntryBase *aCtrl)
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue, EDA_DATA_TYPE aDataType=EDA_DATA_TYPE::DISTANCE)
Converts aValue from internal units to a string appropriate for writing to file.
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
LINE_STYLE
Dashed line types.
std::vector< char > decompressedData
std::string compressedEncodedData
std::string ToString() const
wxString result
Test unit parsing edge cases and error handling.