Ipelib
Public Types | Static Public Member Functions | List of all members
ipe::Platform Class Reference

#include <ipebase.h>

Public Types

using DebugHandler = void(*)(const char *)
 

Static Public Member Functions

static String folder (IpeFolder ft, const char *fname=nullptr)
 
static FILE * fopen (const char *fname, const char *mode)
 
static int mkdir (String path)
 
static int mkdirTree (String path)
 
static String ipeDrive ()
 
static int libVersion ()
 
static void initLib (int version)
 
static void setDebug (bool debug)
 
static String currentDirectory ()
 
static String latexPath ()
 
static bool fileExists (String fname)
 
static bool listDirectory (String path, std::vector< String > &files)
 
static String realPath (String fname)
 
static String readFile (String fname)
 
static String howToRunLatex (LatexType engine, String docname) noexcept
 
static int system (String cmd)
 
static String createTarball (String tex)
 
static double toDouble (String s)
 
static int toNumber (String s, int &iValue, double &dValue)
 
static String spiroVersion ()
 
static String gslVersion ()
 
static std::pair< int, std::vector< const char * > > setupNodeJs ()
 

Detailed Description

Platform dependent methods.

Member Typedef Documentation

◆ DebugHandler

using ipe::Platform::DebugHandler = void (*)(const char *)

Member Function Documentation

◆ folder()

String Platform::folder ( IpeFolder  ft,
const char *  fname = nullptr 
)
static

◆ fopen()

FILE * Platform::fopen ( const char *  fname,
const char *  mode 
)
static

◆ mkdir()

int Platform::mkdir ( String  path)
static

References ipe::String::z().

Referenced by mkdirTree().

◆ mkdirTree()

int Platform::mkdirTree ( String  path)
static

◆ ipeDrive()

String Platform::ipeDrive ( )
static

Returns drive on which Ipe executable exists.

On Linux and OSX, returns empty string.

Referenced by latexPath().

◆ libVersion()

int Platform::libVersion ( )
static

Return the Ipelib version.

This is available as a function so that one can verify what version of Ipelib one has actually linked with (as opposed to the header files used during compilation).

References ipe::IPELIB_VERSION.

◆ initLib()

void Platform::initLib ( int  version)
static

Initialize Ipelib.

This method must be called before Ipelib is used.

It creates a LC_NUMERIC locale set to 'C', which is necessary for correct loading and saving of Ipe objects. The method also checks that the correct version of Ipelib is loaded, and aborts with an error message if the version is not correct. Also enables ipeDebug messages if environment variable IPEDEBUG is defined. (You can override this using setDebug).

References ipe::IPELIB_VERSION.

◆ setDebug()

void Platform::setDebug ( bool  debug)
static

Enable or disable display of ipeDebug messages.

◆ currentDirectory()

String Platform::currentDirectory ( )
static

Returns current working directory.

Returns empty string if something fails.

◆ latexPath()

String Platform::latexPath ( )
static

Return path for the directory containing pdflatex and xelatex.

If empty means look on PATH.

References ipeDrive(), ipe::String::left(), and ipe::String::substr().

◆ fileExists()

bool Platform::fileExists ( String  fname)
static

Determine whether file exists.

References ipe::String::data(), ipe::String::hasPrefix(), and ipe::String::z().

Referenced by mkdirTree().

◆ listDirectory()

bool Platform::listDirectory ( String  path,
std::vector< String > &  files 
)
static

List all files in directory.

Return true if successful, false on error.

References ipe::String::data(), and ipe::String::z().

◆ realPath()

String Platform::realPath ( String  fname)
static

Convert relative filename to absolute.

This also works when the filename does not exist, or at least it tries.

References ipe::String::data(), ipe::String::left(), and ipe::String::z().

◆ readFile()

String Platform::readFile ( String  fname)
static

Read entire file into string.

Returns an empty string if file cannot be found or read. There is no way to distinguish an empty file from this.

References ipe::String::append(), fopen(), and ipe::String::z().

Referenced by ipe::Document::completeLatexRun(), howToRunLatex(), and ipe::Bitmap::readJpeg().

◆ howToRunLatex()

String Platform::howToRunLatex ( LatexType  engine,
String  docname 
)
staticnoexcept

Returns command to run latex on file ipetemp.tex in given directory.

directory of docname is added to TEXINPUTS if its non-empty.

References ipe::String::data(), ipe::String::empty(), ipe::FolderConfig, ipe::FolderLatex, ipe::FolderLua, fopen(), ipe::IPESEP, ipe::String::left(), ipe::Luatex, readFile(), ipe::String::size(), ipe::String::substr(), ipe::Xetex, and ipe::String::z().

Referenced by ipe::Document::runLatex().

◆ system()

int Platform::system ( String  cmd)
static

References ipe::String::z().

Referenced by ipe::Document::runLatex().

◆ createTarball()

String Platform::createTarball ( String  tex)
static

◆ toDouble()

double Platform::toDouble ( String  s)
static

◆ toNumber()

int Platform::toNumber ( String  s,
int &  iValue,
double &  dValue 
)
static

References ipe::String::z().

◆ spiroVersion()

String Platform::spiroVersion ( )
static

◆ gslVersion()

String Platform::gslVersion ( )
static

◆ setupNodeJs()

static std::pair< int, std::vector< const char * > > ipe::Platform::setupNodeJs ( )
static

The documentation for this class was generated from the following files: