如何用xygen记录同名的枚举值

How to document enumeration values with same name with Doxygen?

本文关键字:枚举 何用 xygen 记录      更新时间:2023-10-16

我试图用氧记录两个包含一些相似值的类枚举。但是这会为每个具有相同名称的字段生成重复的文本。

下面是我的两个枚举:

/*!
 * 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.*/
};

每个枚举的STACK成员的描述是两个描述的串联,对于GLOBAL也有同样的问题。

STACK的描述为:

堆栈上的变量

堆栈上的操作数

是否有一种方法来具体记录每一个?

解决方法是把它放在一个命名空间中,然后用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)中。