00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: atlstl/shims/access/string/ccombstr.hpp 00003 * 00004 * Purpose: Contains classes and functions for dealing with OLE/COM strings. 00005 * 00006 * Created: 27th May 2002 00007 * Updated: 10th August 2009 00008 * 00009 * Home: http://stlsoft.org/ 00010 * 00011 * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software 00012 * All rights reserved. 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions are met: 00016 * 00017 * - Redistributions of source code must retain the above copyright notice, this 00018 * list of conditions and the following disclaimer. 00019 * - Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of 00023 * any contributors may be used to endorse or promote products derived from 00024 * this software without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 * 00038 * ////////////////////////////////////////////////////////////////////// */ 00039 00040 00048 #ifndef ATLSTL_INCL_ATLSTL_SHIMS_ACCESS_STRING_HPP_CCOMBSTR 00049 #define ATLSTL_INCL_ATLSTL_SHIMS_ACCESS_STRING_HPP_CCOMBSTR 00050 00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00052 # define ATLSTL_VER_ATLSTL_SHIMS_ACCESS_STRING_HPP_CCOMBSTR_MAJOR 4 00053 # define ATLSTL_VER_ATLSTL_SHIMS_ACCESS_STRING_HPP_CCOMBSTR_MINOR 0 00054 # define ATLSTL_VER_ATLSTL_SHIMS_ACCESS_STRING_HPP_CCOMBSTR_REVISION 1 00055 # define ATLSTL_VER_ATLSTL_SHIMS_ACCESS_STRING_HPP_CCOMBSTR_EDIT 97 00056 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00057 00058 /* ///////////////////////////////////////////////////////////////////////// 00059 * Includes 00060 */ 00061 00062 #ifndef ATLSTL_INCL_ATLSTL_HPP_ATLSTL 00063 # include <atlstl/atlstl.hpp> 00064 #endif /* !ATLSTL_INCL_ATLSTL_HPP_ATLSTL */ 00065 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING 00066 # include <stlsoft/shims/access/string.hpp> 00067 #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING */ 00068 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_CSTRING_MAKER 00069 # include <stlsoft/string/cstring_maker.hpp> 00070 #endif /* !STLSOFT_INCL_STLSOFT_STRING_HPP_CSTRING_MAKER */ 00071 #ifdef STLSOFT_UNITTEST 00072 # include <wchar.h> 00073 #endif /* STLSOFT_UNITTEST */ 00074 00075 /* ///////////////////////////////////////////////////////////////////////// 00076 * Namespace 00077 */ 00078 00079 #ifndef _ATLSTL_NO_NAMESPACE 00080 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00081 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00082 /* There is no stlsoft namespace, so must define ::atlstl */ 00083 namespace atlstl 00084 { 00085 # else 00086 /* Define stlsoft::atlstl_project */ 00087 00088 namespace stlsoft 00089 { 00090 00091 namespace atlstl_project 00092 { 00093 00094 # endif /* _STLSOFT_NO_NAMESPACE */ 00095 #endif /* !_ATLSTL_NO_NAMESPACE */ 00096 00097 /* ///////////////////////////////////////////////////////////////////////// 00098 * c_str_data 00099 * 00100 * This can be applied to an expression, and the return value is either a 00101 * pointer to the character string or to an empty string. 00102 */ 00103 00109 inline LPCOLESTR c_str_data(atlstl_ns_qual_atl(CComBSTR) const& s) 00110 { 00111 return c_str_ptr(s); 00112 } 00113 00114 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00115 inline LPCOLESTR c_str_data_w(atlstl_ns_qual_atl(CComBSTR) const& s) 00116 { 00117 return c_str_data(s); 00118 } 00119 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00120 00121 /* ///////////////////////////////////////////////////////////////////////// 00122 * c_str_len 00123 * 00124 * This can be applied to an expression, and the return value is the number 00125 * of characters in the character string in the expression. 00126 */ 00127 00128 /* CComBSTR */ 00129 00135 inline as_size_t c_str_len(atlstl_ns_qual_atl(CComBSTR) const& s) 00136 { 00137 return s.Length(); 00138 } 00139 00140 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00141 inline as_size_t c_str_len_w(atlstl_ns_qual_atl(CComBSTR) const& s) 00142 { 00143 return c_str_len(s); 00144 } 00145 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00146 00147 /* ///////////////////////////////////////////////////////////////////////// 00148 * c_str_ptr 00149 * 00150 * This can be applied to an expression, and the return value is either a 00151 * pointer to the character string or to an empty string. 00152 */ 00153 00154 /* CComBSTR */ 00155 00161 inline LPCOLESTR c_str_ptr(atlstl_ns_qual_atl(CComBSTR) const& s) 00162 { 00163 /* NULL is a valid BSTR value, so check for that */ 00164 return (s.m_str != 0) ? s.m_str : L""; 00165 } 00166 00167 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00168 inline LPCOLESTR c_str_ptr_w(atlstl_ns_qual_atl(CComBSTR) const& s) 00169 { 00170 return c_str_ptr(s); 00171 } 00172 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00173 00174 /* ///////////////////////////////////////////////////////////////////////// 00175 * c_str_ptr_null 00176 * 00177 * This can be applied to an expression, and the return value is either a 00178 * pointer to the character string or NULL. 00179 */ 00180 00181 /* CComBSTR */ 00182 00188 inline LPCOLESTR c_str_ptr_null(atlstl_ns_qual_atl(CComBSTR) const& s) 00189 { 00190 /* NULL is a valid BSTR value, so may return that */ 00191 return s.m_str; 00192 } 00193 00194 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00195 inline LPCOLESTR c_str_ptr_null_w(atlstl_ns_qual_atl(CComBSTR) const& s) 00196 { 00197 return c_str_ptr_null(s); 00198 } 00199 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00200 00202 // Unit-testing 00203 00204 #ifdef STLSOFT_UNITTEST 00205 # include "./unittest/ccombstr_unittest_.h" 00206 #endif /* STLSOFT_UNITTEST */ 00207 00208 /* ////////////////////////////////////////////////////////////////////// */ 00209 00210 #ifndef _ATLSTL_NO_NAMESPACE 00211 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00212 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00213 } // namespace atlstl 00214 # else 00215 } // namespace stlsoft::atlstl_project 00216 } // namespace stlsoft 00217 # endif /* _STLSOFT_NO_NAMESPACE */ 00218 #endif /* !_ATLSTL_NO_NAMESPACE */ 00219 00220 /* ///////////////////////////////////////////////////////////////////////// 00221 * Namespace 00222 * 00223 * The string access shims exist either in the stlsoft namespace, or in the 00224 * global namespace. This is required by the lookup rules. 00225 * 00226 */ 00227 00228 #ifndef _ATLSTL_NO_NAMESPACE 00229 # if !defined(_STLSOFT_NO_NAMESPACE) && \ 00230 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00231 namespace stlsoft 00232 { 00233 # else /* ? _STLSOFT_NO_NAMESPACE */ 00234 /* There is no stlsoft namespace, so must define in the global namespace */ 00235 # endif /* !_STLSOFT_NO_NAMESPACE */ 00236 00237 using ::atlstl::c_str_data; 00238 using ::atlstl::c_str_data_w; 00239 00240 using ::atlstl::c_str_len; 00241 using ::atlstl::c_str_len_w; 00242 00243 using ::atlstl::c_str_ptr; 00244 using ::atlstl::c_str_ptr_w; 00245 00246 using ::atlstl::c_str_ptr_null; 00247 using ::atlstl::c_str_ptr_null_w; 00248 00249 # if !defined(_STLSOFT_NO_NAMESPACE) && \ 00250 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00251 } // namespace stlsoft 00252 # else /* ? _STLSOFT_NO_NAMESPACE */ 00253 /* There is no stlsoft namespace, so must define in the global namespace */ 00254 # endif /* !_STLSOFT_NO_NAMESPACE */ 00255 #endif /* !_ATLSTL_NO_NAMESPACE */ 00256 00257 /* ////////////////////////////////////////////////////////////////////// */ 00258 00259 #endif /* !ATLSTL_INCL_ATLSTL_SHIMS_ACCESS_STRING_HPP_CCOMBSTR */ 00260 00261 /* ///////////////////////////// end of file //////////////////////////// */