小森动画回忆录(二)-同步奥特曼属性到程序

上篇说到了如何设计了数据 采用了啥方式

先干了再解释
同步奥特曼属性到程序-源码实现

//从文件加载迪迦奥特曼属性数据到程序中
void LoadUltramanMainAttribute(vector<DejaAltmanAttribute>& dejaAltmanAttribute){
   //打开迪迦奥特曼属性.txt文件读取     
   ifstream stream("迪迦奥特曼属性.txt", ios::in);
  //如果成功打开文件流     
   if (stream.is_open()) {
     //循环读取文件中的每个属性集    
     while (stream) {
       DejaAltmanAttribute de;  
       //读取属性类型 '复合型' 
       stream >> de.Type;
       int num = 0;    
       //再读取7个attribute pair 
       while ( stream && num < 7) {
         //构造pair        
         stream >> PairAttribute.first >> PairAttribute.second;        
         //加入到Attribute容器中    
         de.Attribute.emplace_back(forward<decltype(PairAttribute)>(PairAttribute)); 
          //统计已读属性数 
          num++;  
       }
       //读取完毕一个属性集后,加入到容器中 
       dejaAltmanAttribute.emplace_back(forward<decltype(de)>(de));
     }
   } 
}
一共有 4个这样的奥特曼属性 
`复合型
飞行速度 5马赫 
走行速度 1.5马赫 
水中速度 1.5马赫
地中速度 1.5马赫
跳跃力 800米
握力 5万吨
必杀技 哉佩利敖光线`

	while (stream) {文件流 读到的不是文件结束符
			num = 0; 把num 直0

			DejaAltmanAttribute de;创建DejaAltmanAttribute 结构体变量 de
			stream >> de.Type;读取掉复合型
 			文件流 读到的不是文件结束符 并且没有读到8个
			while (stream && num <7) {
				pair<string, string> PairAttribute;
				读取				飞行速度 		5马赫 
				stream >> PairAttribute.first >> PairAttribute.second;
				放入属性池里
				de.Attribute.emplace_back(forward<decltype(PairAttribute)>(PairAttribute));
				num++;统计提供有多少能读到

			}
			读取完毕后放入到dejaAltmanAttribute里
			dejaAltmanAttribute.emplace_back(forward<decltype(de)>(de));
		}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小森程序员

若能帮助到你,小费自愿付费

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值