log4cplus
2.0.0
|
00001 // -*- C++ -*- 00002 // Copyright (C) 2010-2015, Vaclav Zeman. All rights reserved. 00003 // 00004 // Redistribution and use in source and binary forms, with or without modifica- 00005 // tion, are permitted provided that the following conditions are met: 00006 // 00007 // 1. Redistributions of source code must retain the above copyright notice, 00008 // this list of conditions and the following disclaimer. 00009 // 00010 // 2. Redistributions in binary form must reproduce the above copyright notice, 00011 // this list of conditions and the following disclaimer in the documentation 00012 // and/or other materials provided with the distribution. 00013 // 00014 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00015 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00016 // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00017 // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00018 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 00019 // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00020 // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00021 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00023 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 00025 #ifndef LOG4CPLUS_HELPERS_SNPRINTF_H 00026 #define LOG4CPLUS_HELPERS_SNPRINTF_H 00027 00028 #include <log4cplus/config.hxx> 00029 00030 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00031 #pragma once 00032 #endif 00033 00034 #include <log4cplus/tchar.h> 00035 #include <cstdarg> 00036 #include <vector> 00037 00038 00039 namespace log4cplus { namespace helpers { 00040 00041 00042 class LOG4CPLUS_EXPORT snprintf_buf 00043 { 00044 public: 00045 snprintf_buf (); 00046 00047 tchar const * print (tchar const * fmt, ...) 00048 LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 3); 00049 00050 int print_va_list (tchar const * & str, tchar const * fmt, std::va_list) 00051 LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 3, 0); 00052 00053 private: 00054 std::vector<tchar> buf; 00055 }; 00056 00057 00058 } } // namespace log4cplus { namespace helpers 00059 00060 00061 00062 #endif // LOG4CPLUS_HELPERS_SNPRINTF_H