KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_io_utils.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <optional>
23
24#include <wx/buffer.h>
25#include <wx/stream.h>
26#include <wx/string.h>
27
28#include <kicommon.h>
29
30class OUTPUTFORMATTER;
31class EDA_ITEM;
32class KIID;
33
34class wxMemoryBuffer;
35
36namespace KICAD_FORMAT {
37
45KICOMMON_API void FormatBool( OUTPUTFORMATTER* aOut, const wxString& aKey, bool aValue );
46
56KICOMMON_API void FormatOptBool( OUTPUTFORMATTER* aOut, const wxString& aKey,
57 std::optional<bool> aValue );
58
59KICOMMON_API void FormatUuid( OUTPUTFORMATTER* aOut, const KIID& aUuid );
60
67KICOMMON_API void FormatCustomProperties( OUTPUTFORMATTER* aOut, const EDA_ITEM& aItem );
68
72KICOMMON_API void FormatStreamData( OUTPUTFORMATTER& aOut, const wxStreamBuffer& aStream );
73
77enum class KICOMMON_API FORMAT_MODE
78{
82};
83
106KICOMMON_API void Prettify( std::string& aSource, FORMAT_MODE aMode = FORMAT_MODE::NORMAL );
107
108} // namespace KICAD_FORMAT
109
110
118KICOMMON_API bool LoadFileToMemory( const wxString& aFileName, wxMemoryBuffer& aBuffer );
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
Definition kiid.h:46
An interface used to output 8 bit text in a convenient way.
Definition richio.h:294
COMPACT_TEXT_PROPERTIES
Collapses certain text properties to single-line.
NORMAL
Follows standard pretty-printing rules.
KICOMMON_API bool LoadFileToMemory(const wxString &aFileName, wxMemoryBuffer &aBuffer)
Load the contents of a file into a memory buffer.
#define KICOMMON_API
Definition kicommon.h:27
void FormatCustomProperties(OUTPUTFORMATTER *aOut, const EDA_ITEM &aItem)
Writes the item's custom properties as a series of (custom_property "key" "value")
void FormatOptBool(OUTPUTFORMATTER *aOut, const wxString &aKey, std::optional< bool > aValue)
Writes an optional boolean to the formatter.
void Prettify(std::string &aSource, FORMAT_MODE aMode)
Pretty-prints s-expression text according to KiCad format rules.
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 FormatBool(OUTPUTFORMATTER *aOut, const wxString &aKey, bool aValue)
Writes a boolean to the formatter, in the style (aKey [yes|no])