2011-11-30 116 views
7

我想要用Doxygen记录两个包含一些相似值的类枚举。但是,这为相同名称的每个字段生成重复文本。如何用Doxygen记录具有相同名称的枚举值?

这里是我的两个枚举:

/*! 
* \enum OperandType 
* \brief A type of operand. Represents the location of the operand. 
*/ 
enum class OperandType : unsigned int { 
    IMMEDIATE,   /**< An immediate operand */ 
    REGISTER,   /**< An operand in a register */ 
    STACK,    /**< An operand on the stack */ 
    GLOBAL    /**< A global operand */ 
}; 
/*! 
* \enum PositionType 
* \brief A type of position for a variable 
*/ 
enum class PositionType : unsigned int { 
    STACK,   /**< A variable on the stack */ 
    PARAMETER,  /**< A parameter */ 
    GLOBAL,   /**< A global variable */ 
    CONST   /**< A const variable.*/ 
}; 

每个枚举的堆叠成员的描述是既描述的级联和有是全球同样的问题。

栈的描述是:

堆栈

堆栈

有一种方法以特异性记录它们中的每一个上的操作数上的一个变量?

+4

Doxygen对C++ 11的支持很差。 – Pubby

+1

如果您将其中一个枚举放入一个名称空间,然后将该枚举导入父名称空间,是否可行?我会想象有一种不那么丑陋的方式,但我不知道doxygen。希望它的C++ 11支持快速改进 – bames53

回答

2

解决方法是将其放在名称空间中,并将其放置在using之内。

/*! 
* enum class 
*/ 
namespace enum_class { 
    /*! 
    * \enum OperandType 
    * \brief A type of operand. Represents the location of the operand. 
    * Ok 
    */ 
    enum class OperandType : unsigned int { 
     IMMEDIATE,   /**< An immediate operand */ 
      REGISTER,   /**< An operand in a register */ 
     STACK,    /**< An operand on the stack */ 
     GLOBAL    /**< A global operand */ 
    }; 
} 
using enum_class::OperandType; 
/*! 
* \enum PositionType 
* \brief A type of position for a variable 
*/ 
enum class PositionType : unsigned int { 
    STACK,   /**< A variable on the stack */ 
    PARAMETER,  /**< A parameter */ 
    GLOBAL,   /**< A global variable */ 
    CONST   /**< A const variable.*/ 
}; 

你可以把PositionType在不同的命名空间(enumeration),如果你不喜欢的分离。

+0

它可以工作,但枚举记录在enum_class下,而不是在我的名字空间下。我认为这并不理想,因为使用此枚举的人将在根名称空间中搜索文档。有没有办法告诉Doxygen生成使用文档? –

相关问题