KiCad PCB EDA Suite
Loading...
Searching...
No Matches
richio.cpp File Reference
#include <cstdarg>
#include <config.h>
#include <kiplatform/io.h>
#include <core/ignore.h>
#include <richio.h>
#include <errno.h>
#include <io/kicad/kicad_io_utils.h>
#include <wx/file.h>
#include <wx/translation.h>

Go to the source code of this file.

Macros

#define getc_unlocked   getc
 
#define NESTWIDTH   2
 

Functions

static int vprint (std::string *result, const char *format, va_list ap)
 
int StrPrintf (std::string *result, const char *format,...)
 This is like sprintf() but the output is appended to a std::string instead of to a character array.
 
std::string StrPrintf (const char *format,...)
 This is like sprintf() but the output is returned in a std::string instead of to a character array.
 
wxString SafeReadFile (const wxString &aFilePath, const wxString &aReadType)
 Nominally opens a file and reads it into a string.
 

Macro Definition Documentation

◆ getc_unlocked

#define getc_unlocked   getc

Definition at line 45 of file richio.cpp.

◆ NESTWIDTH

#define NESTWIDTH   2

Function Documentation

◆ SafeReadFile()

wxString SafeReadFile ( const wxString &  aFilePath,
const wxString &  aReadType 
)

Nominally opens a file and reads it into a string.

But unlike other facilities, this handles mis-encded Wine-written files on macOS.

Parameters
aFilePath
aReadType
Exceptions
IO_ERRORif the file can't be opened
Returns
the file contents

Definition at line 93 of file richio.cpp.

References _, LINE_READER::Line(), FILE_LINE_READER::ReadLine(), and THROW_IO_ERROR.

Referenced by LTSPICE_SCHEMATIC::Load(), SPICE_LIBRARY_PARSER::parseFile(), LTSPICE_SCHEMATIC::ReadAsyFile(), LTSPICE_SCHEMATIC::ReadAsyFiles(), and SPICE_LIBRARY_PARSER::readFallbacks().

◆ StrPrintf() [1/2]

std::string StrPrintf ( const char *  format,
  ... 
)

This is like sprintf() but the output is returned in a std::string instead of to a character array.

Parameters
formatis a printf() style format string.
Returns
std::string - the result of the sprintf().

Definition at line 80 of file richio.cpp.

References ignore_unused(), and vprint().

◆ StrPrintf() [2/2]

int StrPrintf ( std::string *  aResult,
const char *  aFormat,
  ... 
)

This is like sprintf() but the output is appended to a std::string instead of to a character array.

Parameters
aResultis the string to append to, previous text is not clear()ed.
aFormatis a printf() style format string.
Returns
the count of bytes appended to the result string, no terminating nul is included.

Definition at line 68 of file richio.cpp.

References vprint().

Referenced by BOOST_AUTO_TEST_CASE(), fmt_mask(), PCB_IO_KICAD_SEXPR::format(), FormatProbeItem(), GenCADLayerName(), GenCADLayerNameFlipped(), PCB_IO_KICAD_SEXPR_PARSER::init(), GENDRILL_WRITER_BASE::layerName(), PCB_EDIT_FRAME::OpenProjectFiles(), ReplaceIllegalFileNameChars(), SCH_EDIT_FRAME::SendCrossProbeNetName(), PCB_EDIT_FRAME::SendCrossProbeNetName(), and SCH_EDIT_FRAME::SetCrossProbeConnection().

◆ vprint()

static int vprint ( std::string *  result,
const char *  format,
va_list  ap 
)
static

Definition at line 50 of file richio.cpp.

Referenced by StrPrintf().