MemberList GroupControler::MemberToQMemberList(std::vector<std::shared_ptr<service::User> > members) { MemberList memberList; for(auto i: members){ if(i == NULL){ continue; } Member member; std::shared_ptr<service::Member> mem = std::dynamic_pointer_cast<service::Member>(i); if(mem == NULL){ continue; } member.avatar=QString::fromStdString(mem->avatar); if(mem->gender==1){ member.gender="男"; } else if(mem->gender==2){ member.gender="女"; } else{ member.gender="保密"; } member.groupid=QString::number(mem->groupid); member.id=QString::number(mem->id); member.member_type=QString::number(mem->member_type); member.name=QString::fromStdString(mem->name); member.remark=QString::fromStdString(mem->remark); if(member.remark=="#"){ member.remark=member.name; } std::string str=""; char c=mem->team; char sz[5] = {c}; str=sz; if(str.length()>0){ if(str[0]<'A'||str[0]>'Z'){ str[0]='#'; } } member.team=QString::fromStdString(str); if(mem->thumb_avatar!=""){ member.thumbAvatar="/data/data/com.vrv.linkDood/public/head/"+QString::fromStdString(mem->thumb_avatar); } memberList.push_back(member); } return memberList; }
int main() { typedef std::vector<MyClass>::iterator VectIt; typedef std::vector<MyClass>::reverse_iterator VectRit; //Create several MyClass objects, each one with a different value std::vector<MyClass> values; for(int i = 0; i < 100; ++i) values.push_back(MyClass(i)); BaseList baselist; MemberList memberlist; //Now insert them in the reverse order in the base hook list for(VectIt it(values.begin()), itend(values.end()) ; it != itend ; ++it){ baselist.push_front(*it); } //Now insert them in the same order as in vector in the member hook list for(VectIt it(values.begin()), itend(values.end()); it != itend; ++it) memberlist.push_back(*it); //Now test lists { BaseList::reverse_iterator rbit(baselist.rbegin()), rbitend(baselist.rend()); MemberList::iterator mit(memberlist.begin()), mitend(memberlist.end()); VectIt it(values.begin()), itend(values.end()); //Test the objects inserted in the base hook list for(; it != itend; ++it, ++rbit) if(&*rbit != &*it) return 1; //Test the objects inserted in the member hook list for(it = values.begin(); it != itend; ++it, ++mit) if(&*mit != &*it) return 1; } return 0; }