]> git.lyx.org Git - lyx.git/blob - src/support/lyxlib.h
74abd7fefa210aae7995cd1277047ff078470ca4
[lyx.git] / src / support / lyxlib.h
1 // -*- C++ -*-
2 /**
3  * \file lyxlib.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * A selection of useful system functions made
8  * handy for C++ usage.
9  *
10  * \author Lars Gullik Bjønnes
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef LYX_LIB_H
16 #define LYX_LIB_H
17
18 #include "support/FileName.h"
19
20 #include <string>
21
22
23 namespace lyx {
24 namespace support {
25
26 /// get the current working directory
27 FileName const getcwd();
28
29 /// FIXME: some point to this hmm ?
30 int kill(int pid, int sig);
31 /// FIXME: same here
32 void abort();
33
34 /// (securely) create a temporary file in the given dir with the given mask
35 /// \p mask must be in filesystem encoding
36 FileName const tempName(FileName const & dir = FileName(),
37                       std::string const & mask = std::string());
38
39
40 /**
41  * Returns true if var is approximately equal to number with allowed error
42  * of 'error'.
43  *
44  * Usage: if (float_equal(var, number, 0.0001)) { }
45  *
46  * This will check if 'var' is approx. equal to 'number' with error of 1/1000
47  */
48 inline bool float_equal(double var, double number, double error)
49 {
50         return (number - error <= var && var <= number + error);
51 }
52
53 } // namespace support
54 } // namespace lyx
55
56 #endif /* LYX_LIB_H */