00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00048 #ifndef WINSTL_INCL_WINSTL_SYSTEM_HPP_ENVIRONMENT_VARIABLE
00049 #define WINSTL_INCL_WINSTL_SYSTEM_HPP_ENVIRONMENT_VARIABLE
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define WINSTL_VER_WINSTL_SYSTEM_HPP_ENVIRONMENT_VARIABLE_MAJOR 4
00053 # define WINSTL_VER_WINSTL_SYSTEM_HPP_ENVIRONMENT_VARIABLE_MINOR 2
00054 # define WINSTL_VER_WINSTL_SYSTEM_HPP_ENVIRONMENT_VARIABLE_REVISION 1
00055 # define WINSTL_VER_WINSTL_SYSTEM_HPP_ENVIRONMENT_VARIABLE_EDIT 64
00056 #endif
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00073 # include <winstl/winstl.h>
00074 #endif
00075
00076 #ifndef WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_TRAITS
00077 # include <winstl/system/system_traits.hpp>
00078 #endif
00079 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00080 # include <stlsoft/shims/access/string.hpp>
00081 #endif
00082 #ifndef WINSTL_INCL_WINSTL_SHIMS_ACCESS_HPP_STRING
00083 # include <winstl/shims/access/string.hpp>
00084 #endif
00085 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
00086 # include <stlsoft/memory/auto_buffer.hpp>
00087 #endif
00088 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR
00089 # include <winstl/memory/processheap_allocator.hpp>
00090 #endif
00091
00092
00093
00094
00095
00096 #ifndef _WINSTL_NO_NAMESPACE
00097 # if defined(_STLSOFT_NO_NAMESPACE) || \
00098 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00099
00100 namespace winstl
00101 {
00102 # else
00103
00104
00105 namespace stlsoft
00106 {
00107
00108 namespace winstl_project
00109 {
00110
00111 # endif
00112 #endif
00113
00114
00115
00116
00117
00118
00119
00120
00128 template< ss_typename_param_k C
00129 #ifdef STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00130 , ss_typename_param_k T = system_traits<C>
00131 #else
00132 , ss_typename_param_k T
00133 #endif
00134 >
00135 class basic_environment_variable
00136 {
00137 public:
00139 typedef C char_type;
00141 typedef T traits_type;
00143 typedef processheap_allocator<C> allocator_type;
00145 typedef basic_environment_variable<C, T> class_type;
00147 typedef ws_size_t size_type;
00149 typedef ws_ptrdiff_t difference_type;
00150
00151
00152 public:
00154 ss_explicit_k basic_environment_variable(char_type const* name)
00155 : m_buffer(1 + traits_type::get_environment_variable(name, 0, 0))
00156 {
00157 if( 0 == traits_type::get_environment_variable(name, &m_buffer[0], m_buffer.size()) &&
00158 0 != m_buffer.size())
00159 {
00160 m_buffer[0] = 0;
00161 }
00162 else
00163 {
00164
00165
00166 m_buffer.resize(1 + traits_type::str_len(m_buffer.data()));
00167 }
00168 }
00169 #ifdef STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT
00171 template<ss_typename_param_k S>
00172 ss_explicit_k basic_environment_variable(S const& name)
00173 : m_buffer(1 + traits_type::get_environment_variable(stlsoft_ns_qual(c_str_ptr)(name), 0, 0))
00174 {
00175 if( 0 == traits_type::get_environment_variable(stlsoft_ns_qual(c_str_ptr)(name), &m_buffer[0], m_buffer.size()) &&
00176 0 != m_buffer.size())
00177 {
00178 m_buffer[0] = 0;
00179 }
00180 else
00181 {
00182
00183
00184 m_buffer.resize(1 + traits_type::str_len(m_buffer.data()));
00185 }
00186 }
00187 #endif
00188
00189
00190 public:
00192 operator char_type const* () const
00193 {
00194 return m_buffer.data();
00195 }
00196
00198 char_type const* c_str() const
00199 {
00200 return m_buffer.data();
00201 }
00202
00203
00204 public:
00206 size_type length() const
00207 {
00208 return m_buffer.size() - 1;
00209 }
00210
00211
00212 private:
00213 typedef stlsoft_ns_qual(auto_buffer_old)< char_type
00214 , allocator_type
00215 > buffer_type_;
00216
00217 buffer_type_ m_buffer;
00218
00219
00220 private:
00221 basic_environment_variable(basic_environment_variable const&);
00222 basic_environment_variable& operator =(basic_environment_variable const&);
00223 };
00224
00225
00226
00227
00228
00233 typedef basic_environment_variable<ws_char_a_t, system_traits<ws_char_a_t> > environment_variable_a;
00238 typedef basic_environment_variable<ws_char_w_t, system_traits<ws_char_w_t> > environment_variable_w;
00243 typedef basic_environment_variable<TCHAR, system_traits<TCHAR> > environment_variable;
00244
00245
00246
00247
00248
00249 #if !defined(STLSOFT_COMPILER_IS_MSVC) || \
00250 _MSC_VER >= 1100
00251
00257 template<ss_typename_param_k C>
00258 inline basic_environment_variable<C> make_environment_variable(C const* path)
00259 {
00260 return basic_environment_variable<C>(path);
00261 }
00262
00263 #endif
00264
00266
00267
00268 #ifdef STLSOFT_UNITTEST
00269 # include "./unittest/environment_variable_unittest_.h"
00270 #endif
00271
00272
00273
00274 #ifndef _WINSTL_NO_NAMESPACE
00275 # if defined(_STLSOFT_NO_NAMESPACE) || \
00276 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00277 }
00278 # else
00279 }
00280 }
00281 # endif
00282 #endif
00283
00284
00285
00286 #endif
00287
00288