libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros | Functions
os.hpp File Reference
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <csignal>
#include <type_traits>
#include <qi/api.hpp>
#include <qi/types.hpp>
#include <qi/path.hpp>
#include <qi/clock.hpp>
#include <qi/uuid.hpp>
#include <qi/ptruid.hpp>
#include <boost/lexical_cast.hpp>

Go to the source code of this file.

Classes

struct  qi::os::timeval
 struct similar to POSIX timeval More...
 
class  qi::os::ScopedThreadName
 Set the current thread name and restore it after use. More...
 

Namespaces

 qi
 Deprecated in 2.5. Use int8_t from <cstdint>.
 
 qi::os
 OS abstraction layer. .
 

Macros

#define _QI_OS_HPP_
 
#define PTRDIFF_MIN   -2147483648
 
#define PTRDIFF_MAX   2147483647
 

Functions

FILE * qi::os::fopen (const char *filename, const char *mode)
 Open a file and returns and handle on it. More...
 
int qi::os::stat (const char *filename, struct stat *pstat)
 Get file status. More...
 
int qi::os::checkdbg ()
 Check if the current process is running into a debugger. More...
 
std::string qi::os::home ()
 Return path to the current user's HOME. More...
 
std::string qi::os::mktmpdir (const char *prefix="")
 Return a writable temporary directory. More...
 
std::string qi::os::tmp ()
 Return the system's temporary directory. More...
 
void qi::os::symlink (const qi::Path &source, const qi::Path &destination)
 Create a symlink from source to destination. More...
 
std::string qi::os::gethostname ()
 Get the system's hostname. More...
 
int qi::os::isatty (int fd=1)
 Test if descriptor represents a terminal. More...
 
bool qi::os::fnmatch (const std::string &pattern, const std::string &string)
 Implement POSIX compliant fnmatch. More...
 
char * qi::os::strdup (const char *src)
 Implement POSIX compliant strdup. More...
 
int qi::os::snprintf (char *str, size_t size, const char *format,...)
 Implement POSIX compliant snprintf. More...
 
std::string qi::os::getenv (const char *var)
 Get an environment variable. More...
 
std::string qi::os::pathsep ()
 Get the path separator. More...
 
int qi::os::setenv (const char *var, const char *value)
 Change or add an environment variable. More...
 
int qi::os::unsetenv (const char *var)
 Remove an environment variable. More...
 
std::string qi::os::timezone ()
 Return the timezone. More...
 
void qi::os::sleep (unsigned int seconds)
 Sleep for the specified number of seconds. More...
 
void qi::os::msleep (unsigned int milliseconds)
 Sleep for the specified number of milliseconds. More...
 
QI_API_DEPRECATED int qi::os::gettimeofday (qi::os::timeval *tp)
 The gettimeofday() function shall obtain the current time. More...
 
qi::int64_t qi::os::ustime ()
 Elapsed time since program started in microseconds. More...
 
std::pair< int64_t, int64_t > qi::os::cputime ()
 Return CPU time used by the calling thread as a pair (userTime, systemTime) in microseconds. More...
 
qi::os::timeval qi::os::operator+ (const qi::os::timeval &lhs, const qi::os::timeval &rhs)
 Add two timeval together. More...
 
qi::os::timeval qi::os::operator+ (const qi::os::timeval &lhs, long us)
 Add a delay to a timeval (in microsecond) More...
 
qi::os::timeval qi::os::operator- (const qi::os::timeval &lhs, const qi::os::timeval &rhs)
 Substract two timeval together. More...
 
qi::os::timeval qi::os::operator- (const qi::os::timeval &lhs, long us)
 Substract a delay to a timeval (in microsecond) More...
 
void * qi::os::dlopen (const char *filename, int flag=-1)
 Load a dynamic library. More...
 
int qi::os::dlclose (void *handle)
 Decrements the reference count on the dynamic library. More...
 
void * qi::os::dlsym (void *handle, const char *symbol)
 Get the address where the symbol is loaded into memory. More...
 
const char * qi::os::dlerror ()
 Returns a human readable string of the error code. More...
 
int qi::os::spawnvp (char *const argv[])
 Create and execute a new process. More...
 
int qi::os::spawnlp (const char *argv,...)
 Create and execute a new process. More...
 
int qi::os::system (const char *command)
 Execute a shell command. More...
 
int qi::os::getpid ()
 Get the process identifier. More...
 
int qi::os::gettid ()
 Get the thread identifier. More...
 
int qi::os::waitpid (int pid, int *status)
 Wait for process to change state. More...
 
int qi::os::kill (int pid, int sig)
 Send a signal to a process. More...
 
bool qi::os::isProcessRunning (int pid, const std::string &fileName=std::string())
 Check whether a process is running, given its file name and pid. More...
 
unsigned short qi::os::findAvailablePort (unsigned short port)
 Find the first available port starting at port number in parameter. More...
 
std::map< std::string,
std::vector< std::string > > 
qi::os::hostIPAddrs (bool ipv6Addr=false)
 Find all network adapters and corresponding IPs. More...
 
void qi::os::setCurrentThreadName (const std::string &name)
 Set the current thread name to the string in parameter. More...
 
std::string qi::os::currentThreadName ()
 returns the current thread name as a std::string More...
 
bool qi::os::setCurrentThreadCPUAffinity (const std::vector< int > &cpus)
 Set the CPU affinity for the current thread. More...
 
long qi::os::numberOfCPUs ()
 Get the number of CPUs on the local machin. More...
 
std::string qi::os::getMachineId ()
 Returns an unique uuid for the machine. More...
 
const Uuid & qi::os::getMachineIdAsUuid ()
 Same as getMachineId but return a uuid and not its string representation. More...
 
const Uuid & qi::os::getProcessUuid ()
 Returns an unique uuid for the process. More...
 
std::string qi::os::generateUuid ()
 Generate a universally unique identifier. More...
 
size_t qi::os::memoryUsage (unsigned int pid)
 Get the memory usage of a process in kB. More...
 
PtrUid qi::os::ptrUid (void *address)
 
template<typename T >
qi::os::getEnvParam (const char *name, T defaultVal)
 Returns the value of the environment variableif set, the defaultVal otherwise. More...
 
template<typename N >
std::string qi::os::to_string (N n)
 (Arithmetic or Enum) N More...
 

Macro Definition Documentation

#define _QI_OS_HPP_

Definition at line 9 of file os.hpp.

#define PTRDIFF_MAX   2147483647

Definition at line 56 of file os.hpp.

#define PTRDIFF_MIN   -2147483648

Definition at line 48 of file os.hpp.