fgms 0.11.8
The
FlightGear MultiPlayer Server
project
fg_util.hxx File Reference
#include <string>
#include <cstdlib>
#include <ctype.h>
#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef long long t_longlong
 

Enumerations

enum  NUMERIC_BASE_LIMITS { MIN_BASE = 2, MAX_BASE = 36 }
 

Functions

std::string byte_counter (double bytes)
 
std::string diff_to_days (time_t date)
 convert a time duration expressed in seconds to a string representation of the form "3 days 2 hours" More...
 
template<typename T >
string NumToStr (T n_Number, int n_Precision=2, int n_Base=10)
 Convert a number to string. More...
 
template<class T >
StrToNum (string str_Number, int &n_Error, int n_Base=10)
 Convert string into a number. More...
 
std::string timestamp_to_datestr (time_t date)
 convert a unix timestamp to a string representation of a date More...
 
std::string timestamp_to_days (time_t date)
 calculate the difference of a timestamp to now and convert the difference to a string representation of the form "3 days 2 hours" More...
 

Detailed Description

Author
Oliver Schroeder

Definition in file fg_util.hxx.

Typedef Documentation

typedef long long t_longlong

Definition at line 21 of file fg_util.hxx.

Enumeration Type Documentation

Enumerator
MIN_BASE 
MAX_BASE 

Definition at line 36 of file fg_util.hxx.

Function Documentation

std::string byte_counter ( double  bytes)

Convert a byte counter to a string representation of the form "3.7 Gib" (3.7 Gigibit). The units conform to IEC, see http://physics.nist.gov/cuu/Units/binary.html

Definition at line 100 of file fg_util.cxx.

Referenced by FG_CLI::cmd_blacklist_show(), FG_CLI::cmd_crossfeed_show(), FG_CLI::cmd_relay_show(), FG_CLI::cmd_show_stats(), FG_CLI::cmd_tracker_show(), and FG_CLI::cmd_user_show().

std::string diff_to_days ( time_t  date)

convert a time duration expressed in seconds to a string representation of the form "3 days 2 hours"

Definition at line 52 of file fg_util.cxx.

Referenced by mT_FG_List< T >::CheckTTL(), mT_FG_List< T >::Find(), and timestamp_to_days().

template<typename T >
string NumToStr ( n_Number,
int  n_Precision = 2,
int  n_Base = 10 
)

Convert a number to string.

Parameters
n_Numberthe number to convert
n_Precisionnumber of digits after the dot
n_Basethe base of the string representation

Definition at line 193 of file fg_util.hxx.

Referenced by byte_counter(), FG_CLI::cmd_blacklist_show(), LIBCLI::Client::count_filter(), diff_to_days(), netAddress::getHost(), FG_SERVER::HandleTelnet(), FG_SERVER::PacketIsValid(), and FG_SERVER::UpdateTracker().

template<class T >
T StrToNum ( string  str_Number,
int &  n_Error,
int  n_Base = 10 
)

Convert string into a number.

Parameters
str_Numberthe string representation of a number
n_Errorif an error (illegal char) occured, n_Error point to the position
n_BaseThe base of the string representation
Returns
  • n_Error -1: empty string
  • n_Error -2: overflow
  • n_Error -3: base out of range
  • n_Error >0: index of non-numeric

Definition at line 61 of file fg_util.hxx.

std::string timestamp_to_datestr ( time_t  date)

convert a unix timestamp to a string representation of a date

Definition at line 11 of file fg_util.cxx.

Referenced by FG_CLI::cmd_blacklist_show(), FG_CLI::cmd_crossfeed_show(), FG_CLI::cmd_relay_show(), FG_CLI::cmd_show_uptime(), FG_CLI::cmd_tracker_show(), and FG_CLI::cmd_user_show().

std::string timestamp_to_days ( time_t  date)

calculate the difference of a timestamp to now and convert the difference to a string representation of the form "3 days 2 hours"

Definition at line 36 of file fg_util.cxx.

Referenced by FG_CLI::cmd_blacklist_show(), FG_CLI::cmd_crossfeed_show(), FG_CLI::cmd_show_uptime(), FG_CLI::cmd_tracker_show(), and FG_CLI::cmd_user_show().