コード例 #1
0
        public void MaterialPrepare()
        {
            if ( null != order_list_ && !order_list_.Count.Equals( 0 ) )
            {
                order_list_.Clear();
            }

            DirectoryInfo materialFolder = null;

            if ( Directory.Exists( material_path_ ) )
            {
                materialFolder = new DirectoryInfo( material_path_ );
            }
            else
            {
                throw new Exception( "Can not find the Material Path" );
            }

            foreach ( FileInfo nextFile in materialFolder.GetFiles( "*.json" ) )
            {
                string                  jsonString          = File.ReadAllText( nextFile.FullName , Encoding.UTF8 );
                List<ProtocolMetaItem>  classMemberDefine   = JsonConvert.DeserializeObject<List<ProtocolMetaItem>>( jsonString );

                HppFileDescrption       oneFile             = new HppFileDescrption();

                oneFile.ClassMemberList                     = classMemberDefine;
                oneFile.NameSpaceString                     = @"Protocol";
                oneFile.ClassName                           = Path.GetFileNameWithoutExtension( nextFile.FullName );
                oneFile.ParentClassName                     = @"Message";
                oneFile.HeaderDictionary.Add( "iostrem" , false );
                oneFile.HeaderDictionary.Add( "<fstream>" , false );
                oneFile.HeaderDictionary.Add( "json.hpp" , true );

                order_list_.Add( oneFile );
            }
        }
コード例 #2
0
        private void GenerateProtocolClassFile( HppFileDescrption hppFileDescrption )
        {
            fragment_root_.AddChild( new Description() );

            DefineGuards defineGuards = new DefineGuards();
            defineGuards.AddGuardMark( hppFileDescrption.DefineGuards );
            fragment_root_.AddChild( defineGuards );

            Headers headers = new Headers();
            fragment_root_.AddChildTo( defineGuards , headers , 0 );
            foreach ( var item in hppFileDescrption.HeaderDictionary )
            {
                headers.AddHeader( item.Key , item.Value );
            }

            NameSpace nmspace = new NameSpace();
            fragment_root_.AddChildTo( defineGuards , nmspace , 0 );
            nmspace.AddNameSpace( hppFileDescrption.NameSpaceString );

            Class cls = new Class();
            fragment_root_.AddChildTo( nmspace , cls , 1 );
            cls.AddClass( hppFileDescrption.ClassName , hppFileDescrption.ParentClassName );
            cls.AddAccessModifer( "public" );

            Dictionary<string , string> param_list = new Dictionary<string , string>();
            param_list.Add( "int"    , "num" );
            param_list.Add( "string" , "str" );
            param_list.Add( "float"  , "flt" );
            cls.AddMethod( "int" , "method1" , param_list );

            cls.AddAccessModifer( "private" );
            cls.AddMethod( "int" , "method2" , null );

            fragment_root_.GenerateAll();
        }