You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
6.6 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/system/windows_directory.hpp
  3. *
  4. * Purpose: Simple class that gets, and makes accessible, the windows
  5. * directory.
  6. *
  7. * Created: 10th December 2002
  8. * Updated: 12th August 2010
  9. *
  10. * Home: http://stlsoft.org/
  11. *
  12. * Copyright (c) 2002-2010, Matthew Wilson and Synesis Software
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above copyright notice, this
  19. * list of conditions and the following disclaimer.
  20. * - Redistributions in binary form must reproduce the above copyright notice,
  21. * this list of conditions and the following disclaimer in the documentation
  22. * and/or other materials provided with the distribution.
  23. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  24. * any contributors may be used to endorse or promote products derived from
  25. * this software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  28. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  29. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  31. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  32. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  33. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  34. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  35. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  36. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. * ////////////////////////////////////////////////////////////////////// */
  40. /** \file winstl/system/windows_directory.hpp
  41. *
  42. * \brief [C++ only] Definition of the winstl::basic_windows_directory class
  43. * template
  44. * (\ref group__library__system "System" Library).
  45. */
  46. #ifndef WINSTL_INCL_WINSTL_SYSTEM_HPP_WINDOWS_DIRECTORY
  47. #define WINSTL_INCL_WINSTL_SYSTEM_HPP_WINDOWS_DIRECTORY
  48. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  49. # define WINSTL_VER_WINSTL_SYSTEM_HPP_WINDOWS_DIRECTORY_MAJOR 4
  50. # define WINSTL_VER_WINSTL_SYSTEM_HPP_WINDOWS_DIRECTORY_MINOR 2
  51. # define WINSTL_VER_WINSTL_SYSTEM_HPP_WINDOWS_DIRECTORY_REVISION 1
  52. # define WINSTL_VER_WINSTL_SYSTEM_HPP_WINDOWS_DIRECTORY_EDIT 65
  53. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  54. /* /////////////////////////////////////////////////////////////////////////
  55. * Includes
  56. */
  57. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  58. # include <winstl/winstl.h>
  59. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  60. #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE
  61. # include <stlsoft/string/special_string_instance.hpp>
  62. #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_SPECIAL_STRING_INSTANCE */
  63. #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR
  64. # include <winstl/memory/processheap_allocator.hpp>
  65. #endif /* !WINSTL_INCL_WINSTL_MEMORY_HPP_PROCESSHEAP_ALLOCATOR */
  66. #ifndef WINSTL_INCL_WINSTL_SYNCH_HPP_SPIN_MUTEX
  67. # include <winstl/synch/spin_mutex.hpp>
  68. #endif /* !WINSTL_INCL_WINSTL_SYNCH_HPP_SPIN_MUTEX */
  69. #ifndef WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_TRAITS
  70. # include <winstl/system/system_traits.hpp>
  71. #endif /* !WINSTL_INCL_WINSTL_SYSTEM_HPP_SYSTEM_TRAITS */
  72. /* /////////////////////////////////////////////////////////////////////////
  73. * Namespace
  74. */
  75. #ifndef _WINSTL_NO_NAMESPACE
  76. # if defined(_STLSOFT_NO_NAMESPACE) || \
  77. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  78. /* There is no stlsoft namespace, so must define ::winstl */
  79. namespace winstl
  80. {
  81. # else
  82. /* Define stlsoft::winstl_project */
  83. namespace stlsoft
  84. {
  85. namespace winstl_project
  86. {
  87. # endif /* _STLSOFT_NO_NAMESPACE */
  88. #endif /* !_WINSTL_NO_NAMESPACE */
  89. /* /////////////////////////////////////////////////////////////////////////
  90. * Classes
  91. */
  92. /** \brief \ref group__pattern__special_string_instance "Special String Instance"
  93. * policy template for eliciting the <b>Windows</b> directory.
  94. *
  95. * \ingroup group__library__system
  96. */
  97. template <ss_typename_param_k C>
  98. struct windir_policy
  99. {
  100. /// \name Member Types
  101. /// @{
  102. public:
  103. typedef C char_type;
  104. typedef processheap_allocator<C> allocator_type;
  105. typedef ws_size_t size_type;
  106. typedef size_type (*pfn_type)(char_type *, size_type);
  107. typedef winstl::spin_mutex spin_mutex_type;
  108. typedef winstl::atomic_int_t atomic_int_type;
  109. /// @}
  110. /// \name Member Constants
  111. /// @{
  112. public:
  113. enum { internalBufferSize = 32 };
  114. enum { allowImplicitConversion = 1 };
  115. enum { sharedState = 1 };
  116. /// @}
  117. /// \name Operations
  118. /// @{
  119. public:
  120. static pfn_type get_fn()
  121. {
  122. return winstl::system_traits<char_type>::get_windows_directory;
  123. }
  124. /// @}
  125. };
  126. /* /////////////////////////////////////////////////////////////////////////
  127. * Typedefs for commonly encountered types
  128. */
  129. /** \brief A \ref group__pattern__special_string_instance "Special String Instance"
  130. * that represents the <b>Windows</b> directory; ANSI specialisation.
  131. *
  132. * \ingroup group__library__system
  133. */
  134. typedef stlsoft_ns_qual(special_string_instance_0)< windir_policy<ws_char_a_t> > windows_directory_a;
  135. /** \brief A \ref group__pattern__special_string_instance "Special String Instance"
  136. * that represents the <b>Windows</b> directory; 'Unicode' specialisation.
  137. *
  138. * \ingroup group__library__system
  139. */
  140. typedef stlsoft_ns_qual(special_string_instance_0)< windir_policy<ws_char_w_t> > windows_directory_w;
  141. /** \brief A \ref group__pattern__special_string_instance "Special String Instance"
  142. * that represents the <b>Windows</b> directory; TCHAR specialisation.
  143. *
  144. * \ingroup group__library__system
  145. */
  146. typedef stlsoft_ns_qual(special_string_instance_0)< windir_policy<TCHAR> > windows_directory;
  147. /* ////////////////////////////////////////////////////////////////////// */
  148. #ifndef _WINSTL_NO_NAMESPACE
  149. # if defined(_STLSOFT_NO_NAMESPACE) || \
  150. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  151. } // namespace winstl
  152. # else
  153. } // namespace winstl_project
  154. } // namespace stlsoft
  155. # endif /* _STLSOFT_NO_NAMESPACE */
  156. #endif /* !_WINSTL_NO_NAMESPACE */
  157. /* ////////////////////////////////////////////////////////////////////// */
  158. #endif /* WINSTL_INCL_WINSTL_SYSTEM_HPP_WINDOWS_DIRECTORY */
  159. /* ///////////////////////////// end of file //////////////////////////// */