log4cplus  1.1.0
snprintf.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //  Copyright (C) 2010-2012, 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     tchar const * print_va_list (tchar const * fmt, std::va_list)
00050         LOG4CPLUS_FORMAT_ATTRIBUTE (__printf__, 2, 0);
00051 
00052 private:
00053     std::vector<tchar> buf;
00054 };
00055   
00056 
00057 } } // namespace log4cplus { namespace helpers
00058 
00059 
00060 
00061 #endif // LOG4CPLUS_HELPERS_SNPRINTF_H