Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

fastformat/format/specification_defect_handling/mismatched_arguments_scope_base.hpp

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        fastformat/format/specification_defect_handling/mismatched_arguments_scope_base.hpp
00003  *
00004  * Purpose:     Base class for scoping classes that customise the behaviour
00005  *              in response to mismatched arguments.
00006  *
00007  * Created:     1st December 2008
00008  * Updated:     30th April 2010
00009  *
00010  * Home:        http://www.fastformat.org/
00011  *
00012  * Copyright (c) 2008-2010, 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
00017  * met:
00018  *
00019  * - Redistributions of source code must retain the above copyright notice,
00020  *   this list of conditions and the following disclaimer.
00021  * - Redistributions in binary form must reproduce the above copyright
00022  *   notice, this list of conditions and the following disclaimer in the
00023  *   documentation and/or other materials provided with the distribution.
00024  * - Neither the names of Matthew Wilson and Synesis Software nor the names
00025  *   of any contributors may be used to endorse or promote products derived
00026  *   from this software without specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00029  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00030  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00031  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00032  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00033  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00034  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00035  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00036  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00037  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00038  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  * ////////////////////////////////////////////////////////////////////// */
00041 
00042 
00049 #ifndef FASTFORMAT_INCL_FASTFORMAT_FORMAT_SPECIFICATION_DEFECT_HANDLING_HPP_MISMATCHED_ARGUMENTS_SCOPE_BASE
00050 #define FASTFORMAT_INCL_FASTFORMAT_FORMAT_SPECIFICATION_DEFECT_HANDLING_HPP_MISMATCHED_ARGUMENTS_SCOPE_BASE
00051 
00052 /* /////////////////////////////////////////////////////////////////////////
00053  * Version information
00054  */
00055 
00056 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00057 # define FASTFORMAT_VER_FASTFORMAT_FORMAT_SPECIFICATION_DEFECT_HANDLING_HPP_MISMATCHED_ARGUMENTS_SCOPE_BASE_MAJOR       1
00058 # define FASTFORMAT_VER_FASTFORMAT_FORMAT_SPECIFICATION_DEFECT_HANDLING_HPP_MISMATCHED_ARGUMENTS_SCOPE_BASE_MINOR       0
00059 # define FASTFORMAT_VER_FASTFORMAT_FORMAT_SPECIFICATION_DEFECT_HANDLING_HPP_MISMATCHED_ARGUMENTS_SCOPE_BASE_REVISION    1
00060 # define FASTFORMAT_VER_FASTFORMAT_FORMAT_SPECIFICATION_DEFECT_HANDLING_HPP_MISMATCHED_ARGUMENTS_SCOPE_BASE_EDIT        4
00061 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00062 
00063 /* /////////////////////////////////////////////////////////////////////////
00064  * Language
00065  */
00066 
00067 #ifndef __cplusplus
00068 # error This file can only be included in C++ compilation units
00069 #endif /* !__cplusplus */
00070 
00071 /* /////////////////////////////////////////////////////////////////////////
00072  * Includes
00073  */
00074 
00075 #include <fastformat/fastformat.h>
00076 #include <fastformat/quality/contract.h>
00077 
00078 /* /////////////////////////////////////////////////////////////////////////
00079  * Namespace
00080  */
00081 
00082 #if !defined(FASTFORMAT_NO_NAMESPACE)
00083 namespace fastformat
00084 {
00085 #endif /* !FASTFORMAT_NO_NAMESPACE */
00086 
00087 /* /////////////////////////////////////////////////////////////////////////
00088  * Classes
00089  */
00090 
00094 class mismatched_arguments_scope_base
00095 {
00096 public: // Member Types
00098     typedef mismatched_arguments_scope_base     class_type;
00099 
00100 protected: // Construction
00106     explicit mismatched_arguments_scope_base(fastformat_mismatchedHandler_t handler, void* param)
00107         : m_previous(fastformat_setThreadMismatchedHandler(handler, param))
00108     {}
00109 public:
00116     virtual ~mismatched_arguments_scope_base() throw()
00117     {
00118         fastformat_setThreadMismatchedHandler(m_previous.handler, m_previous.param);
00119     }
00120 
00121 protected: // Operations
00124     int handle_default(
00125         void*                   /* param */
00126     ,   ff_replacement_code_t   code
00127     ,   size_t                  numParameters
00128     ,   int                     parameterIndex
00129     ,   ff_string_slice_t*      slice
00130     ,   void*                   reserved0
00131     ,   size_t                  reserved1
00132     ,   void*                   reserved2
00133     )
00134     {
00135         if(NULL == m_previous.handler)
00136         {
00137             return +1; // Ignore unreferenced argument
00138         }
00139         else
00140         {
00141             return (m_previous.handler)(m_previous.param, code, numParameters, parameterIndex, slice, reserved0, reserved1, reserved2);
00142         }
00143     }
00144 
00145 private:
00146     mismatched_arguments_scope_base(class_type const&);
00147     class_type& operator =(class_type const&);
00148 
00149 protected:  // A (very) rare use case for protected member data, when using (private) implementation inheritance
00150     mismatched_handler_info_t   m_previous; 
00151 };
00152 
00153 /* /////////////////////////////////////////////////////////////////////////
00154  * Namespace
00155  */
00156 
00157 #if !defined(FASTFORMAT_NO_NAMESPACE)
00158 } /* namespace fastformat */
00159 #endif /* !FASTFORMAT_NO_NAMESPACE */
00160 
00161 /* ////////////////////////////////////////////////////////////////////// */
00162 
00163 #endif /* FASTFORMAT_INCL_FASTFORMAT_FORMAT_SPECIFICATION_DEFECT_HANDLING_HPP_MISMATCHED_ARGUMENTS_SCOPE_BASE */
00164 
00165 /* ///////////////////////////// end of file //////////////////////////// */

FastFormat Library documentation © Matthew Wilson, 2006-2009 SourceForge.net Logo