00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: winstl/system/system_directory.hpp 00003 * 00004 * Purpose: Simple class that gets, and makes accessible, the system 00005 * directory. 00006 * 00007 * Created: 10th December 2002 00008 * Updated: 10th August 2009 00009 * 00010 * Home: http://stlsoft.org/ 00011 * 00012 * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software 00013 * All rights reserved. 00014 * 00015 * Redistribution and use in source and binary forms, with or without 00016 * modification, are permitted provided that the following conditions are met: 00017 * 00018 * - Redistributions of source code must retain the above copyright notice, this 00019 * list of conditions and the following disclaimer. 00020 * - Redistributions in binary form must reproduce the above copyright notice, 00021 * this list of conditions and the following disclaimer in the documentation 00022 * and/or other materials provided with the distribution. 00023 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of 00024 * any contributors may be used to endorse or promote products derived from 00025 * this software without specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 * 00039 * ////////////////////////////////////////////////////////////////////// */ 00040 00041 00049 #ifndef WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_DIRECTORY 00050 #define WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_DIRECTORY 00051 00052 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00053 # define WINSTL_VER_WINSTL_SYSTEM_HPP_SYSTEM_DIRECTORY_MAJOR 4 00054 # define WINSTL_VER_WINSTL_SYSTEM_HPP_SYSTEM_DIRECTORY_MINOR 2 00055 # define WINSTL_VER_WINSTL_SYSTEM_HPP_SYSTEM_DIRECTORY_REVISION 2 00056 # define WINSTL_VER_WINSTL_SYSTEM_HPP_SYSTEM_DIRECTORY_EDIT 67 00057 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00058 00059 /* ///////////////////////////////////////////////////////////////////////// 00060 * Includes 00061 */ 00062 00063 #ifndef WINSTL_INCL_WINSTL_H_WINSTL 00064 # include <winstl/winstl.h> 00065 #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */ 00066 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE 00067 # include <stlsoft/string/special_string_instance.hpp> 00068 #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE */ 00069 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR 00070 # include <winstl/memory/processheap_allocator.hpp> 00071 #endif /* !WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR */ 00072 #ifndef WINSTL_INCL_WINSTL_SYNCH_HPP_SPIN_MUTEX 00073 # include <winstl/synch/spin_mutex.hpp> 00074 #endif /* !WINSTL_INCL_WINSTL_SYNCH_HPP_SPIN_MUTEX */ 00075 #ifndef WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_TRAITS 00076 # include <winstl/system/system_traits.hpp> 00077 #endif /* !WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_TRAITS */ 00078 00079 /* ///////////////////////////////////////////////////////////////////////// 00080 * Namespace 00081 */ 00082 00083 #ifndef _WINSTL_NO_NAMESPACE 00084 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00085 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00086 /* There is no stlsoft namespace, so must define ::winstl */ 00087 namespace winstl 00088 { 00089 # else 00090 /* Define stlsoft::winstl_project */ 00091 00092 namespace stlsoft 00093 { 00094 00095 namespace winstl_project 00096 { 00097 00098 # endif /* _STLSOFT_NO_NAMESPACE */ 00099 #endif /* !_WINSTL_NO_NAMESPACE */ 00100 00101 /* ///////////////////////////////////////////////////////////////////////// 00102 * Classes 00103 */ 00104 00110 template <ss_typename_param_k C> 00111 struct sysdir_policy 00112 { 00115 public: 00116 typedef C char_type; 00117 typedef processheap_allocator<C> allocator_type; 00118 typedef ws_size_t size_type; 00119 typedef size_type (*pfn_type)(char_type *, size_type); 00120 typedef winstl::spin_mutex spin_mutex_type; 00122 00125 public: 00126 enum { internalBufferSize = 32 }; 00127 00128 enum { allowImplicitConversion = 1 }; 00129 00130 enum { sharedState = 1 }; 00132 00135 public: 00136 static pfn_type get_fn() 00137 { 00138 return winstl::system_traits<char_type>::get_system_directory; 00139 } 00141 }; 00142 00143 /* ///////////////////////////////////////////////////////////////////////// 00144 * Typedefs for commonly encountered types 00145 */ 00146 00152 typedef stlsoft_ns_qual(special_string_instance_0)< sysdir_policy<ws_char_a_t> > system_directory_a; 00158 typedef stlsoft_ns_qual(special_string_instance_0)< sysdir_policy<ws_char_w_t> > system_directory_w; 00164 typedef stlsoft_ns_qual(special_string_instance_0)< sysdir_policy<TCHAR> > system_directory; 00165 00167 // Unit-testing 00168 00169 #ifdef STLSOFT_UNITTEST 00170 # include "./unittest/system_directory_unittest_.h" 00171 #endif /* STLSOFT_UNITTEST */ 00172 00173 /* ////////////////////////////////////////////////////////////////////// */ 00174 00175 #ifndef _WINSTL_NO_NAMESPACE 00176 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00177 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00178 } // namespace winstl 00179 # else 00180 } // namespace winstl_project 00181 } // namespace stlsoft 00182 # endif /* _STLSOFT_NO_NAMESPACE */ 00183 #endif /* !_WINSTL_NO_NAMESPACE */ 00184 00185 /* ////////////////////////////////////////////////////////////////////// */ 00186 00187 #endif /* WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_DIRECTORY */ 00188 00189 /* ///////////////////////////// end of file //////////////////////////// */