【问题标题】:Problem with doxygen and templates in .tpp file.tpp 文件中的 doxygen 和模板问题
【发布时间】:2019-05-11 07:10:48
【问题描述】:

我已经开始使用 Doxygen(预编译 1.8.14)在 Windows 10 上为我的 C++ 项目生成简单的代码文档。

在一个头文件中,我定义了三个模板化函数,我的定义被放置在一个包含在头文件末尾的 .tpp 文件中。查看生成的输出,似乎 doxygen 没有读取此文件。 因此我得出结论 doxygen 不支持这个

但是根据手册 (http://www.doxygen.nl/manual/starting.html),它说“任何其他扩展都被解析为 C/C++ 文件。”这种功能真的没有实现吗?

IPC.hpp(示例)

class IPC {
public:
    template <class T, int N>
    bool setData(std::vector<T> data, Offsets offset);

    template <class T, int N>
    std::array<T, N> getData(Offsets offset);

    template <class T, int N>
    bool getData(std::array<T, N> &data, Offsets offset);

    bool getTrigger(Offsets selector, long timeout_ms = 0);
    void setTrigger(Offsets selector, Status on);
};

#include "IPC.tpp"

IPC.tpp(示例)

#pragma once
/*! Writes to the shared memory object.

    \param data gives the data that will be written.
    \param offset gives the byte offset from the start of the file.

    \return bool: true on completion

    \sa getData()
*/
template <class T, int N>
bool IPC::setData(std::vector<T> data, Offsets offset) {
    //Calculate the memory block size from the type and number
    unsigned int block_size = sizeof(T) * N;

    //Safety check
    if (block_size + offset > _size) {
        std::cerr << "Error at IPC::setData(): Block size is bigger than memory block size" << std::endl;
        return false;
    }

    if (data.size() < N) {
        std::cerr << "Error at IPC::setData(): Data array is smaller than N" << std::endl;
        return false;
    }

    //Create mapped_region
    mapped_region region(_shm, read_write, offset, block_size);

    for (int i = 0; i < N; i++) {
        std::memcpy((char* ) region.get_address() + sizeof(T) * i, &(data.at(i)), sizeof(T));
    }

    return true;
}

【问题讨论】:

  • 所提到的句子可能不再准确。您是否将tpp 扩展名添加到FILE_PATTERNS?同时设置tppEXTENSION_MAPPING的映射
  • @albert 我使用了 doxywizard GUI,这是 Doxyfile 中的设置吗?
  • 这些是 Doxyfile 中的设置,但可以在 doxywizard 以及 expert 选项卡和子项 inputproject 中访问。
  • @albert 成功了!
  • 1.8.15 版本的文档中有更好的描述。

标签: c++ templates doxygen


【解决方案1】:

供将来参考:将tpp=C++ 添加到EXTENSION_MAPPING(在doxywizard 中的expert/project 下)和*.tppFILE_PATTERNS(在doxywizard 中的expert/input 下)。

【讨论】:

  • 对不起,这对我还没有用。由于某种原因,我在依赖图中有几个标题显示为绝对路径 - 输入没有什么不同 - 但是当 x.tpp 存在时,这通常发生在 x.hpp 上。 (我立即找到了一个反例,但至少这是一种趋势。)文件名都不是依赖关系图中的链接,也不是引用的链接包含部分,甚至从 x.tpp 到 x.hpp 都没有显示依赖关系图表。有任何想法吗?谢谢!
猜你喜欢
  • 2021-03-07
  • 2020-10-05
  • 2012-08-25
  • 1970-01-01
  • 1970-01-01
  • 2013-05-22
  • 1970-01-01
  • 1970-01-01
  • 2015-01-14
相关资源
最近更新 更多