Doxygen XML输出,用于带有子结构的C lang结构

时间:2018-11-29 10:24:32

标签: c xml struct doxygen

带有子结构的结构由doxygen按预期用于输出格式HTML。

但是对于XML输出格式,它们的处理方式不明确,如下例所示。

test.h

typedef struct {
  struct {
    int   joe;
    short jack;
  } bar;
  struct {
    int   joe;
    short jack;
    long  bill;
  } saloon;
} a;

typedef struct {
  struct {
    int   joe;
    short jack;
  } bar;
  struct {
    int   joe;
    long  bill;
  } saloon;
} b;

Doxyfile

PROJECT_NAME           = Test
OPTIMIZE_OUTPUT_FOR_C  = YES
TYPEDEF_HIDES_STRUCT   = NO
EXTRACT_ALL            = YES
EXTRACT_LOCAL_CLASSES  = YES
FILE_PATTERNS          = *.h 
SOURCE_BROWSER         = NO
GENERATE_HTML          = YES
HTML_OUTPUT            = html
GENERATE_HTMLHELP      = NO
SERVER_BASED_SEARCH    = NO
GENERATE_LATEX         = NO
GENERATE_XML           = YES
XML_OUTPUT             = xml

输出文件 structa.xml structb.xml 相同,除了 refid 属性和结构名称本身。

struct [a | b] .xml 的输出( refid 和struct名称用“ *”代替,空的xml标记被切掉)

<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.8.13" xsi:noNamespaceSchemaLocation="compound.xsd">
    <compounddef id="structa" kind="struct" language="C++" prot="public">
        <compoundname>a</compoundname>
        <includes local="no" refid="test_8h">test.h</includes>
        <sectiondef kind="public-attrib">
            <memberdef id="struct*_*" kind="variable" mutable="no" prot="public" static="no">
                <type>int</type>
                <definition>int a::joe</definition>
                <name>joe</name>
                <location bodyend="-1" bodyfile="test.h" bodystart="*" column="1" file="test.h" line="*" />
            </memberdef>
            <memberdef id="struct*_*" kind="variable" mutable="no" prot="public" static="no">
                <type>short</type>
                <definition>short a::jack</definition>
                <name>jack</name>
                <location bodyend="-1" bodyfile="test.h" bodystart="*" column="1" file="test.h" line="*" />
            </memberdef>
            <memberdef id="struct*_*" kind="variable" mutable="no" prot="public" static="no">
                <type>struct a::@0</type>
                <definition>struct a::@0  a::bar</definition>
                <location column="1" file="test.h" line="*" />
            </memberdef>
            <memberdef id="struct*_*" kind="variable" mutable="no" prot="public" static="no">
                <type>long</type>
                <definition>long a::bill</definition>
                <name>bill</name>
                <location bodyend="-1" bodyfile="test.h" bodystart="*" column="1" file="test.h" line="*" />
            </memberdef>
            <memberdef id="structa_1a4eec237b24903ad639c4f91aad9d8236" kind="variable" mutable="no" prot="public" static="no">
                <type>struct a::@1</type>
                <definition>struct a::@1  a::saloon</definition>
                <name>saloon</name>
                <location column="1" file="test.h" line="*" />
            </memberdef>
        </sectiondef>
    </compounddef>
</doxygen>

在解析XML时,我只能重新创建 a.bar b.bar 。 但是我不能说 a.saloon b.saloon 是否只有成员 bill joe 以及 bill joe jack bill 。 结果是成员 jack 的子结构 a.saloon b.saloon 不同,但是doxygen的XML输出对于< em> a.saloon 和 b.saloon

有没有人想解决此问题以解析XML(而不是解析HTML而不是XML)?

1 个答案:

答案 0 :(得分:0)

为您创建非匿名typedef /结构是一种解决方案

typedef struct A {
  struct BAR {
    int   joe;
    short jack;
  } bar;
  struct SALOON {
    int   joe;
    short jack;
    long  bill;
  } saloon;
} a;

typedef struct B {
  struct BAR {
    int   joe;
    short jack;
  } bar;
  struct SALOON {
    int   joe;
    long  bill;
  } saloon;
} b;