1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// $Id$
template <class T> ACE_INLINE
ACE_Env_Value<T>::operator const T (void) const
{
return value_;
}
template <class T> ACE_INLINE
ACE_Env_Value<T>::ACE_Env_Value (void)
: varname_ (0)
{
}
template <class T> ACE_INLINE
ACE_Env_Value<T>::ACE_Env_Value (const char *varname,
const T &defval)
: varname_ (varname),
value_(defval)
{
this->fetch_value ();
}
template <class T> ACE_INLINE void
ACE_Env_Value<T>::open (const char *varname,
const T &defval)
{
varname_ = varname;
value_ = defval;
this->fetch_value ();
}
template <class T> ACE_INLINE void
ACE_Env_Value<T>::fetch_value (void)
{
const char *env = ACE_OS::getenv (varname_);
if (env != 0)
ACE_Convert (env, value_);
}
template <class T> ACE_INLINE
ACE_Env_Value<T>::~ACE_Env_Value (void)
{
}
// Default calls a CTOR on type T of the form 'T::T(const char*)', but
// users can feel free to create their own specialized conversion
// functions if necessary, as shown below. Note that for 'char*' the
// default is used because a simple cast will be performed and no
// conversion will be necessary.
template <class T> ACE_INLINE void
ACE_Convert (const char *s, T &t)
{
t = T (s);
}
ACE_INLINE void
ACE_Convert (const char *s, char *&v)
{
v = (char *) s;
}
ACE_INLINE void
ACE_Convert (const char *s, short &si)
{
si = ACE_OS::strtol (s, 0, 10);
}
ACE_INLINE void
ACE_Convert (const char *s, long &l)
{
l = ACE_OS::strtol (s, 0, 10);
}
ACE_INLINE void
ACE_Convert (const char *s, int &i)
{
i = ACE_OS::strtol (s, 0, 10);
}
ACE_INLINE void
ACE_Convert (const char *s, u_long &ul)
{
ul = ACE_OS::strtoul (s, 0, 10);
}
ACE_INLINE void
ACE_Convert (const char *s, double &d)
{
d = ACE_OS::strtod (s, 0);
}
|