KiCad PCB EDA Suite
Loading...
Searching...
No Matches
richio.h File Reference
#include <vector>
#include <core/utf8.h>
#include <cstdio>
#include <wx/string.h>
#include <wx/stream.h>
#include <ki_exception.h>
#include <kicommon.h>

Go to the source code of this file.

Classes

class  LINE_READER
 An abstract class from which implementation specific LINE_READERs may be derived to read single lines of text and manage a line number counter. More...
 
class  FILE_LINE_READER
 A LINE_READER that reads from an open file. More...
 
class  STRING_LINE_READER
 Is a LINE_READER that reads from a multiline 8 bit wide std::string. More...
 
class  INPUTSTREAM_LINE_READER
 A LINE_READER that reads from a wxInputStream object. More...
 
class  OUTPUTFORMATTER
 An interface used to output 8 bit text in a convenient way. More...
 
class  STRING_FORMATTER
 Implement an OUTPUTFORMATTER to a memory buffer. More...
 
class  FILE_OUTPUTFORMATTER
 Used for text file output. More...
 
class  PRETTIFIED_FILE_OUTPUTFORMATTER
 

Macros

#define LINE_READER_LINE_DEFAULT_MAX   1000000
 
#define LINE_READER_LINE_INITIAL_SIZE   5000
 
#define OUTPUTFMTBUFZ   500
 default buffer size for any OUTPUT_FORMATTER
 
#define PRINTF_FUNC
 

Functions

KICOMMON_API 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.
 
KICOMMON_API 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.
 
KICOMMON_API wxString SafeReadFile (const wxString &aFilePath, const wxString &aReadType)
 Nominally opens a file and reads it into a string.
 

Macro Definition Documentation

◆ LINE_READER_LINE_DEFAULT_MAX

#define LINE_READER_LINE_DEFAULT_MAX   1000000

Definition at line 85 of file richio.h.

◆ LINE_READER_LINE_INITIAL_SIZE

#define LINE_READER_LINE_INITIAL_SIZE   5000

Definition at line 86 of file richio.h.

◆ OUTPUTFMTBUFZ

#define OUTPUTFMTBUFZ   500

default buffer size for any OUTPUT_FORMATTER

Definition at line 304 of file richio.h.

◆ PRINTF_FUNC

#define PRINTF_FUNC

Definition at line 360 of file richio.h.

Function Documentation

◆ SafeReadFile()

KICOMMON_API 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(), and LTSPICE_SCHEMATIC::ReadAsyFiles().

◆ StrPrintf() [1/2]

KICOMMON_API 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]

KICOMMON_API 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(), 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().