STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - Template Software for the Active Template Library COMSTL - The Standard Template Library meets the Component Object Model .netSTL - Standard Template Library meets the Microsoft.NET Common Language Runtime InetSTL - The Standard Template Library meets WinInet MFCSTL - Template Software for the Microsoft Foundation Classes UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

atlstl.h

Go to the documentation of this file.
00001 /* 
00002  * File:        atlstl.h
00003  *
00004  * Purpose:     Root header for the ATLSTL libraries. Performs various compiler
00005  *              and platform discriminations, and definitions of types.
00006  *
00007  * Created:     15th January 2002
00008  * Updated:     11th September 2004
00009  *
00010  * Home:        http://stlsoft.org/
00011  *
00012  * Copyright (c) 2002-2004, 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 
00042 #ifndef ATLSTL_INCL_H_ATLSTL
00043 #define ATLSTL_INCL_H_ATLSTL
00044 
00045 /* File version */
00046 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00047 # define ATLSTL_VER_H_ATLSTL_MAJOR      2
00048 # define ATLSTL_VER_H_ATLSTL_MINOR      0
00049 # define ATLSTL_VER_H_ATLSTL_REVISION   1
00050 # define ATLSTL_VER_H_ATLSTL_EDIT       68
00051 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00052 
00096 /* 
00097  * ATLSTL version
00098  *
00099  * The libraries version information is comprised of major, minor and revision
00100  * components.
00101  *
00102  * The major version is denoted by the _ATLSTL_VER_MAJOR preprocessor symbol.
00103  * A changes to the major version component implies that a dramatic change has
00104  * occurred in the libraries, such that considerable changes to source dependent
00105  * on previous versions would need to be effected.
00106  *
00107  * The minor version is denoted by the _ATLSTL_VER_MINOR preprocessor symbol.
00108  * Changes to the minor version component imply that a significant change has
00109  * occurred to the libraries, either in the addition of new functionality or in
00110  * the destructive change to one or more components such that recomplilation and
00111  * code change may be necessitated.
00112  *
00113  * The revision version is denoted by the _ATLSTL_VER_REVISIO preprocessor
00114  * symbol. Changes to the revision version component imply that a bug has been
00115  * fixed. Dependent code should be recompiled in order to pick up the changes.
00116  *
00117  * In addition to the individual version symbols - _ATLSTL_VER_MAJOR,
00118  * _ATLSTL_VER_MINOR and _ATLSTL_VER_REVISION - a composite symbol _ATLSTL_VER
00119  * is defined, where the upper 8 bits are 0, bits 16-23 represent the major
00120  * component,  bits 8-15 represent the minor component, and bits 0-7 represent
00121  * the revision component.
00122  *
00123  * Each release of the libraries will bear a different version, and that version
00124  * will also have its own symbol: Version 1.0.1 specifies _ATLSTL_VER_1_0_1.
00125  *
00126  * Thus the symbol _ATLSTL_VER may be compared meaningfully with a specific
00127  * version symbol, e.g. #if _ATLSTL_VER >= _ATLSTL_VER_1_0_1
00128  */
00129 
00132 
00135 
00138 
00141 
00142 #define _ATLSTL_VER_MAJOR       1
00143 #define _ATLSTL_VER_MINOR       3
00144 #define _ATLSTL_VER_REVISION    1
00145 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00146 # define _ATLSTL_VER_1_0_1      0x00010001  
00147 # define _ATLSTL_VER_1_1_1      0x00010101  
00148 # define _ATLSTL_VER_1_2_1      0x00010201  
00149 # define _ATLSTL_VER_1_2_2      0x00010202  
00150 # define _ATLSTL_VER_1_2_3      0x00010203  
00151 # define _ATLSTL_VER_1_2_4      0x00010204  
00152 # define _ATLSTL_VER_1_2_5      0x00010205  
00153 # define _ATLSTL_VER_1_2_6      0x00010206  
00154 # define _ATLSTL_VER_1_2_7      0x00010207  
00155 # define _ATLSTL_VER_1_2_8      0x00010208  
00156 # define _ATLSTL_VER_1_3_1      0x00010301  
00157 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00158 
00159 #define _ATLSTL_VER             _ATLSTL_VER_1_3_1
00160 
00161 /* 
00162  * Includes
00163  */
00164 
00165 #ifndef STLSOFT_INCL_H_STLSOFT
00166 # include "stlsoft.h"   // STLSoft root header
00167 #endif /* !STLSOFT_INCL_H_STLSOFT */
00168 
00169 #if defined(__STLSOFT_COMPILER_IS_BORLAND)
00170 # pragma warn -8013 /* Suppresses "Possible use of 'f' before definition in '. . .'" */
00171 # pragma warn -8084 /* Suppresses "Suggest parentheses to clarify precedence in function 'f()'" */
00172 #endif /* compiler */
00173 
00174 #include <atlbase.h>    // ATL base header
00175 
00176 #if defined(__STLSOFT_COMPILER_IS_BORLAND)
00177 # pragma warn .8013 /* Suppresses "Possible use of 'f' before definition in '. . .'" */
00178 # pragma warn .8084 /* Suppresses "Suggest parentheses to clarify precedence in function 'f()'" */
00179 #endif /* compiler */
00180 
00181 #ifdef STLSOFT_UNITTEST
00182 # include <stdio.h>
00183 #endif /* STLSOFT_UNITTEST */
00184 
00185 /* 
00186  * STLSoft version compatibility
00187  */
00188 
00189 #if !defined(_STLSOFT_VER_1_5_1) || \
00190     _STLSOFT_VER < _STLSOFT_VER_1_5_1
00191 # error This version of the ATLSTL libraries requires STLSoft version 1.5.1 or later
00192 #endif /* _STLSOFT_VER < _STLSOFT_VER_1_5_1 */
00193 
00194 /* 
00195  * Compiler compatibility
00196  *
00197  * Currently the only compilers supported by the ATLSTL libraries are
00198  *
00199  * Borland C++ 5.5, 5.51, 5.6
00200  * Digital Mars C/C++ 8.26 - 8.32
00201  * Metrowerks 2.4 & 3.0 (CodeWarrior 7.0 & 8.0)
00202  * Intel C/C++ 6.0
00203  * Visual C++ 4.2, 5.0, 6.0, 7.0
00204  */
00205 
00206 #if defined(__STLSOFT_COMPILER_IS_BORLAND)
00207 /* Borland C++ */
00208 # if __BORLANDC__ < 0x0550
00209 #  error Versions of Borland C++ prior to 5.5 are not supported by the ATLSTL libraries
00210 # endif /* __BORLANDC__ */
00211 
00212 #elif defined(__STLSOFT_COMPILER_IS_DMC)
00213 /* Digital Mars C/C++ */
00214 # if __DMC__ < 0x0826
00215 #  error Versions of Digital Mars C/C++ prior to 8.26 are not supported by the ATLSTL libraries
00216 # endif /* __DMC__ */
00217 
00218 #elif defined(__STLSOFT_COMPILER_IS_INTEL)
00219 /* Intel C++ */
00220 # if (__INTEL_COMPILER < 600)
00221 #  error Versions of Intel C++ prior to 6.0 are not supported by the ATLSTL libraries
00222 # endif /* __INTEL_COMPILER */
00223 
00224 #elif defined(__STLSOFT_COMPILER_IS_MWERKS)
00225 /* Metrowerks C++ */
00226 # if (__MWERKS__ & 0xFF00) < 0x2400
00227 #  error Versions of Metrowerks CodeWarrior C++ prior to 7.0 are not supported by the ATLSTL libraries
00228 # endif /* __MWERKS__ */
00229 
00230 #elif defined(__STLSOFT_COMPILER_IS_MSVC)
00231 /* Visual C++ */
00232 # if _MSC_VER < 1100
00233 #  error Versions of Visual C++ prior to 5.0 are not supported by the ATLSTL libraries
00234 # endif /* _MSC_VER */
00235 
00236 #else
00237 /* No recognised compiler */
00238 # ifdef _STLSOFT_FORCE_ANY_COMPILER
00239 #  define _ATLSTL_COMPILER_IS_UNKNOWN
00240 #  ifdef _STLSOFT_COMPILE_VERBOSE
00241 #   pragma message("Compiler is unknown to ATLSTL")
00242 #  endif /* _STLSOFT_COMPILE_VERBOSE */
00243 # else
00244 #  error Currently only Borland C++, Digital Mars C/C++, Intel C/C++, Metrowerks CodeWarrior and Visual C++ compilers are supported by the ATLSTL libraries
00245 # endif /* _STLSOFT_FORCE_ANY_COMPILER */
00246 #endif /* compiler */
00247 
00248 /* 
00249  * Debugging
00250  *
00251  * The macro atlstl_assert provides standard debug-mode assert functionality.
00252  */
00253 
00257 #define atlstl_assert(expr)                 stlsoft_assert(expr)
00258 
00263 #define atlstl_message_assert(msg, expr)    stlsoft_message_assert(msg, expr)
00264 
00268 #define atlstl_static_assert(expr)          stlsoft_static_assert(expr)
00269 
00270 /* 
00271  * Namespace
00272  *
00273  * The ATLSTL components are contained within the atlstl namespace. This is
00274  * usually an alias for stlsoft::atlstl_project,
00275  *
00276  * When compilers support namespaces they are defined by default. They can be
00277  * undefined using a cascasing system, as follows:
00278  *
00279  * If _STLSOFT_NO_NAMESPACES is defined, then _ATLSTL_NO_NAMESPACES is defined.
00280  *
00281  * If _ATLSTL_NO_NAMESPACES is defined, then _ATLSTL_NO_NAMESPACE is defined.
00282  *
00283  * If _ATLSTL_NO_NAMESPACE is defined, then the ATLSTL constructs are defined
00284  * in the global scope.
00285  *
00286  * If _STLSOFT_NO_NAMESPACES, _ATLSTL_NO_NAMESPACES and _ATLSTL_NO_NAMESPACE are
00287  * all undefined but the symbol _STLSOFT_NO_NAMESPACE is defined (whence the
00288  * namespace stlsoft does not exist), then the ATLSTL constructs are defined
00289  * within the atlstl namespace. The definition matrix is as follows:
00290  *
00291  * _STLSOFT_NO_NAMESPACE    _ATLSTL_NO_NAMESPACE    atlstl definition
00292  * ---------------------    --------------------    -----------------
00293  *  not defined              not defined             = stlsoft::atlstl_project
00294  *  not defined              defined                 not defined
00295  *  defined                  not defined             atlstl
00296  *  defined                  defined                 not defined
00297  *
00298  *
00299  *
00300  * The macro atlstl_ns_qual() macro can be used to refer to elements in the
00301  * ATLSTL libraries irrespective of whether they are in the
00302  * stlsoft::atlstl_project (or atlstl) namespace or in the global namespace.
00303  *
00304  * Furthermore, some compilers do not support the standard library in the std
00305  * namespace, so the atlstl_ns_qual_std() macro can be used to refer to elements
00306  * in the ATLSTL libraries irrespective of whether they are in the std namespace
00307  * or in the global namespace.
00308  *
00309  *
00310  * The ATL libraries themselves may or may not be defined within the ATL
00311  * namespace, so the atlstl_ns_qual_stl() macro can be used to refer to
00312  * elements in the ATLSTL libraries irrespective of whether they are in the std
00313  * namespace or in the global namespace.
00314  */
00315 
00316 /* No STLSoft namespaces means no ATLSTL namespaces */
00317 #ifdef _STLSOFT_NO_NAMESPACES
00318 # define _ATLSTL_NO_NAMESPACES
00319 #endif /* _STLSOFT_NO_NAMESPACES */
00320 
00321 /* No ATLSTL namespaces means no atlstl namespace */
00322 #ifdef _ATLSTL_NO_NAMESPACES
00323 # define _ATLSTL_NO_NAMESPACE
00324 #endif /* _ATLSTL_NO_NAMESPACES */
00325 
00326 #ifndef _ATLSTL_NO_NAMESPACE
00327 # if defined(_STLSOFT_NO_NAMESPACE) || \
00328      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00329 /* There is no stlsoft namespace, so must define ::atlstl */
00332 namespace atlstl
00333 {
00334 # else
00335 /* Define stlsoft::atlstl_project */
00336 
00337 namespace stlsoft
00338 {
00339 
00340 namespace atlstl_project
00341 {
00342 
00343 # endif /* _STLSOFT_NO_NAMESPACE */
00344 #else
00345 stlsoft_ns_using(move_lhs_from_rhs)
00346 #endif /* !_ATLSTL_NO_NAMESPACE */
00347 
00350 
00353 
00354 #ifndef _ATLSTL_NO_NAMESPACE
00355 # define atlstl_ns_qual(x)          ::atlstl::x
00356 # define atlstl_ns_using(x)         using ::atlstl::x;
00357 #else
00358 # define atlstl_ns_qual(x)          x
00359 # define atlstl_ns_using(x)
00360 #endif /* !_ATLSTL_NO_NAMESPACE */
00361 
00364 
00367 
00368 #ifdef __STLSOFT_CF_std_NAMESPACE
00369 # define atlstl_ns_qual_std(x)      ::std::x
00370 # define atlstl_ns_using_std(x)     using ::std::x;
00371 #else
00372 # define atlstl_ns_qual_std(x)      x
00373 # define atlstl_ns_using_std(x)
00374 #endif /* !__STLSOFT_CF_std_NAMESPACE */
00375 
00378 
00381 
00382 #ifndef ATL_NO_NAMESPACE
00383 # define atlstl_ns_qual_atl(x)       ::ATL::x
00384 # define atlstl_ns_using_atl(x)      using ::ATL::x;
00385 #else
00386 # define atlstl_ns_qual_atl(x)       x
00387 # define atlstl_ns_using_atl(x)
00388 #endif /* !ATL_NO_NAMESPACE */
00389 
00390 /* 
00391  * Typedefs
00392  *
00393  * The ATLSTL uses a number of typedefs to aid in compiler-independence in the
00394  * libraries' main code.
00395  */
00396 
00397 typedef stlsoft_ns_qual(ss_char_a_t)        as_char_a_t;    
00398 typedef stlsoft_ns_qual(ss_char_w_t)        as_char_w_t;    
00399 typedef stlsoft_ns_qual(ss_sint8_t)         as_sint8_t;     
00400 typedef stlsoft_ns_qual(ss_uint8_t)         as_uint8_t;     
00401 typedef stlsoft_ns_qual(ss_int16_t)         as_int16_t;     
00402 typedef stlsoft_ns_qual(ss_sint16_t)        as_sint16_t;    
00403 typedef stlsoft_ns_qual(ss_uint16_t)        as_uint16_t;    
00404 typedef stlsoft_ns_qual(ss_int32_t)         as_int32_t;     
00405 typedef stlsoft_ns_qual(ss_sint32_t)        as_sint32_t;    
00406 typedef stlsoft_ns_qual(ss_uint32_t)        as_uint32_t;    
00407 #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
00408 typedef stlsoft_ns_qual(ss_int64_t)         as_int64_t;     
00409 typedef stlsoft_ns_qual(ss_sint64_t)        as_sint64_t;    
00410 typedef stlsoft_ns_qual(ss_uint64_t)        as_uint64_t;    
00411 #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
00412 typedef stlsoft_ns_qual(ss_int_t)           as_int_t;       
00413 typedef stlsoft_ns_qual(ss_sint_t)          as_sint_t;      
00414 typedef stlsoft_ns_qual(ss_uint_t)          as_uint_t;      
00415 typedef stlsoft_ns_qual(ss_long_t)          as_long_t;      
00416 typedef stlsoft_ns_qual(ss_bool_t)          as_bool_t;      
00417 typedef DWORD                               as_dword_t;     
00418 typedef stlsoft_ns_qual(ss_size_t)          as_size_t;      
00419 typedef stlsoft_ns_qual(ss_ptrdiff_t)       as_ptrdiff_t;   
00420 typedef stlsoft_ns_qual(ss_streampos_t)     as_streampos_t; 
00421 typedef stlsoft_ns_qual(ss_streamoff_t)     as_streamoff_t; 
00422 
00423 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00424 /* 
00425  * Values
00426  *
00427  * Since the boolean type may not be supported natively on all compilers, the
00428  * values of true and false may also not be provided. Hence the values of
00429  * as_true_v and as_false_v are defined, and are used in all code.
00430  */
00431 
00432 #define as_true_v       ss_true_v
00433 #define as_false_v      ss_false_v
00434 
00435 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00436 /* 
00437  * Code modification macros
00438  */
00439 
00440 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00441 /* Exception signatures. */
00442 #define atlstl_throw_0()                                stlsoft_throw_0()
00443 #define atlstl_throw_1(x1)                              stlsoft_throw_1(x1)
00444 #define atlstl_throw_2(x1, x2)                          stlsoft_throw_2(x1, x2)
00445 #define atlstl_throw_3(x1, x2, x3)                      stlsoft_throw_3(x1, x2, x3)
00446 #define atlstl_throw_4(x1, x2, x3, x4)                  stlsoft_throw_4(x1, x2, x3, x4)
00447 #define atlstl_throw_5(x1, x2, x3, x4, x5)              stlsoft_throw_5(x1, x2, x3, x4, x5)
00448 #define atlstl_throw_6(x1, x2, x3, x4, x5, x6)          stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
00449 #define atlstl_throw_7(x1, x2, x3, x4, x5, x6, x7)      stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
00450 #define atlstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)  stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)
00451 #endif /* !__STLSOFT_DOCUMENTATION_SKIP_SECTION */
00452 
00454 #define atlstl_num_elements(ar)                         stlsoft_num_elements(ar)
00455 
00457 #define atlstl_destroy_instance(t, _type, p)            stlsoft_destroy_instance(t, _type, p)
00458 
00460 #define atlstl_gen_opaque(_htype)                       stlsoft_gen_opaque(_htype)
00461 
00462 /* 
00463  * Functions
00464  */
00465 
00469 #if _ATL_VER < 0x0700
00470 inline as_bool_t InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
00471 {
00472    return ( ((as_int32_t*) &rguid1)[0] == ((as_int32_t*) &rguid2)[0] &&
00473             ((as_int32_t*) &rguid1)[1] == ((as_int32_t*) &rguid2)[1] &&
00474             ((as_int32_t*) &rguid1)[2] == ((as_int32_t*) &rguid2)[2] &&
00475             ((as_int32_t*) &rguid1)[3] == ((as_int32_t*) &rguid2)[3]);
00476 }
00477 #endif /* _ATL_VER < 0x0700 */
00478 
00479 /* 
00480  * Unit-testing
00481  */
00482 
00483 #ifdef STLSOFT_UNITTEST
00484 
00485 namespace unittest
00486 {
00487     ss_bool_t test_atlstl(unittest_reporter *r)
00488     {
00489         using stlsoft::unittest::unittest_initialiser;
00490 
00491         ss_bool_t               bSuccess    =   true;
00492         char                    szVersion[101];
00493         unsigned                atlverHi    =   HIBYTE(_ATL_VER);
00494         unsigned                atlverLo    =   HIBYTE(_ATL_VER);
00495 
00496         sprintf(szVersion, "ATL %u.%u", atlverHi, atlverLo);
00497 
00498         unittest_initialiser    init(r, "ATLSTL", szVersion, __FILE__);
00499 
00500         return bSuccess;
00501     }
00502 
00503     unittest_registrar    unittest_stlsoft_string_tokeniser(test_atlstl);
00504 
00505 } // namespace winstl_test
00506 
00507 #endif /* STLSOFT_UNITTEST */
00508 
00509 /* 
00510 
00511 #ifndef _ATLSTL_NO_NAMESPACE
00512 # if defined(_STLSOFT_NO_NAMESPACE) || \
00513      defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00514 } // namespace atlstl
00515 # else
00516 } // namespace atlstl_project
00517 } // namespace stlsoft
00518 namespace atlstl = ::stlsoft::atlstl_project;
00519 # endif /* _STLSOFT_NO_NAMESPACE */
00520 #endif /* !_ATLSTL_NO_NAMESPACE */
00521 
00522 /* 
00523 
00524 #endif /* ATLSTL_INCL_H_ATLSTL */
00525 
00526 /* 

STLSoft Libraries documentation © Synesis Software Pty Ltd, 2001-2004