Doxygen не может выполнить синтаксический анализ сигнатуры метода в файле cpp, если он отличается от сигнатуры заголовка - причина несоответствия пространства имен из-за `using` - PullRequest
0 голосов
/ 19 марта 2020

У меня есть следующий заголовочный файл:

#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)

Ошибка исчезнет, ​​если вместо использования string_view подписи в методе конструктора cpp я поставлю 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

Очевидно, что это не позволяет мне определять оператор using, и мне нужно переписать весь код, чтобы поместить пространства имен во все аргументы метода и функции, это то, чего мне нужно избегать. Как я могу сказать doxygen, что string_view является std::string_view, и, очевидно, для всех других классов, с которыми я работаю таким же образом?

1 Ответ

1 голос
/ 19 марта 2020

В версии 1.8.15 string_view еще не поддерживается.

В версии 1.8.17 поддерживается string_view, что решает проблему. (ссылка на коммит: Расширить встроенную поддержку STL большим количеством классов (https://github.com/doxygen/doxygen/commit/742927e23a728fffe53e7bfd1d220f7df4c6f552)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...