• <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>

            戰魂小筑

            討論群:309800774 知乎關注:http://zhihu.com/people/sunicdavy 開源項目:https://github.com/davyxu

               :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              257 隨筆 :: 0 文章 :: 506 評論 :: 0 Trackbacks

            protobuf就是為懶人而造的工具, 啥協議, 啥配置文件, 統統定義proto, 解析就ok, 非常方便

             

            文本格式的解析錯誤不能使用捕獲錯誤來獲取, 因此,我們需要使用自定義的錯誤收集器進行收集, 看代碼:

            #include <google/protobuf/text_format.h>
            #include <google/protobuf/io/zero_copy_stream_impl_lite.h>
            #include <google/protobuf/io/tokenizer.h>
             
            class PBTextErrorCollector : public google::protobuf::io::ErrorCollector
            {
            public:
                PBTextErrorCollector( const std::string& FileName )
                    : mFileName( FileName )
                {
             
                }
             
                virtual void AddError(int line, int column, const string& message)
                {
                    CCLog("%s(%d:%d) %s ", mFileName.c_str(), line, column, message.c_str() );
                }
             
                virtual void AddWarning(int line, int column, const string& message) 
                {
                    CCLog("%s(%d:%d) %s ", mFileName.c_str(), line, column, message.c_str() );
                }
             
            private:
                std::string mFileName;
            };
             

            解析代碼

            google::protobuf::TextFormat::Parser P;        
                P.RecordErrorsTo( &PEC );
                P.Parse( &AIS, &AF );

             

            另外: 文本格式的注釋使用unix shell風格: 以#開頭

            下面是我的文本格式的配置文件

             

            AnchorPointX: 0.5
            AnchorPointY: 0
            
            SpriteScale: 2
            
            ComponentName: "ActorActionManager"
            ComponentName: "ActorFrameEventDispatcher"
            #ComponentName: "SoundFXController"
            ComponentName: "RoleDeltaMoveController"
            ComponentName: "RoleBehaviorDirector"
            
            InitAction: AA_Idle
            
            Animations 
            {
              AnimationName: "mai_idle"
              AnimationInterval: 0.067
            }
            
            posted on 2013-07-09 18:29 戰魂小筑 閱讀(7045) 評論(2)  編輯 收藏 引用 所屬分類: 腳本技術游戲開發技術C++/ 編程語言

            評論

            # re: Google Protocolbuf 文本格式的解析 2013-07-10 10:33 永遇樂
            很好,學習了。  回復  更多評論
              

            # re: Google Protocolbuf 文本格式的解析 2013-07-23 17:02 tb
            這工具好啊  回復  更多評論
              

            77777亚洲午夜久久多喷| 国产亚洲精久久久久久无码AV| 超级碰久久免费公开视频| 久久精品国产99国产电影网| 久久精品国产福利国产琪琪| 亚洲精品美女久久久久99| 狠狠色丁香久久综合五月| 久久综合久久鬼色| 精品久久久久久成人AV| 亚洲欧美成人久久综合中文网 | 久久久久亚洲av无码专区喷水 | 精品永久久福利一区二区| 久久国产视屏| 久久精品免费观看| 伊人久久大香线蕉av不变影院| 99久久99久久精品免费看蜜桃| 色婷婷噜噜久久国产精品12p| 久久久无码一区二区三区| 久久综合久久伊人| 四虎国产永久免费久久| 久久亚洲精品成人av无码网站| 久久青青草原精品国产软件| 久久久青草久久久青草| 久久久久亚洲Av无码专| 亚洲精品乱码久久久久久按摩 | 久久性精品| 国产精品免费久久久久影院 | 久久精品国产亚洲麻豆| 久久99国内精品自在现线| 久久久噜噜噜www成人网| 99精品久久精品一区二区| 久久久久青草线蕉综合超碰| 模特私拍国产精品久久| 99久久香蕉国产线看观香| 久久亚洲视频| 久久婷婷人人澡人人爽人人爱| 狠狠色丁香婷婷久久综合五月| 久久这里都是精品| 一本一道久久综合狠狠老| 精品久久久久中文字幕日本| 久久青青草原亚洲av无码app |