NetBurner 3.5.0
PDF Version
 
config_time.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
17#ifndef CONFIG_TIMET_H
18#define CONFIG_TIMET_H
19
20#include <config_obj.h>
21#include <sys/time.h>
22#include <sys/types.h>
23#include <time.h>
24
29{
30protected:
31 time_t tv;
32 bool buser_sees_gmt;
33
34public:
35static NBString TimetoNBString(time_t tv,bool bUtc=true);
36static time_t ParseTime(const char * cp,bool bUtc=true);
37static time_t ParseTime(NBString & ns,bool bUtc=true) {return config_time_t::ParseTime(ns.c_str(), bUtc); }
38
50 config_time_t(config_obj &owner, time_t def_val, const char *name, const char *desc = NULL, bool bUserSeesGmt=false) : config_string(owner,config_time_t::TimetoNBString(def_val), name, desc)
51 {
52 tv=def_val;
53 buser_sees_gmt=bUserSeesGmt;
54 }
55
57 config_time_t(config_obj &owner, const char * def_val, const char *name, const char *desc = NULL,bool bUserSeesGmt=false) : config_string(owner,def_val, name, desc)
58 {
59 tv=ParseTime(def_val);
60 buser_sees_gmt=bUserSeesGmt;
61 }
62
73 config_time_t(const char * def_val, const char *name, const char *desc = NULL,bool bUserSeesGmt=false) : config_string(def_val, name, desc)
74 {
75 tv=ParseTime(def_val);
76 buser_sees_gmt=bUserSeesGmt;
77 }
78
86 config_time_t(time_t def_val, const char *name, const char *desc = NULL) : config_string(config_time_t::TimetoNBString(def_val),name, desc)
87 {
88 tv=def_val;
89 }
90
91virtual void CommitTestedValue(uint32_t permission_mask) {config_string::CommitTestedValue(permission_mask); tv=config_time_t::ParseTime(val); };
92
93virtual void GetTypeValue(NBString &s) { s = "time_t"; };
94
100 operator time_t() const { return tv; };
101
102
103
110 {
111 tv=t;
112 pend_val = val = config_time_t::TimetoNBString(tv);
113 return *this;
114 };
115
122 {
123 pend_val = val = ci.val;
124 tv=ci.tv;
125 return *this;
126 };
127
128 NBString GetAsGmtString() {return val; }
129
131
132
133
134
136 virtual int Missing_ConfigEndMarker(void *&startp)
137 {
138 startp = this;
139 return sizeof(*this);
140 };
141
142void RenderValue(int fd, int len, const char *extra);
143void RenderInput(int fd, int len, const char *extra);
144bool ProcessValue(const char * pValue);
145
146};
147
148#endif
149
150
Lightweight alternative to C++ CString class.
Definition nbstring.h:118
const char * c_str() const
Method to pass a NBString as a constant char *.
Base class used to create configuration objects.
Definition config_obj.h:277
String Configuration Variable.
Definition config_obj.h:1055
Class to hold time configuration.
Definition config_time.h:29
virtual int Missing_ConfigEndMarker(void *&startp)
This is named so error messages make sense to user, old name was GetExtent.
Definition config_time.h:136
config_time_t(config_obj &owner, time_t def_val, const char *name, const char *desc=NULL, bool bUserSeesGmt=false)
Object constructor with the parent/owner leaf parameter.
Definition config_time.h:50
static NBString TimetoNBString(time_t tv, bool bUtc=true)
config_time_t(time_t def_val, const char *name, const char *desc=NULL)
Object constructor.
Definition config_time.h:86
static time_t ParseTime(NBString &ns, bool bUtc=true)
Definition config_time.h:37
config_time_t & operator=(const config_time_t &ci)
Copy one config_string object to another.
Definition config_time.h:121
void RenderValue(int fd, int len, const char *extra)
NBString GetAsLocalString()
Definition config_time.h:130
config_time_t(config_obj &owner, const char *def_val, const char *name, const char *desc=NULL, bool bUserSeesGmt=false)
Object constructor with the parent/owner leaf parameter.
Definition config_time.h:57
NBString GetAsGmtString()
Definition config_time.h:128
virtual void GetTypeValue(NBString &s)
Definition config_time.h:93
config_time_t & operator=(time_t t)
Assign the config_time_t object value from a anotherNBString object.
Definition config_time.h:109
bool ProcessValue(const char *pValue)
static time_t ParseTime(const char *cp, bool bUtc=true)
void RenderInput(int fd, int len, const char *extra)
config_time_t(const char *def_val, const char *name, const char *desc=NULL, bool bUserSeesGmt=false)
Object constructor.
Definition config_time.h:73
Configuration object header file.