Example #1
0
		//-----------------------------------------------------------------//
		unit_map_its create_list(const std::string& root)
		{
			unit_map_its list;
			if(unit_map_.empty()) {
				list.clear();
				return list;
			}

			if(root.empty()) {
				list.resize(unit_map_.size());
				list.clear();
				for(unit_map_it it = unit_map_.begin(); it != unit_map_.end(); ++it) {
					list.push_back(it);
				}
			} else {
				auto fpath = create_full_path(root);
				if(fpath.empty()) {
					list.clear();
					return list;
				}

				unit_map_it it = unit_map_.find(fpath);
				if(it != unit_map_.end()) {
					const typename unit_t::childs& ch = it->second.get_childs();
					list.resize(ch.size());
					list.clear();
					for(const auto& s : ch) {
						auto path = create_full_path(s);
						if(!path.empty()) {
							it = unit_map_.find(path);
							if(it != unit_map_.end()) {
								list.push_back(it);
							}
						}
					}
				} else {
					list.clear();
				}
			}

			std::sort(list.begin(), list.end(), [] (unit_map_it l, unit_map_it r) {
				return l->first < r->first; }
			);

			return list;
		}