• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆-341  評論-2670  文章-0  trackbacks-0
                終于到了激動人心的時刻了。今天的博客內容將永遠消除Visual Studio的本地C++XML注釋編譯出來的XML文檔沒有辦法生成可讀文檔的根本原因。

                首先介紹一下C++的XML注釋。在啟用注釋之前,我們必須先去工程屬性里面,把[C/C++ -> Output Files -> Generate Xml Documentation Files]設置成Yes。這樣我們就可以在C++的類啊函數上面寫XML注釋,然后被編譯成一份帶有符號鏈接的XML注釋集合。這里先給一個GacUI的XML注釋的例子:
                        /// <summary>
                        
            /// This is the interface for graphics renderers.
                        
            /// </summary>
                        class IGuiGraphicsRenderer : public Interface
                        {
                        
            public:
                            
            /// <summary>
                            
            /// Access the graphics <see cref="IGuiGraphicsRendererFactory"></see> that is used to create this graphics renderer.
                            
            /// </summary>
                            
            /// <returns>Returns the related factory.</returns>
                            virtual IGuiGraphicsRendererFactory*    GetFactory()=0;

                            
            /// <summary>
                            
            /// Initialize the grpahics renderer by binding a <see cref="IGuiGraphicsElement"></see> to it.
                            
            /// </summary>
                            
            /// <param name="element">The graphics element to bind.</param>
                            virtual void                            Initialize(IGuiGraphicsElement* element)=0;
                            
            /// <summary>
                            
            /// Release all resources that used by this renderer.
                            
            /// </summary>
                            virtual void                            Finalize()=0;
                            
            /// <summary>
                            
            /// Set a <see cref="IGuiGraphicsRenderTarget"></see> to this element.
                            
            /// </summary>
                            
            /// <param name="renderTarget">The graphics render target. It can be NULL.</param>
                            virtual void                            SetRenderTarget(IGuiGraphicsRenderTarget* renderTarget)=0;
                            
            /// <summary>
                            
            /// Render the graphics element using a specified bounds.
                            
            /// </summary>
                            
            /// <param name="bounds">Bounds to decide the size and position of the binded graphics element.</param>
                            virtual void                            Render(Rect bounds)=0;
                            
            /// <summary>
                            
            /// Notify that the state in the binded graphics element is changed. This function is usually called by the element itself.
                            
            /// </summary>
                            virtual void                            OnElementStateChanged()=0;
                            
            /// <summary>
                            
            /// Calculate the minimum size using the binded graphics element and its state.
                            
            /// </summary>
                            
            /// <returns>The minimum size.</returns>
                            virtual Size                            GetMinSize()=0;
                        };

                這個XML注釋的格式是Visual Studio的統一格式。無論C++、C#和VB等語言都可以使用。在編譯之后會給出下面的一個XML文件:
            <?xml version="1.0"?>
            <doc>
                
            <assembly>
                    "GacUISrc"
                
            </assembly>
                
            <members>
                    
                    
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.GetMinSize">
                        
            <summary>
            Calculate the minimum size using the binded graphics element and its state.
            </summary>
                        
            <returns>The minimum size.</returns>
                    
            </member>
                    
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.OnElementStateChanged">
                        
            <summary>
            Notify that the state in the binded graphics element is changed. This function is usually called by the element itself.
            </summary>
                    
            </member>
                    
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.Render(vl.presentation.Rect)">
                        
            <summary>
            Render the graphics element using a specified bounds.
            </summary>
                        
            <param name="bounds">Bounds to decide the size and position of the binded graphics element.</param>
                    
            </member>
                    
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.SetRenderTarget(vl.presentation.elements.IGuiGraphicsRenderTarget*)">
                        
            <summary>
            Set a 
            <see cref="T:vl.presentation.elements.IGuiGraphicsRenderTarget" /> to this element.
            </summary>
                        
            <param name="renderTarget">The graphics render target. It can be NULL.</param>
                    
            </member>
                    
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.Finalize">
                        
            <summary>
            Release all resources that used by this renderer.
            </summary>
                    
            </member>
                    
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.Initialize(vl.presentation.elements.IGuiGraphicsElement*)">
                        
            <summary>
            Initialize the grpahics renderer by binding a 
            <see cref="T:vl.presentation.elements.IGuiGraphicsElement" /> to it.
            </summary>
                        
            <param name="element">The graphics element to bind.</param>
                    
            </member>
                    
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.GetFactory">
                        
            <summary>
            Access the graphics 
            <see cref="T:vl.presentation.elements.IGuiGraphicsRendererFactory" /> that is used to create this graphics renderer.
            </summary>
                        
            <returns>Returns the related factory.</returns>
                    
            </member>
                    
            <member name="T:vl.presentation.elements.IGuiGraphicsRenderer">
                        
            <summary>
            This is the interface for graphics renderers.
            </summary>
                    
            </member>
                    
                
            </members>
            </doc>

                我們可以看出,C++編譯器幫我們把每一個XML注釋都標注了一個符號鏈接的名字,也就是<member name="這里">。T:開頭的是類型,M:開頭的是函數,還有各種各樣的規則都寫在了MSDN里面,大家去查一下就知道了。我們首先回憶一下msdn的.net framework的文檔,文檔里面的每一個類的基類也好,每一個函數的參數類型和返回類型也好,都是超鏈接。為了生成這樣子的文檔,我們首先就要知道一個函數的參數類型和返回類型究竟是什么。但是在這里我們發現這份XML并不包含這個內容。這也是為什么找不到一個生成本地C++XML注釋的可讀文檔工具的原因。而C++/CLI也好,.net的其他語言也好,都有這樣的工具,因為.net的可執行文件可以反射出每一個符號的所有細節內容。

                這也就是為什么有上一篇博客的原因。既然可執行文件不包含元數據,那么pdb總包含的吧。良心的Visual Studio提供了我們msdia100.dll這個COM庫,使得我們可以做到從pdb讀取符號內容的事情。當然上一篇博客是針對VisualStudio本地C++編譯出來的pdb開發的,不能適合所有種類的pdb。

                有了這個pdb之后,我們把pdb用C++調用msdia100.dll先生成一份xml,然后就可以用偉大的.net linq to xml來完成接下來的事情了。現在我們手上有了兩份xml,一份是xml注釋,另一份是pdb符號表。利用Vczh Library++ 3.0的[Tools\Release\SideProjects\GacUISrc\Xml2Doc\Xml2Doc.csproj]項目里面的代碼,就可以將這兩份xml合并成第三份xml了:
            <?xml version="1.0" encoding="utf-8"?>
            <cppdoc>
              
            <namespace name="">
                
            <namespace name="vl">
                  
            <namespace name="presentation">
                    
            <namespace name="elements">
                      
                      
            <type name="IGuiGraphicsRenderer" fullName="vl::presentation::elements::IGuiGraphicsRenderer">
                        
            <document>
                          
            <member name="T:vl.presentation.elements.IGuiGraphicsRenderer">
                            
            <summary>
            This is the interface for graphics renderers.
            </summary>
                          
            </member>
                        
            </document>
                        
            <functionGroup name="GetMinSize">
                          
            <function name="GetMinSize" fullName="GetMinSize" isStatic="true" access="Public" kind="Abstract">
                            
            <returnType>vl::presentation::Size</returnType>
                            
            <document>
                              
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.GetMinSize">
                                
            <summary>
            Calculate the minimum size using the binded graphics element and its state.
            </summary>
                                
            <returns>The minimum size.</returns>
                              
            </member>
                            
            </document>
                          
            </function>
                        
            </functionGroup>
                        
            <functionGroup name="OnElementStateChanged">
                          
            <function name="OnElementStateChanged" fullName="OnElementStateChanged" isStatic="true" access="Public" kind="Abstract">
                            
            <returnType>void</returnType>
                            
            <document>
                              
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.OnElementStateChanged">
                                
            <summary>
            Notify that the state in the binded graphics element is changed. This function is usually called by the element itself.
            </summary>
                              
            </member>
                            
            </document>
                          
            </function>
                        
            </functionGroup>
                        
            <functionGroup name="Render">
                          
            <function name="Render" fullName="Render" isStatic="true" access="Public" kind="Abstract">
                            
            <returnType>void</returnType>
                            
            <parameterType>vl::presentation::Rect</parameterType>
                            
            <document>
                              
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.Render(vl.presentation.Rect)">
                                
            <summary>
            Render the graphics element using a specified bounds.
            </summary>
                                
            <param name="bounds">Bounds to decide the size and position of the binded graphics element.</param>
                              
            </member>
                            
            </document>
                          
            </function>
                        
            </functionGroup>
                        
            <functionGroup name="SetRenderTarget">
                          
            <function name="SetRenderTarget" fullName="SetRenderTarget" isStatic="true" access="Public" kind="Abstract">
                            
            <returnType>void</returnType>
                            
            <parameterType>vl::presentation::elements::IGuiGraphicsRenderTarget*</parameterType>
                            
            <document>
                              
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.SetRenderTarget(vl.presentation.elements.IGuiGraphicsRenderTarget*)">
                                
            <summary>
            Set a 
            <see cref="T:vl.presentation.elements.IGuiGraphicsRenderTarget" /> to this element.
            </summary>
                                
            <param name="renderTarget">The graphics render target. It can be NULL.</param>
                              
            </member>
                            
            </document>
                          
            </function>
                        
            </functionGroup>
                        
            <functionGroup name="Finalize">
                          
            <function name="Finalize" fullName="Finalize" isStatic="true" access="Public" kind="Abstract">
                            
            <returnType>void</returnType>
                            
            <document>
                              
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.Finalize">
                                
            <summary>
            Release all resources that used by this renderer.
            </summary>
                              
            </member>
                            
            </document>
                          
            </function>
                        
            </functionGroup>
                        
            <functionGroup name="Initialize">
                          
            <function name="Initialize" fullName="Initialize" isStatic="true" access="Public" kind="Abstract">
                            
            <returnType>void</returnType>
                            
            <parameterType>vl::presentation::elements::IGuiGraphicsElement*</parameterType>
                            
            <document>
                              
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.Initialize(vl.presentation.elements.IGuiGraphicsElement*)">
                                
            <summary>
            Initialize the grpahics renderer by binding a 
            <see cref="T:vl.presentation.elements.IGuiGraphicsElement" /> to it.
            </summary>
                                
            <param name="element">The graphics element to bind.</param>
                              
            </member>
                            
            </document>
                          
            </function>
                        
            </functionGroup>
                        
            <functionGroup name="GetFactory">
                          
            <function name="GetFactory" fullName="GetFactory" isStatic="true" access="Public" kind="Abstract">
                            
            <returnType>vl::presentation::elements::IGuiGraphicsRendererFactory*</returnType>
                            
            <document>
                              
            <member name="M:vl.presentation.elements.IGuiGraphicsRenderer.GetFactory">
                                
            <summary>
            Access the graphics 
            <see cref="T:vl.presentation.elements.IGuiGraphicsRendererFactory" /> that is used to create this graphics renderer.
            </summary>
                                
            <returns>Returns the related factory.</returns>
                              
            </member>
                            
            </document>
                          
            </function>
                        
            </functionGroup>
                      
            </type>
                      
                    
            </namespace>
                  
            </namespace>
                
            </namespace>
              
            </namespace>
            </cppdoc>

                現在一個類型和函數的xml注釋也好,他的基類啊函數的參數類型返回類型也好,全部都出現了。下面可以做的事情就很多了。譬如說自己寫一個xml到html文檔的轉換程序啦,或者用偉大的.net linq to xml把這個xml一轉成為其他xml格式,然后使用現有的工具生成文檔啦,所有的事情都可以做了。

                我接下來會根據GacUI的情況不斷增加這個小工具的功能,最終讓他可以產生一份好的GacUI的文檔,不僅包含XML注釋的內容,還可以包含外部插入的tutorial啊,帶高亮的code sample等等。
            posted on 2012-03-09 17:04 陳梓瀚(vczh) 閱讀(6775) 評論(7)  編輯 收藏 引用 所屬分類: C++GacUI

            評論:
            # re: 合并Visual Studio本地C++XML注釋文檔和PDB的符號內容 2012-03-09 18:09 | ArthasLee
            果然是GaCGUI的作者,尼桑跟我深感安慰阿魯~  回復  更多評論
              
            # re: 合并Visual Studio本地C++XML注釋文檔和PDB的符號內容 2012-03-10 00:27 | 空明流轉
            你做個EXE吧。  回復  更多評論
              
            # re: 合并Visual Studio本地C++XML注釋文檔和PDB的符號內容 2012-03-10 01:09 | 布拉德比特
            竊以為還是doxygen比較爽....  回復  更多評論
              
            # re: 合并Visual Studio本地C++XML注釋文檔和PDB的符號內容 2012-03-10 02:00 | 陳梓瀚(vczh)
            @空明流轉
            exe已經有了。  回復  更多評論
              
            # re: 合并Visual Studio本地C++XML注釋文檔和PDB的符號內容 2012-03-10 22:56 | tb
            牛人啊   回復  更多評論
              
            # re: 合并Visual Studio本地C++XML注釋文檔和PDB的符號內容 2012-03-12 04:42 | 裝配腦袋
            感覺你做的越來越多,但離一個普通用戶能夠容易使用的親切狀態越來越遠了。。  回復  更多評論
              
            # re: 合并Visual Studio本地C++XML注釋文檔和PDB的符號內容 2012-03-12 09:48 | 陳梓瀚(vczh)
            @裝配腦袋
            這個純粹是類似于source depot的tools目錄下面的程序,用戶是不需要管的,啊哈哈哈哈,他們只要用preprocess過的東西就行了。  回復  更多評論
              
            AV无码久久久久不卡蜜桃| 欧美精品福利视频一区二区三区久久久精品 | 久久精品国产免费| 久久久艹| 久久久久久av无码免费看大片| 久久久受www免费人成| 久久久久亚洲精品天堂| 狠狠精品久久久无码中文字幕| 久久久艹| 国产一区二区三区久久| 久久久精品国产| 久久福利资源国产精品999| 久久久久亚洲AV成人网人人网站 | 精品久久久久久中文字幕大豆网 | 人妻无码αv中文字幕久久琪琪布| 青青青青久久精品国产h久久精品五福影院1421| 久久妇女高潮几次MBA| 品成人欧美大片久久国产欧美| 亚洲狠狠综合久久| 国产福利电影一区二区三区久久久久成人精品综合 | 久久久精品人妻一区二区三区蜜桃| 久久婷婷五月综合色奶水99啪| 久久无码人妻精品一区二区三区| 国产成人久久激情91| 久久久精品午夜免费不卡| a级毛片无码兔费真人久久| 久久精品国产亚洲AV嫖农村妇女| 热99RE久久精品这里都是精品免费 | 日产精品久久久久久久| 久久亚洲精品无码VA大香大香| 久久久久久亚洲精品不卡| 日本免费久久久久久久网站| 欧美噜噜久久久XXX| 少妇久久久久久久久久| 99久久精品国产麻豆| 久久久精品人妻一区二区三区四 | 久久综合视频网站| 亚洲?V乱码久久精品蜜桃| 欧美国产精品久久高清| 久久这里都是精品| 久久精品中文字幕一区|