Jepessen
Jepessen

Reputation: 12445

Doxygen fails to parse method signature in cpp file when different from header signature cause of namespace mismatch due to `using`

I've the following header file:

#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.
 */

and the following cpp file:

#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

If I try to build doxygen documentation, I obtain following warning (that I manage as error):

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)

The error disappear if instead of using the string_view signature in the cpp constructor method I put std::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

Obviously this doesn't me allow to define the using statement, and I need to rewrite all the code in order to put namespaces in all method and function argument, that's something thatn I need to avoid. How can I tell doxygen that string_view is a std::string_view, and obviously for all other classes that I handle in the same way?

Upvotes: 0

Views: 168

Answers (1)

albert
albert

Reputation: 9077

In version 1.8.15 the string_view was not yet supported.

In version 1.8.17 the string_view is supported and solving the problem. (reference commit: Extend built-in STL support with more classes (https://github.com/doxygen/doxygen/commit/742927e23a728fffe53e7bfd1d220f7df4c6f552)

Upvotes: 1

Related Questions