00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: winstl/system/module_directory.hpp 00003 * 00004 * Purpose: Simple class that gets, and makes accessible, the module's 00005 * directory. 00006 * 00007 * Created: 5th June 2003 00008 * Updated: 10th August 2009 00009 * 00010 * Home: http://stlsoft.org/ 00011 * 00012 * Copyright (c) 2003-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_MODULE_DIRECTORY 00050 #define WINSTL_INCL_WINSTL_SYSTEM_HPP_MODULE_DIRECTORY 00051 00052 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00053 # define WINSTL_VER_WINSTL_SYSTEM_HPP_MODULE_DIRECTORY_MAJOR 4 00054 # define WINSTL_VER_WINSTL_SYSTEM_HPP_MODULE_DIRECTORY_MINOR 1 00055 # define WINSTL_VER_WINSTL_SYSTEM_HPP_MODULE_DIRECTORY_REVISION 2 00056 # define WINSTL_VER_WINSTL_SYSTEM_HPP_MODULE_DIRECTORY_EDIT 55 00057 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00058 00059 /* ///////////////////////////////////////////////////////////////////////// 00060 * Compatibility 00061 */ 00062 00063 /* 00064 [Incompatibilies-start] 00065 STLSOFT_COMPILER_IS_MSVC: _MSC_VER<1200 00066 [Incompatibilies-end] 00067 */ 00068 00069 /* ///////////////////////////////////////////////////////////////////////// 00070 * Includes 00071 */ 00072 00073 #ifndef WINSTL_INCL_WINSTL_H_WINSTL 00074 # include <winstl/winstl.h> 00075 #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */ 00076 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE 00077 # include <stlsoft/string/special_string_instance.hpp> 00078 #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE */ 00079 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR 00080 # include <winstl/memory/processheap_allocator.hpp> 00081 #endif /* !WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR */ 00082 #ifndef WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_TRAITS 00083 # include <winstl/system/system_traits.hpp> 00084 #endif /* !WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_TRAITS */ 00085 00086 #if defined(STLSOFT_COMPILER_IS_BORLAND) 00087 // Borland is a bit of a thicky, and requires a (valid) spin_mutex_type 00088 # include <winstl/synch/spin_mutex.hpp> 00089 #endif /* compiler */ 00090 00091 #ifdef STLSOFT_UNITTEST 00092 # include <stdlib.h> // for malloc(), free() 00093 #endif /* STLSOFT_UNITTEST */ 00094 00095 /* ///////////////////////////////////////////////////////////////////////// 00096 * Namespace 00097 */ 00098 00099 #ifndef _WINSTL_NO_NAMESPACE 00100 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00101 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00102 /* There is no stlsoft namespace, so must define ::winstl */ 00103 namespace winstl 00104 { 00105 # else 00106 /* Define stlsoft::winstl_project */ 00107 00108 namespace stlsoft 00109 { 00110 00111 namespace winstl_project 00112 { 00113 00114 # endif /* _STLSOFT_NO_NAMESPACE */ 00115 #endif /* !_WINSTL_NO_NAMESPACE */ 00116 00117 /* ///////////////////////////////////////////////////////////////////////// 00118 * basic_module_directory 00119 * 00120 * This class determines the directory of a module, and effectively acts as a 00121 * C-string of its value. 00122 */ 00123 00167 template <ss_typename_param_k C> 00168 struct moddir_policy 00169 { 00172 public: 00173 typedef C char_type; 00174 typedef HINSTANCE argument_0_type; 00175 typedef processheap_allocator<C> allocator_type; 00176 typedef ws_size_t size_type; 00177 typedef size_type (*pfn_type)(argument_0_type, char_type *, size_type); 00178 #if defined(STLSOFT_COMPILER_IS_BORLAND) 00179 // Borland is a bit of a thicky, and requires a (valid) spin_mutex_type 00180 typedef winstl::spin_mutex spin_mutex_type; 00181 #endif /* compiler */ 00183 00186 public: 00187 enum { internalBufferSize = 128 }; 00188 00189 enum { allowImplicitConversion = 1 }; 00190 00191 enum { sharedState = 0 }; 00193 00196 public: 00197 static pfn_type get_fn() 00198 { 00199 return winstl::system_traits<char_type>::get_module_directory; 00200 } 00202 }; 00203 00204 /* ///////////////////////////////////////////////////////////////////////// 00205 * Typedefs for commonly encountered types 00206 */ 00207 00213 typedef stlsoft_ns_qual(special_string_instance_1)<moddir_policy<ws_char_a_t> > module_directory_a; 00219 typedef stlsoft_ns_qual(special_string_instance_1)<moddir_policy<ws_char_w_t> > module_directory_w; 00225 typedef stlsoft_ns_qual(special_string_instance_1)<moddir_policy<TCHAR> > module_directory; 00226 00227 /* ///////////////////////////////////////////////////////////////////////// 00228 * Unit-testing 00229 */ 00230 00231 #ifdef STLSOFT_UNITTEST 00232 # include "./unittest/module_directory_unittest_.h" 00233 #endif /* STLSOFT_UNITTEST */ 00234 00235 /* ////////////////////////////////////////////////////////////////////// */ 00236 00237 #ifndef _WINSTL_NO_NAMESPACE 00238 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00239 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00240 } // namespace winstl 00241 # else 00242 } // namespace winstl_project 00243 } // namespace stlsoft 00244 # endif /* _STLSOFT_NO_NAMESPACE */ 00245 #endif /* !_WINSTL_NO_NAMESPACE */ 00246 00247 /* ////////////////////////////////////////////////////////////////////// */ 00248 00249 #endif /* WINSTL_INCL_WINSTL_SYSTEM_HPP_MODULE_DIRECTORY */ 00250 00251 /* ///////////////////////////// end of file //////////////////////////// */