summaryrefslogtreecommitdiffabout
path: root/include/sitecing/sitecing_util.h
Unidiff
Diffstat (limited to 'include/sitecing/sitecing_util.h') (more/less context) (show whitespace changes)
-rw-r--r--include/sitecing/sitecing_util.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/sitecing/sitecing_util.h b/include/sitecing/sitecing_util.h
index f642c74..233292c 100644
--- a/include/sitecing/sitecing_util.h
+++ b/include/sitecing/sitecing_util.h
@@ -1,70 +1,94 @@
1#ifndef __SITECING_SITECING_UTIL_H 1#ifndef __SITECING_SITECING_UTIL_H
2#define __SITECING_SITECING_UTIL_H 2#define __SITECING_SITECING_UTIL_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#include <string> 5#include <string>
6#include <konforka/exception.h> 6#include <konforka/exception.h>
7#include <konforka/util.h> 7#include <konforka/util.h>
8 8
9/** 9/**
10 * @file 10 * @file
11 * @brief utility classes and functions. 11 * @brief utility classes and functions.
12 */ 12 */
13 13
14namespace sitecing { 14namespace sitecing {
15 using namespace std; 15 using namespace std;
16 16
17 /** 17 /**
18 * Base class for utility exceptions. 18 * Base class for utility exceptions.
19 */ 19 */
20 class utility_error : public konforka::exception { 20 class utility_error : public konforka::exception {
21 public: 21 public:
22 /**
23 * @param fi file name
24 * @param fu function name
25 * @param l line number
26 * @param w what
27 */
22 utility_error(const string& fi,const string& fu,int l,const string& w) 28 utility_error(const string& fi,const string& fu,int l,const string& w)
23 : konforka::exception(fi,fu,l,w) { } 29 : konforka::exception(fi,fu,l,w) { }
24 }; 30 };
25 31
26 /** 32 /**
27 * No prefix or suffix found to strip out. 33 * No prefix or suffix found to strip out.
28 */ 34 */
29 class utility_no_affix : public utility_error { 35 class utility_no_affix : public utility_error {
30 public: 36 public:
37 /**
38 * @param fi file name
39 * @param fu function name
40 * @param l line number
41 * @param w what
42 */
31 utility_no_affix(const string& fi,const string& fu,int l,const string& w) 43 utility_no_affix(const string& fi,const string& fu,int l,const string& w)
32 : utility_error(fi,fu,l,w) { } 44 : utility_error(fi,fu,l,w) { }
33 }; 45 };
34 /** 46 /**
35 * No prefix to strip found. 47 * No prefix to strip found.
36 */ 48 */
37 class utility_no_prefix : public utility_no_affix { 49 class utility_no_prefix : public utility_no_affix {
38 public: 50 public:
51 /**
52 * @param fi file name
53 * @param fu function name
54 * @param l line number
55 * @param w what
56 */
39 utility_no_prefix(const string& fi,const string& fu,int l,const string& w) 57 utility_no_prefix(const string& fi,const string& fu,int l,const string& w)
40 : utility_no_affix(fi,fu,l,w) { } 58 : utility_no_affix(fi,fu,l,w) { }
41 }; 59 };
42 /** 60 /**
43 * No suffix to strip found. 61 * No suffix to strip found.
44 */ 62 */
45 class utility_no_suffix : public utility_no_affix { 63 class utility_no_suffix : public utility_no_affix {
46 public: 64 public:
65 /**
66 * @param fi file name
67 * @param fu function name
68 * @param l line number
69 * @param w what
70 */
47 utility_no_suffix(const string& fi,const string& fu,int l,const string& w) 71 utility_no_suffix(const string& fi,const string& fu,int l,const string& w)
48 : utility_no_affix(fi,fu,l,w) { } 72 : utility_no_affix(fi,fu,l,w) { }
49 }; 73 };
50 74
51 /** 75 /**
52 * The file lock object. Released at the object destruction. 76 * The file lock object. Released at the object destruction.
53 */ 77 */
54 class file_lock { 78 class file_lock {
55 public: 79 public:
56 /** 80 /**
57 * The file descriptor. 81 * The file descriptor.
58 */ 82 */
59 int fd; 83 int fd;
60 84
61 file_lock() 85 file_lock()
62 : fd(-1) { } 86 : fd(-1) { }
63 /** 87 /**
64 * @param f file name. 88 * @param f file name.
65 */ 89 */
66 file_lock(const string& f) 90 file_lock(const string& f)
67 : fd(-1) { lock(f); } 91 : fd(-1) { lock(f); }
68 ~file_lock() { unlock(); } 92 ~file_lock() { unlock(); }
69 93
70 /** 94 /**