XPPlanes
X-Plane plugin to display additional planes based on network data
|
Miscellaneous utility functions, including logging. More...
#include "XPPlanes.h"
Macros | |
#define | PATH_DELIM_STD '/' |
Functions | |
float | GetMiscNetwTime () |
Get synched network time from X-Plane (sim/network/misc/network_time_sec) as used in Log.txt. More... | |
bool | CheckEverySoOften (float &_lastCheck, float _interval, float _now) |
Convenience function to check on something at most every x seconds. More... | |
std::string | GetPluginName (XPLMPluginID who) |
Return a plugin's name. More... | |
std::istream & | safeGetline (std::istream &is, std::string &t) |
Read a text line, handling both Windows (CRLF) and Unix (LF) ending. More... | |
float | HeadDiff (float from, float to) |
Return shortest turn from one heading to the other. More... | |
float | RpmToAngle (float angle, float rpm, float s) |
Rotation: Computes new rotation angle based on current + revolution in a (small) amount of time. More... | |
std::string | str_n (const char *s, size_t max) |
Copy at most n chars from location, or less if zero-terminated. More... | |
std::vector< std::string > | str_tokenize (const std::string &s, const std::string &tokens, bool bSkipEmpty) |
separates string into tokens More... | |
std::pair< std::string, std::string > | str_split (const std::string &s, const std::string &tokens) |
Split the string at the first of the tokens and return the two pieces. More... | |
const char * | LogGetString (const char *szPath, 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 | LogMsg (const char *szPath, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...) |
Log Text to log file. More... | |
Variables | |
const char * | LOG_LEVEL [] |
Miscellaneous utility functions, including logging.
#define PATH_DELIM_STD '/' |
bool CheckEverySoOften | ( | float & | _lastCheck, |
float | _interval, | ||
float | _now | ||
) |
Convenience function to check on something at most every x seconds.
_lastCheck | Provide a float which holds the time of last check (init with 0.0f ) |
_interval | [seconds] How often to perform the check? |
_now | Current time, possibly from a call to GetTotalRunningTime() |
true
if more than _interval
time has passed since _lastCheck
float GetMiscNetwTime | ( | ) |
Get synched network time from X-Plane (sim/network/misc/network_time_sec) as used in Log.txt.
std::string GetPluginName | ( | XPLMPluginID | who | ) |
Return a plugin's name.
float HeadDiff | ( | float | from, |
float | to | ||
) |
Return shortest turn from one heading to the other.
const char* LogGetString | ( | const char * | szPath, |
int | ln, | ||
const char * | szFunc, | ||
logLevelTy | lvl, | ||
const char * | szMsg, | ||
va_list | args | ||
) |
Returns ptr to static buffer filled with formatted log string.
void LogMsg | ( | const char * | szPath, |
int | ln, | ||
const char * | szFunc, | ||
logLevelTy | lvl, | ||
const char * | szMsg, | ||
... | |||
) |
Log Text to log file.
float RpmToAngle | ( | float | angle, |
float | rpm, | ||
float | s | ||
) |
Rotation: Computes new rotation angle based on current + revolution in a (small) amount of time.
angle | Last rotation angle as basis |
rpm | Rotation speed in revolutions per minute |
s | Timeframe to consider in seconds |
std::istream& safeGetline | ( | std::istream & | is, |
std::string & | t | ||
) |
Read a text line, handling both Windows (CRLF) and Unix (LF) ending.
Code makes use of the fact that in both cases LF is the terminal character. So we read from file until LF (without widening!). In case of CRLF files there then is a trailing CR, which we just remove.
std::string str_n | ( | const char * | s, |
size_t | max | ||
) |
Copy at most n
chars from location, or less if zero-terminated.
Unlike std::string(char*, n) this will not copy null chars
std::pair<std::string,std::string> str_split | ( | const std::string & | s, |
const std::string & | tokens | ||
) |
Split the string at the first of the tokens and return the two pieces.
std::vector<std::string> str_tokenize | ( | const std::string & | s, |
const std::string & | tokens, | ||
bool | bSkipEmpty | ||
) |
separates string into tokens
const char* LOG_LEVEL[] |