00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef ACE_ENV_VALUE_T_H
00018 #define ACE_ENV_VALUE_T_H
00019 
00020 #include  "ace/pre.h"
00021 
00022 #include  "ace/config-all.h"
00023 #include "ace/Global_Macros.h"
00024 #include "ace/OS_NS_stdlib.h"
00025 
00026 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00027 # pragma once
00028 #endif 
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 template <class T>
00041 class ACE_Env_Value
00042 {
00043 public:
00044 
00045 
00046 
00047 
00048 
00049   ACE_Env_Value (void);
00050 
00051 
00052   ACE_Env_Value (const ACE_TCHAR *varname,
00053                  const T &vardefault);
00054 
00055 
00056   ~ACE_Env_Value (void);
00057 
00058 
00059   operator T (void);
00060 
00061 
00062 
00063   void open (const ACE_TCHAR *varname, const T &defval);
00064 
00065 
00066   const ACE_TCHAR *varname (void) const;
00067 
00068 private:
00069 
00070   ACE_UNIMPLEMENTED_FUNC (ACE_Env_Value(const ACE_Env_Value<T> &))
00071   ACE_UNIMPLEMENTED_FUNC (ACE_Env_Value<T> operator=(const ACE_Env_Value<T> &))
00072 
00073   void fetch_value (void);
00074 
00075   const ACE_TCHAR *varname_;
00076   T value_;
00077 };
00078 
00079 
00080 template <class T> void ACE_Convert (const ACE_TCHAR *s, T &t);
00081 
00082 ACE_END_VERSIONED_NAMESPACE_DECL
00083 
00084 #if defined (__ACE_INLINE__)
00085 #include "ace/Env_Value_T.inl"
00086 #endif 
00087 
00088 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00089 #include "ace/Env_Value_T.cpp"
00090 #endif 
00091 
00092 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00093 
00094 template <> inline void
00095 ACE_Convert (const ACE_TCHAR *s, ACE_TCHAR *&v)
00096 {
00097   v = (ACE_TCHAR *) s;
00098 }
00099 
00100 template <> inline void
00101 ACE_Convert (const ACE_TCHAR *s, const ACE_TCHAR *&v)
00102 {
00103   v = (const ACE_TCHAR *) s;
00104 }
00105 
00106 template <> inline void
00107 ACE_Convert (const ACE_TCHAR *s, short &si)
00108 {
00109   si = static_cast<short> (ACE_OS::strtol (s, 0, 10));
00110 }
00111 
00112 template <> inline void
00113 ACE_Convert (const ACE_TCHAR *s, u_short &us)
00114 {
00115   us = static_cast <u_short> (ACE_OS::strtol (s, 0, 10));
00116 }
00117 
00118 template <> inline void
00119 ACE_Convert (const ACE_TCHAR *s, u_int &i)
00120 {
00121   i = static_cast<u_int> (ACE_OS::strtol (s, 0, 10));
00122 }
00123 
00124 template <> inline void
00125 ACE_Convert (const ACE_TCHAR *s, long &l)
00126 {
00127   l = ACE_OS::strtol (s, 0, 10);
00128 }
00129 
00130 template <> inline void
00131 ACE_Convert (const ACE_TCHAR *s, int &i)
00132 {
00133   i = static_cast<int> (ACE_OS::strtol (s, 0, 10));
00134 }
00135 
00136 template <> inline void
00137 ACE_Convert (const ACE_TCHAR *s, u_long &ul)
00138 {
00139   ul = ACE_OS::strtoul (s, 0, 10);
00140 }
00141 
00142 template <> inline void
00143 ACE_Convert (const ACE_TCHAR *s, double &d)
00144 {
00145   d = ACE_OS::strtod (s, 0);
00146 }
00147 
00148 
00149 
00150 
00151 
00152 
00153 template <class T> inline void
00154 ACE_Convert (const ACE_TCHAR *s, T &t)
00155 {
00156   t = T (s);
00157 }
00158 
00159 ACE_END_VERSIONED_NAMESPACE_DECL
00160 
00161 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00162 #pragma implementation ("Env_Value_T.cpp")
00163 #endif 
00164 
00165 #include  "ace/post.h"
00166 #endif