XPMP2
X-Plane multiplayer library 2 - using instancing
Namespaces | Macros | Functions | Variables
Utilities.cpp File Reference

Miscellaneous utility functions, including logging. More...

#include "XPMP2.h"

Namespaces

 XPMP2
 

Macros

#define S_ISDIR(m)   (((m) & _S_IFMT) == _S_IFDIR)
 

Functions

ThreeWaySwitchTy XPMP2::Read3WaySwitch (std::string &sVal, const std::string &sKey, const std::string &cfgFileName, ThreeWaySwitchTy defVal)
 Convert strings on, auto, off to enums of type ThreeWaySwitchTy More...
 
int XPMP2::PrefsFuncIntDefault (const char *, const char *, int _default)
 Default config function just always returns the provided default value. More...
 
bool XPMP2::ExistsFile (const std::string &filename)
 Does a file path exist? More...
 
bool XPMP2::IsDir (const std::string &path)
 Is path a directory? More...
 
bool XPMP2::CreateDir (const std::string &path)
 Create directory if it does not exist. More...
 
bool XPMP2::CopyFileIfNewer (const std::string &source, const std::string &destDir)
 Copy file if source is newer or destination missing. More...
 
std::list< std::string > XPMP2::GetDirContents (const std::string &path)
 List of files in a directory (wrapper around XPLMGetDirectoryContents) More...
 
std::istream & XPMP2::safeGetline (std::istream &is, std::string &t)
 Read a line from a text file, no matter if ending on CRLF or LF. More...
 
const std::string & XPMP2::GetXPSystemPath ()
 Returns XP's system directory, including a trailing slash. More...
 
std::string XPMP2::StripXPSysDir (const std::string &path)
 If a path starts with X-Plane's system directory it is stripped. More...
 
void XPMP2::RemoveExtension (std::string &path)
 Removes everything after the last dot, the dot including. More...
 
std::string & XPMP2::str_tolower (std::string &s)
 change a std::string to uppercase More...
 
std::vector< std::string > XPMP2::str_tokenize (const std::string s, const std::string tokens, bool bSkipEmpty=true)
 separates string into tokens More...
 
std::uint16_t XPMP2::PJWHash16 (const char *s)
 Produces a reproducible(!) hash value for strings. More...
 
float XPMP2::headDiff (float head1, float head2)
 (Shortest) difference between 2 angles: How much to turn to go from h1 to h2? More...
 
std::valarray< float > XPMP2::HeadPitch2Vec (const float head, const float pitch)
 Convert heading/pitch to normalized x/y/z vector. More...
 
std::valarray< float > XPMP2::HeadPitchRoll2Normal (const float head, const float pitch, const float roll)
 Convert heading/pitch/roll to unit and normal vector, ie. returns 6 values, first 3 like HeadPitch2Vec, second three the normal vector (pointing "up") More...
 
float XPMP2::GetMiscNetwTime ()
 Get synched network time from X-Plane (sim/network/misc/network_time_sec) as used in Log.txt. More...
 
std::string XPMP2::GetMiscNetwTimeStr (float _time=NAN)
 Return the network time as a string like used in the XP's Log.txt. More...
 
const char * XPMP2::GetGraphicsDriverTxt ()
 Text string for current graphics driver in use. More...
 
bool XPMP2::IsPaused ()
 X-Plane in a Pause state? More...
 
bool XPMP2::IsViewExternal ()
 Is current X-Plane view an external view (outside a cockpit)? More...
 
bool XPMP2::CheckEverySoOften (float &_lastCheck, float _interval, float _now)
 Convenience function to check on something at most every x seconds. More...
 
const char * XPMP2::LogGetString (const char *szFile, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg, va_list args)
 Returns ptr to static buffer filled with formatted log string. More...
 
void XPMP2::LogMsg (const char *szFile, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...) XPMP2_FMTARGS(5)
 Log Text to log file. More...
 

Variables

GlobVars XPMP2::glob
 The one and only global variable structure. More...
 
const char * XPMP2::LOG_LEVEL []
 

Detailed Description

Miscellaneous utility functions, including logging.

Author
Birger Hoppe

Macro Definition Documentation

◆ S_ISDIR

#define S_ISDIR (   m)    (((m) & _S_IFMT) == _S_IFDIR)