当与 header 签名不同时,Doxygen 无法解析 cpp 文件中的方法签名,因为 `using` 导致命名空间不匹配
Doxygen fails to parse method signature in cpp file when different from header signature cause of namespace mismatch due to `using`
我有以下 header 文件:
#ifndef LOGIN_STATEMACHINE_EXCEPTION_HPP_
#define LOGIN_STATEMACHINE_EXCEPTION_HPP_
#include "LoginLib/StateMachine/Global.hpp"
#include "LoginLib/Common/Exception.hpp"
#include <string_view>
#include <string>
namespace LoginLib {
namespace StateMachine {
class Exception : public Common::Exception {
public:
LOGINLIB_STATEMACHINE_LIB Exception(std::string_view message);
virtual ~Exception() = default;
};
} // namespace StateMachine
} // namespace LoginLib
#endif // !LOGIN_STATEMACHINE_EXCEPTION_HPP_
///////////////////////////////////////////////////////////////////////////////
// DOCUMENTATION //
///////////////////////////////////////////////////////////////////////////////
/**
* @class LoginLib::StateMachine::Exception
*
* @brief Exception class for state machine library
*
* This is the exception that's raised when the state machine library launches
* an exception.
*/
和以下 cpp 文件:
#include "LoginLib/StateMachine/Exception.hpp"
namespace LoginLib {
namespace StateMachine {
///////////////////////////////////////////////////////////////////////////////
// USING SECTION //
///////////////////////////////////////////////////////////////////////////////
using std::string_view;
///////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
/**
* @brief Message constructor.
*
* This constructor allows to define a message that must be associated with the
* exception.
*
* @param[in] message Message that must be set.
*/
Exception::Exception(string_view message) :
Common::Exception(std::string(message)) {
}
} // namespace StateMachine
} // namespace LoginLib
如果我尝试构建 doxygen 文档,我会收到以下警告(我管理为错误):
H:/path/Exception.cpp:24: error: no matching class member found for
LoginLib::StateMachine::Exception::Exception(string_view message)
Possible candidates:
LOGINLIB_COMMON_LIB LoginLib::Common::Exception::Exception(const std::string &message)
LOGINLIB_STATEMACHINE_LIB LoginLib::StateMachine::Exception::Exception(std::string_view message)
(warning treated as error, aborting now)
如果我在 cpp 构造函数方法中使用 std::string_view
:
而不是使用 string_view
签名,错误就会消失
#include "LoginLib/StateMachine/Exception.hpp"
namespace LoginLib {
namespace StateMachine {
///////////////////////////////////////////////////////////////////////////////
// USING SECTION //
///////////////////////////////////////////////////////////////////////////////
using std::string_view;
///////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
/**
* @brief Message constructor.
*
* This constructor allows to define a message that must be associated with the
* exception.
*
* @param[in] message Message that must be set.
*/
Exception::Exception(std::string_view message) :
Common::Exception(std::string(message)) {
}
} // namespace StateMachine
} // namespace LoginLib
显然这不允许我定义 using
语句,我需要重写所有代码以便将命名空间放入所有方法和函数参数中,这是我需要避免的事情。我如何告诉 doxygen string_view
是一个 std::string_view
,显然对于我以相同方式处理的所有其他 类?
在版本 1.8.15 中 string_view
尚不支持。
1.8.17版本支持string_view
并解决了问题。
(参考提交:使用更多 类 (https://github.com/doxygen/doxygen/commit/742927e23a728fffe53e7bfd1d220f7df4c6f552)
扩展内置 STL 支持
我有以下 header 文件:
#ifndef LOGIN_STATEMACHINE_EXCEPTION_HPP_
#define LOGIN_STATEMACHINE_EXCEPTION_HPP_
#include "LoginLib/StateMachine/Global.hpp"
#include "LoginLib/Common/Exception.hpp"
#include <string_view>
#include <string>
namespace LoginLib {
namespace StateMachine {
class Exception : public Common::Exception {
public:
LOGINLIB_STATEMACHINE_LIB Exception(std::string_view message);
virtual ~Exception() = default;
};
} // namespace StateMachine
} // namespace LoginLib
#endif // !LOGIN_STATEMACHINE_EXCEPTION_HPP_
///////////////////////////////////////////////////////////////////////////////
// DOCUMENTATION //
///////////////////////////////////////////////////////////////////////////////
/**
* @class LoginLib::StateMachine::Exception
*
* @brief Exception class for state machine library
*
* This is the exception that's raised when the state machine library launches
* an exception.
*/
和以下 cpp 文件:
#include "LoginLib/StateMachine/Exception.hpp"
namespace LoginLib {
namespace StateMachine {
///////////////////////////////////////////////////////////////////////////////
// USING SECTION //
///////////////////////////////////////////////////////////////////////////////
using std::string_view;
///////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
/**
* @brief Message constructor.
*
* This constructor allows to define a message that must be associated with the
* exception.
*
* @param[in] message Message that must be set.
*/
Exception::Exception(string_view message) :
Common::Exception(std::string(message)) {
}
} // namespace StateMachine
} // namespace LoginLib
如果我尝试构建 doxygen 文档,我会收到以下警告(我管理为错误):
H:/path/Exception.cpp:24: error: no matching class member found for
LoginLib::StateMachine::Exception::Exception(string_view message)
Possible candidates:
LOGINLIB_COMMON_LIB LoginLib::Common::Exception::Exception(const std::string &message)
LOGINLIB_STATEMACHINE_LIB LoginLib::StateMachine::Exception::Exception(std::string_view message)
(warning treated as error, aborting now)
如果我在 cpp 构造函数方法中使用 std::string_view
:
string_view
签名,错误就会消失
#include "LoginLib/StateMachine/Exception.hpp"
namespace LoginLib {
namespace StateMachine {
///////////////////////////////////////////////////////////////////////////////
// USING SECTION //
///////////////////////////////////////////////////////////////////////////////
using std::string_view;
///////////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION //
///////////////////////////////////////////////////////////////////////////////
/**
* @brief Message constructor.
*
* This constructor allows to define a message that must be associated with the
* exception.
*
* @param[in] message Message that must be set.
*/
Exception::Exception(std::string_view message) :
Common::Exception(std::string(message)) {
}
} // namespace StateMachine
} // namespace LoginLib
显然这不允许我定义 using
语句,我需要重写所有代码以便将命名空间放入所有方法和函数参数中,这是我需要避免的事情。我如何告诉 doxygen string_view
是一个 std::string_view
,显然对于我以相同方式处理的所有其他 类?
在版本 1.8.15 中 string_view
尚不支持。
1.8.17版本支持string_view
并解决了问题。
(参考提交:使用更多 类 (https://github.com/doxygen/doxygen/commit/742927e23a728fffe53e7bfd1d220f7df4c6f552)