2011-11-30 117 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生成使用文檔? –

相關問題