Kaitai:描述数据的结构,而不是如何读取或写入数据

2020-12-06 00:16:13

std :: ifstream ifs(" path / to / some.gif&#34 ;, std :: ifstream :: binary); kaitai :: kstream ks(& ifs); gif_t g = gif_t(& ks) ; std :: cout<< " width =" << g.logical_screen()-> image_width()<< std :: endl; std :: cout<< "高度=" << g.logical_screen()-> image_height()<< std :: endl; file,err:= os.Open(" path / to / some.gif")g:= NewGif()err = g.Read(kaitai.NewStream(file),g,g)fmt.Printf ("宽度=%d \ n",g.LogicalScreen.ImageWidth)fmt.Printf(" height =%d \ n",g.LogicalScreen.ImageHeight) $ g = Gif :: fromFile(" path / to / some.gif"); print(" width ="。$ g-> logicalScreen()-> imageWidth( )。" \ n"); print(" height ="。$ g-> logicalScreen()-> imageHeight()。" \ n" ); 当然,此示例仅显示Kaitai Struct可以执行的操作的非常有限的子集。 请参阅文档以获取更多见解。