int main() { Interpreter itpr(new UnitTest()); CommandListNode *nlist = Interpreter::parse("if isset show hoge set show msghoge else set msg piyo end"); L("test start"); itpr.execEvent(nlist); for ( auto a : *nlist ) { delete a; } nlist->clear(); delete nlist; nlist = nullptr; if ( nlist != NULL ) delete nlist; L("start hogepiyo"); CommandNode *nod = new CommandNode("hoge", "piyo"); delete nod; auto room = createRoom(); //auto itr = room.find("room_door"); //auto pair = room->begin(); //L(pair->second->at(0)); auto itr = room->find("room_door"); L(itr->second->at(2)); L(StrUtil::trim(" hoge ")); auto data = "a = b\ntesttest\n\nabc=def ef\nhoge=piyo\n"; auto amap = StrUtil::makeAssocMap(data); L(amap->find("a")->second); L(amap->find("abc")->second); L(amap->find("hoge")->second); std::string hoge; L(hoge); if ( hoge == "" ) { L("empty"); } hoge += "piyo"; hoge += ":"; hoge += "test"; L(hoge); std::string st = "9423175742"; L(st[2]); for ( char ch : st ) { L(atoi(&ch)); } return 0; }
int main(int argc, char *argv[]) { if(argc<3) { std::cout<<"usage: "<<"./test [RIF] [ANHO]"<<std::endl; return 0; } char* rif,*anho; rif=argv[1]; anho=argv[2]; DynDlist<UnidadEconomica> nodoraiz, nodofiltrado; std::ofstream file; Chain cadena; FetchRoot root("file.txt"); std::locale loc; rif[0]=std::toupper(rif[0],loc); std::string val; // file.open("out.json"); file.open("media/tmp/out.json"); if(rif[0]=='J'||rif[0]=='G') nodoraiz=root.searchByRif(rif,anho); else nodoraiz=root.searchByCode(rif,anho); file<<"{\t \"Raiz\":\t["; //ELIMINAR NODOS QUE NO TENGAN DATOS PARA MODELAR EN CADENA size_t i; for(DynDlist<UnidadEconomica>::Iterator it(nodoraiz);it.has_curr();it.next()) {i=0; if(!it.get_curr().productos.is_empty()) { for(DynDlist<Productos>::Iterator itpr(it.get_curr().productos);itpr.has_curr();itpr.next()) if(itpr.get_curr().insumos.is_empty()) { swap(itpr.get_curr(),it.get_curr().productos[i]); i++; } for(int n=0;n<i;n++) it.get_curr().productos.pop(); if(!it.get_curr().productos.is_empty()) nodofiltrado.append(it.get_curr()); } } //PARSER MANUAL A FORMATO JSON for(DynDlist<UnidadEconomica>::Iterator it(nodofiltrado);it.has_curr();) { file<<"{ \"roleName\":\""<<it.get_curr().nombre+" "+it.get_curr().rif<<"\",\"roleId\":\""<<it.get_curr().rif<<"\",\"children\":["<<std::endl; for (DynDlist<Productos>::Iterator it1(it.get_curr().productos);it1.has_curr();it1.next()) { file<<"{\"roleName\":\""<<it1.get_curr().nombre+" "+it1.get_curr().cod_aran<<"\",\"roleId\":\""<<it1.get_curr().id<<"\",\"children\":["<<std::endl; for(DynDlist<Insumos>::Iterator it0(it1.get_curr().insumos);it0.has_curr();it0.next()) { file<<"{\"roleName\":\""<<std::get<0>(it0.get_curr()).nombre+" "+std::get<0>(it0.get_curr()).cod_aran<<"\",\"roleId\":\""<<std::get<0>(it0.get_curr()).cantidad<<"\",\"children\":["<<std::endl; for(DynDlist<Proveedor>::Iterator it2(std::get<1>(it0.get_curr()));it2.has_curr();it2.next()) { file<<"{\"roleName\":\""<<it2.get_curr().nombre+" "+it2.get_curr().paisProcedencia<<"\",\"roleId\":\""<<it2.get_curr().rif<<"\",\"children\":[]}"; if(it2.get_pos()!=std::get<1>(it0.get_curr()).size()-1 && std::get<1>(it0.get_curr()).size()!=1) file<<","<<std::endl; } if(it0.get_pos()!=it1.get_curr().insumos.size()-1) file<<"]},"<<std::endl; else file<<"]}"<<std::endl; } if(it1.get_pos()!=it.get_curr().productos.size()-1) file<<"]},"<<std::endl; else file<<"]}"<<std::endl; } if(it.get_pos()!=nodofiltrado.size()-1) file<<"]},"<<std::endl; else file<<"]}"<<std::endl; it.next(); } file<<"]}"; file.close(); std::cout<<std::endl<<"DONE!!"<<std::endl; return 0; }