2016-10-05 35 views
1

目前正處在Boost.Log庫中一些奇怪的代碼,例如在BoostFileLogging.cpp,它說Boost_LOG_DOXYGEN_PASS在Boost.Log中是什麼?

#ifndef BOOST_LOG_DOXYGEN_PASS 

#define BOOST_LOG_INIT_LOG_TO_FILE_INTERNAL(z, n, data)\ 
    template< BOOST_PP_ENUM_PARAMS(n, typename T) >\ 
    inline shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL<sinks::text_file_backend> > add_file_log(BOOST_PP_ENUM_BINARY_PARAMS(n, T, const& arg))\ 
    {\ 
     return aux::add_file_log((\ 
      aux::wrap_file_name(arg0, typename parameter::aux::is_named_argument<T0>::type())\ 
      BOOST_PP_COMMA_IF(BOOST_PP_GREATER(n, 1))\ 
      BOOST_PP_ENUM_SHIFTED_PARAMS(n, arg)\ 
      ));\ 
    } 

BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, BOOST_LOG_INIT_LOG_TO_FILE_INTERNAL, ~) 

#undef BOOST_LOG_INIT_LOG_TO_FILE_INTERNAL 

#else // BOOST_LOG_DOXYGEN_PASS 

/*! 
* The function initializes the logging library to write logs to a file stream. 
* 
* \param args A number of named arguments. The following parameters are supported: 
*    \li \c file_name The file name or its pattern. This parameter is mandatory. 
*    \li \c open_mode The mask that describes the open mode for the file. See <tt>std::ios_base::openmode</tt>. 
*    \li \c rotation_size The size of the file at which rotation should occur. See <tt>basic_text_file_backend</tt>. 
*    \li \c time_based_rotation The predicate for time-based file rotations. See <tt>basic_text_file_backend</tt>. 
*    \li \c auto_flush A boolean flag that shows whether the sink should automatically flush the file 
*        after each written record. 
*    \li \c target The target directory to store rotated files in. See <tt>sinks::file::make_collector</tt>. 
*    \li \c max_size The maximum total size of rotated files in the target directory. See <tt>sinks::file::make_collector</tt>. 
*    \li \c min_free_space Minimum free space in the target directory. See <tt>sinks::file::make_collector</tt>. 
*    \li \c scan_method The method of scanning the target directory for log files. See <tt>sinks::file::scan_method</tt>. 
*    \li \c filter Specifies a filter to install into the sink. May be a string that represents a filter, 
*       or a filter lambda expression. 
*    \li \c format Specifies a formatter to install into the sink. May be a string that represents a formatter, 
*       or a formatter lambda expression (either streaming or Boost.Format-like notation). 
* \return Pointer to the constructed sink. 
*/ 
template< typename... ArgsT > 
shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL<sinks::text_file_backend> > add_file_log(ArgsT... const& args); 

#endif // BOOST_LOG_DOXYGEN_PASS 

什麼是該宏的動機是什麼?我應該啓用它還是禁用它?它沒有記錄。

+1

看起來像東西,以方便與doxygen生成documentaiton。 –

回答

3

Doxygen是一個解析源代碼並生成文檔的程序。

這樣做的目的是讓Doxygen看到(和記錄)與真實編譯器看到的東西不同的東西。

在這種情況下,使用Doxygen會看到一個可變參數模板,因此HTML文檔會說這樣的事情:

add_file_log(ArgsT ...常量&參數);

模板參數:

  • 模板<類型名稱... ArgsT>

返回類型:

shared_ptr< BOOST_LOG_FILE_SINK_FRONTEND_INTERNAL<sinks::text_file_backend> > 

函數初始化日誌庫日誌寫入文件流。

...等等

但升壓登錄顯然適用於不支持可變參數模板編譯器,所以真正的編譯器看不到這一點。什麼編譯器看到的是一堆非可變參數模板,東西沿着這些線路(雖然它是不相關的解釋BOOST_LOG_DOXYGEN_PASS):

template<typename Arg1T> shared_ptr</*snip*/> add_file_log(Arg1T const& arg1); 
template<typename Arg1T, typename Arg2T> shared_ptr</*snip*/> add_file_log(Arg1T const& arg1, Arg2T const& arg2); 
template<typename Arg1T, typename Arg2T, typename Arg3T> shared_ptr</*snip*/> add_file_log(Arg1T const& arg1, Arg2T const& arg2, Arg3T const& arg3); 
// and so on 

你不會想對於這些獨立的文檔記錄,那麼它將只是雜亂的文件。