Ejemplo n.º 1
0
    /**
     * @return True if the data should be deleted.
     */
    bool MaskWorkspace::isMasked(const std::set<detid_t> &detectorIDs) const
    {
      if (detectorIDs.empty())
      {
        return false;
      }

      bool masked(true);
      for (std::set<detid_t>::const_iterator it = detectorIDs.begin(); it != detectorIDs.end(); ++it)
      {
        if (!this->isMasked(*it))
        {
          masked = false;
          break; // allows space for a debug print statement
        }
      }
      return masked;
    }
Ejemplo n.º 2
0
/*
 * Search object in database using its key
 * \param key is the 64 bits row key to search through all tables
 */
bool	CDatabase::searchObjectIndex(uint64 key, std::set<RY_PDS::CObjectIndex>& indexes) const
{
	indexes.clear();

	uint	i;
	for (i=0; i<_Tables.size(); ++i)
	{
		if (_Tables[i] == NULL || !_Tables[i]->initialised() || !_Tables[i]->isMapped())
			continue;

		RY_PDS::CObjectIndex	index = _Tables[i]->getMappedRow(key);

		if (index.isValid())
			indexes.insert(index);
	}

	return !indexes.empty();
}
Ejemplo n.º 3
0
void CFileItemHandler::FillDetails(const ISerializable *info, const CFileItemPtr &item, std::set<std::string> &fields, CVariant &result, CThumbLoader *thumbLoader /* = NULL */)
{
  if (info == NULL || fields.empty())
    return;

  CVariant serialization;
  info->Serialize(serialization);

  bool fetchedArt = false;

  std::set<std::string> originalFields = fields;

  for (std::set<std::string>::const_iterator fieldIt = originalFields.begin(); fieldIt != originalFields.end(); ++fieldIt)
  {
    if (GetField(*fieldIt, serialization, item, result, fetchedArt, thumbLoader) && result.isMember(*fieldIt) && !result[*fieldIt].empty())
      fields.erase(*fieldIt);
  }
}
std::set<T> MonsterGenerator::get_set_from_tags(std::set<std::string> tags,
                                                std::map<std::string, T> conversion_map, T fallback)
{
    std::set<T> ret;

    if (!tags.empty()){
        for (std::set<std::string>::iterator it = tags.begin(); it != tags.end(); ++it){
            if (conversion_map.find(*it) != conversion_map.end()){
                ret.insert(conversion_map[*it]);
            }
        }
    }
    if (ret.empty()){
        ret.insert(fallback);
    }

    return ret;
}
Ejemplo n.º 5
0
std::set<T> MonsterGenerator::get_set_from_tags(std::set<std::string> tags,
        std::map<std::string, T> conversion_map, T fallback)
{
    std::set<T> ret;

    if (!tags.empty()) {
        for( const auto &tag : tags ) {
            if( conversion_map.find( tag ) != conversion_map.end() ) {
                ret.insert( conversion_map[tag] );
            }
        }
    }
    if (ret.empty()) {
        ret.insert(fallback);
    }

    return ret;
}
Ejemplo n.º 6
0
void HlslLinker::emitLibraryFunctions(const std::set<TOperator>& libFunctions, EShLanguage lang, bool usePrecision)
{
	// library Functions & required extensions
	std::string shaderLibFunctions;
	if (!libFunctions.empty())
	{
		for (std::set<TOperator>::const_iterator it = libFunctions.begin(); it != libFunctions.end(); it++)
		{
			const std::string &func = getHLSLSupportCode(*it, m_Extensions, lang==EShLangVertex, usePrecision);
			if (!func.empty())
			{
				shaderLibFunctions += func;
				shaderLibFunctions += '\n';
			}
		}
	}
	shader << shaderLibFunctions;
}
Ejemplo n.º 7
0
void CheckInternal::checkUnknownPattern()
{
    static std::set<std::string> knownPatterns;
    if (knownPatterns.empty()) {
        knownPatterns.insert("%any%");
        knownPatterns.insert("%var%");
        knownPatterns.insert("%type%");
        knownPatterns.insert("%num%");
        knownPatterns.insert("%bool%");
        knownPatterns.insert("%str%");
        knownPatterns.insert("%varid%");
        knownPatterns.insert("%or%");
        knownPatterns.insert("%oror%");
        knownPatterns.insert("%op%");
    }

    for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
        if (!Token::simpleMatch(tok, "Token :: Match (") && !Token::simpleMatch(tok, "Token :: findmatch ("))
            continue;

        // Get pattern string
        const Token *pattern_tok = tok->tokAt(4)->nextArgument();
        if (!pattern_tok || pattern_tok->type() != Token::eString)
            continue;

        const std::string pattern = pattern_tok->strValue();
        bool inBrackets = false;

        for (std::string::size_type i = 0; i < pattern.length()-1; i++) {
            if (pattern[i] == '[' && (i == 0 || pattern[i-1] == ' '))
                inBrackets = true;
            else if (pattern[i] == ']')
                inBrackets = false;
            else if (pattern[i] == '%' && pattern[i+1] != ' ' && pattern[i+1] != '|' && !inBrackets) {
                std::string::size_type end = pattern.find('%', i+1);
                if (end != std::string::npos) {
                    std::string s = pattern.substr(i, end-i+1);
                    if (knownPatterns.find(s) == knownPatterns.end())
                        unknownPatternError(tok, s);
                }
            }
        }
    }
}
Ejemplo n.º 8
0
    ItemStack::ItemStack(const MWWorld::Ptr &base, ItemModel *creator, size_t count)
        : mType(Type_Normal)
        , mFlags(0)
        , mCreator(creator)
        , mCount(count)
        , mBase(base)
    {
        if (base.getClass().getEnchantment(base) != "")
            mFlags |= Flag_Enchanted;

        static std::set<std::string> boundItemIDCache;

        // If this is empty then we haven't executed the GMST cache logic yet; or there isn't any sMagicBound* GMST's for some reason
        if (boundItemIDCache.empty())
        {
            // Build a list of known bound item ID's
            const MWWorld::Store<ESM::GameSetting> &gameSettings = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

            for (MWWorld::Store<ESM::GameSetting>::iterator currentIteration = gameSettings.begin(); currentIteration != gameSettings.end(); ++currentIteration)
            {
                const ESM::GameSetting &currentSetting = *currentIteration;
                std::string currentGMSTID = currentSetting.mId;
                Misc::StringUtils::toLower(currentGMSTID);

                // Don't bother checking this GMST if it's not a sMagicBound* one.
                const std::string& toFind = "smagicbound";
                if (currentGMSTID.compare(0, toFind.length(), toFind) != 0)
                    continue;

                // All sMagicBound* GMST's should be of type string
                std::string currentGMSTValue = currentSetting.getString();
                Misc::StringUtils::toLower(currentGMSTValue);

                boundItemIDCache.insert(currentGMSTValue);
            }
        }

        // Perform bound item check and assign the Flag_Bound bit if it passes
        std::string tempItemID = base.getCellRef().getRefId();
        Misc::StringUtils::toLower(tempItemID);

        if (boundItemIDCache.count(tempItemID) != 0)
            mFlags |= Flag_Bound;
    }
Ejemplo n.º 9
0
config vconfig::get_parsed_config() const
{
	// Keeps track of insert_tag variables.
	static std::set<std::string> vconfig_recursion;

	config res;

	BOOST_FOREACH(const config::attribute &i, cfg_->attribute_range()) {
		res[i.first] = expand(i.first);
	}

	BOOST_FOREACH(const config::any_child &child, cfg_->all_children_range())
	{
		if (child.key == "insert_tag") {
			vconfig insert_cfg(child.cfg);
			const t_string& name = insert_cfg["name"];
			const t_string& vname = insert_cfg["variable"];
			if(!vconfig_recursion.insert(vname).second) {
				throw recursion_error("vconfig::get_parsed_config() infinite recursion detected, aborting");
			}
			try
			{
				config::const_child_itors range = as_nonempty_range(vname);
				BOOST_FOREACH(const config& child, range)
				{
					res.add_child(name, vconfig(child).get_parsed_config());
				}
			}
			catch(const invalid_variablename_exception&)
			{
				res.add_child(name);
			}
			catch(recursion_error &err) {
				vconfig_recursion.erase(vname);
				WRN_NG << err.message << std::endl;
				if(vconfig_recursion.empty()) {
					res.add_child("insert_tag", insert_cfg.get_config());
				} else {
					// throw to the top [insert_tag] which started the recursion
					throw;
				}
			}
			vconfig_recursion.erase(vname);
		} else {
Ejemplo n.º 10
0
void XLHighlighter::highlightNames(int index, std::set<text> &names)
// ----------------------------------------------------------------------------
//    Set the words to highlight as XL names or symbols
// ----------------------------------------------------------------------------
{
    HighlightingRule &nameRule = highlightingRules[index];
    if (names.empty())
    {
        nameRule.begin = QRegExp("");
        return;
    }
    QStringList w;
    for (std::set<text>::iterator n = names.begin(); n != names.end(); n++)
        w << QRegExp::escape(+*n);
    QString exp = w.join("|");
    if (index != 1)
        exp = QString("\\b(%1)\\b").arg(exp);
    nameRule.begin = QRegExp(exp);
}
Ejemplo n.º 11
0
void DBManager::DeleteItems( std::set<unsigned int> const& ids ) const
{
    if (ids.empty())
    {
        return;
    }

    std::list<std::tstring> idStrings;
    for (std::set<unsigned int>::const_iterator it = ids.begin(); it != ids.end(); ++it)
    {
        idStrings.push_back(STREAM2STR(*it));
    }
    std::tstring idList = boost::join(idStrings, _T(","));

    std::tstringstream sql;
    sql << _T("DELETE FROM tItems WHERE itemidx IN(") << idList << _T(")");

    m_db->Exec(sql.str());
}
Ejemplo n.º 12
0
/**
 * @brief Utility method to get value for specified key.
 *
 * Docker supports querying primary columns by prefix. This is preserved when
 * querying throught OSQuery.
 *
 * For example the following should return same result as long as there is only
 * one container with "id" that starts with "12345678":
 *   SELECT * FROM docker_containers WHERE id = '1234567890abcdef'
 *   SELECT * FROM docker_containers WHERE id = '12345678'
 *
 * @param tree Property tree response from docker.
 * @param set Set that might contain prefix values.
 * @param key Key to look for in the property tree.
 */
std::string getValue(const pt::ptree& tree,
                     const std::set<std::string>& set,
                     const std::string& key) {
  std::string value = tree.get<std::string>(key, "");
  if (value.find("sha256:") == 0) {
    value.erase(0, 7);
  }
  if (set.empty()) {
    return value; // Return value from tree, if set is empty
  }

  for (const auto& entry : set) {
    if (value.find(entry) == 0) {
      return entry; // If entry from set is prefix of value from tree, return
    }
  }

  return value;
}
Ejemplo n.º 13
0
int SlaveManager::chooseLessReplicaNode(std::set<Address, AddrComp>& loclist, Address& addr)
{
   if (loclist.empty())
      return -1;

   int min_dist = 1024;
   int64_t min_avail_space = -1;


   // TODO (sergey)

   // Remove a node such that the rest has the max-min distance;
   // When the first rule ties, choose one with least available space.
   for (set<Address, AddrComp>::iterator i = loclist.begin(); i != loclist.end(); ++ i)
   {
      // TODO: optimize this by using ID instead of address.
      set<Address, AddrComp> tmp = loclist;
      tmp.erase(*i);
      int slave_id = m_mAddrList[*i];
      SlaveNode sn = m_mSlaveList[slave_id];
      if( m_mSlaveList.find( slave_id ) == m_mSlaveList.end() )
         log().error << __PRETTY_FUNCTION__ << ": about to add new slave to list " << slave_id << std::endl;
      int64_t availDiskSpace = sn.m_llAvailDiskSpace;

      int dist = m_pTopology->min_distance(*i, tmp);
      if (dist < min_dist)
      {
         addr = *i;
         min_dist = dist;
         min_avail_space = availDiskSpace;
      }
      else if (dist == min_dist)
      {
         if (availDiskSpace < min_avail_space)
         {
            addr = *i;
            min_avail_space = sn.m_llAvailDiskSpace;
         }
      }
   }

   return 0;
}
Ejemplo n.º 14
0
 void MatrixArchive::saveMatrices(std::ostream & fout, std::set<std::string> const & validNames) const
 {
   matrix_map_t::const_iterator it = m_values.begin();
   for( ; it != m_values.end(); it++)
   {
     if(validNames.empty() || validNames.count(it->first) > 0)
     {
       if(isSystemLittleEndian())
       {
         writeMatrixBlock(fout, it->first, it->second);
       }
       else
       {
         writeMatrixBlockSwapBytes(fout, it->first, it->second);
       }
       SM_ASSERT_TRUE(MatrixArchiveException, fout.good(), "Error while writing matrix " << it->first << " to file.");
     }
   }
 }
Ejemplo n.º 15
0
 void operator()(msgpack::object::with_zone& o, const std::set<T>& v) const {
     o.type = msgpack::type::ARRAY;
     if(v.empty()) {
         o.via.array.ptr = nullptr;
         o.via.array.size = 0;
     } else {
         uint32_t size = checked_get_container_size(v.size());
         msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
         msgpack::object* const pend = p + size;
         o.via.array.ptr = p;
         o.via.array.size = size;
         typename std::set<T>::const_iterator it(v.begin());
         do {
             *p = msgpack::object(*it, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
Ejemplo n.º 16
0
bool change_sql_database()
{
    if(new_sql_updates.empty()) return true;
    printf("+ changing database sql files\n");

    // rename the database files, copy their contents back
    // and change the required update line
    for(int i = 0; i < NUM_DATABASES; i++)
    {
        if(last_sql_update[i][0] == '\0') continue;

        char old_file[MAX_PATH], tmp_file[MAX_PATH], dummy[MAX_BUF];

        snprintf(old_file, MAX_PATH, "%s%s", path_prefix, db_sql_file[i]);
        snprintf(tmp_file, MAX_PATH, "%s%stmp", path_prefix, db_sql_file[i]);

        rename(old_file, tmp_file);

        FILE *fin = fopen( tmp_file, "r" );
        if(!fin) return false;
        FILE *fout = fopen( old_file, "w" );
        if(!fout) return false;

        while(1)
        {
            if(!fgets(buffer, MAX_BUF, fin)) return false;
            if(sscanf(buffer, "  `required_%s`", dummy) == 1) break;
            fputs(buffer, fout);
        }

        fprintf(fout, "  `required_%s` bit(1) default NULL\n", last_sql_update[i]);
        while(fgets(buffer, MAX_BUF, fin))
            fputs(buffer, fout);

        fclose(fin);
        fclose(fout);
        remove(tmp_file);

        snprintf(cmd, MAX_CMD, "git add %s", old_file);
        system_switch_index(cmd);
    }
    return true;
}
Ejemplo n.º 17
0
void MergingSearcher::update(ExecutionState *current,
                             const std::set<ExecutionState*> &addedStates,
                             const std::set<ExecutionState*> &removedStates) {
  if (!removedStates.empty()) {
    std::set<ExecutionState *> alt = removedStates;
    for (std::set<ExecutionState*>::const_iterator it = removedStates.begin(),
           ie = removedStates.end(); it != ie; ++it) {
      ExecutionState *es = *it;
      std::set<ExecutionState*>::const_iterator it2 = statesAtMerge.find(es);
      if (it2 != statesAtMerge.end()) {
        statesAtMerge.erase(it2);
        alt.erase(alt.find(es));
      }
    }    
    baseSearcher->update(current, addedStates, alt);
  } else {
    baseSearcher->update(current, addedStates, removedStates);
  }
}
Ejemplo n.º 18
0
TEST_P(FormatWriterTest, PixelTypesByCodec)
{
  const PixelType::value_map_type& pv = PixelType::values();

  std::set<ome::xml::model::enums::PixelType> all_pixel_types;
  for (PixelType::value_map_type::const_iterator i = pv.begin();
       i != pv.end();
       ++i)
    all_pixel_types.insert(i->first);

  std::set<ome::xml::model::enums::PixelType> default_pixel_types;
  for (PixelType::value_map_type::const_iterator i = pv.begin();
       i != pv.end();
       ++i)
    {
      if (i->first != PixelType::INT16 &&
          i->first != PixelType::DOUBLE &&
          i->first != PixelType::COMPLEXDOUBLE &&
          i->first != PixelType::BIT)
      default_pixel_types.insert(i->first);
    }

  const std::set<ome::xml::model::enums::PixelType> dpt = w.getPixelTypes("default");
  EXPECT_EQ(default_pixel_types, dpt);

  const std::set<ome::xml::model::enums::PixelType> lzw = w.getPixelTypes("lzw");
  EXPECT_EQ(all_pixel_types, lzw);

  std::set<ome::xml::model::enums::PixelType> rle_pixel_types;
  rle_pixel_types.insert(PixelType::BIT);
  const std::set<ome::xml::model::enums::PixelType> rle = w.getPixelTypes("rle");
  EXPECT_EQ(rle_pixel_types, rle);

  std::set<ome::xml::model::enums::PixelType> test_8bit_pixel_types;
  test_8bit_pixel_types.insert(PixelType::INT8);
  test_8bit_pixel_types.insert(PixelType::UINT8);
  const std::set<ome::xml::model::enums::PixelType> test_8bit = w.getPixelTypes("test-8bit-only");
  EXPECT_EQ(test_8bit_pixel_types, test_8bit);

  const std::set<ome::xml::model::enums::PixelType> ipt = w.getPixelTypes("invalid");
  EXPECT_TRUE(ipt.empty());
}
Ejemplo n.º 19
0
    bool summarize(OTCLI & otCLI) override {
        if (pruneInpTreesNotSynth) {
            return true;
        }
        assert(synthTree != nullptr && !includedNodes.empty());
        std::set<NodeWithSplits *> toPrune;
        for (auto nd : iter_node(*synthTree)) {
            const NodeWithSplits *  c = const_cast<const NodeWithSplits *>(nd);
            if ((!contains(includedNodes, c)) && contains(includedNodes, c->getParent())) {
                toPrune.insert(nd);
            }
        }
        for (auto nd : toPrune) {
            pruneAndDelete(*synthTree, nd);
        }
        writeTreeAsNewick(otCLI.out, *synthTree);
        otCLI.out << '\n';

        return numErrors == 0;
    }
Ejemplo n.º 20
0
void Data<Annotation>::set_intersection(
  std::set<Data<Annotation> *> & result_,
  const std::set<Data<Annotation> *> & datas_1_,
  const std::set<Data<Annotation> *> & datas_2_
) {
  assert(result_.empty());
  // FIXME currently: same symbol => same data

  std::vector<Data<Annotation> *> datas_1(datas_1_.begin(), datas_1_.end());
  std::vector<Data<Annotation> *> datas_2(datas_2_.begin(), datas_2_.end());
  std::vector<Data<Annotation> *> result(std::min(datas_1.size(), datas_2.size()));

  std::sort(datas_1.begin(), datas_1.end(), less);
  std::sort(datas_2.begin(), datas_2.end(), less);

  typename std::vector<Data<Annotation> *>::iterator it_result_begin = result.begin();
  typename std::vector<Data<Annotation> *>::iterator it_result_end = std::set_intersection(datas_1.begin(), datas_1.end(), datas_2.begin(), datas_2.end(), it_result_begin, less);

  result_.insert(it_result_begin, it_result_end);
}
Ejemplo n.º 21
0
void
SVLocus::
eraseNodes(
    const std::set<NodeIndexType>& nodes,
    flyweight_observer_t* obs)
{
    if (nodes.empty()) return;

    if (size() == nodes.size())
    {
        // if the whole locus is being erased, this is more efficient:
        clear(obs);
        return;
    }

    // partial deletion must be done in descending order:
    BOOST_REVERSE_FOREACH(const NodeIndexType nodeIndex, nodes)
    {
        eraseNode(nodeIndex, obs);
    }
Ejemplo n.º 22
0
  /////////////////////////////////////////////////////////////////////////////
  // methods
  /////////////////////////////////////////////////////////////////////////////
  bool initialize(kdsplit_strategy<value_t> const& split_strategy, std::set<contour_segment_ptr> const& segments) {
    if (segments.empty()) {
      root = std::make_shared<kdnode2d<value_t>>(bbox_type(), 0, 0, 0, 0, segments, nullptr, nullptr, nullptr);
      return false;
    }
    else {
      // gather bbox information
      bbox = (*segments.begin())->bbox();
      for (auto const& segment : segments) {
        bbox.merge(segment->bbox());
      }
      // create root
      root = std::make_shared<kdnode2d<value_t>>(bbox, 0, 0, 0, 0, segments, nullptr, nullptr, nullptr);

      bool success = split_strategy.generate(*this);
      root->determine_parity(segments);
      
      return success;
    }
  }
Ejemplo n.º 23
0
void ExtractAllMaps(std::set<uint32>& mapIds, uint32 threads, bool debug)
{
    DBC* dbc = MPQHandler->GetDBC("Map");
    for (std::vector<Record*>::iterator itr = dbc->Records.begin(); itr != dbc->Records.end(); ++itr)
    {
        uint32 mapId = (*itr)->Values[0];

        // Skip this map if a list of specific maps was provided and this one is not contained in it.
        if (!mapIds.empty() && mapIds.find(mapId) == mapIds.end())
            continue;

        std::string name = (*itr)->GetString(1);
        WDT wdt("World\\maps\\" + name + "\\" + name + ".wdt");
        if (!wdt.IsValid || wdt.IsGlobalModel)
            continue;
        printf("Building %s MapId %u\n", name.c_str(), mapId);
        ContinentBuilder builder(name, mapId, &wdt, threads);
        builder.Build(debug);
    }
}
Ejemplo n.º 24
0
actor_addr remote_actor_impl(std::set<std::string> ifs,
                             std::string host, uint16_t port) {
  auto mm = get_middleman_actor();
  actor_addr result;
  scoped_actor self;
  self->sync_send(mm, connect_atom::value, std::move(host), port).await(
    [&](ok_atom, const node_id&, actor_addr res, std::set<std::string>& xs) {
      if (!res)
        throw network_error("no actor published at given port");
      if (! (xs.empty() && ifs.empty())
          && ! std::includes(xs.begin(), xs.end(), ifs.begin(), ifs.end()))
        throw network_error("expected signature does not "
                            "comply to found signature");
      result = std::move(res);
    },
    [&](error_atom, std::string& msg) {
      throw network_error(std::move(msg));
    }
  );
  return result;
}
Ejemplo n.º 25
0
void AssFile::Sort(EntryList<AssDialogue> &lst, CompFunc comp, std::set<AssDialogue*> const& limit) {
	if (limit.empty()) {
		lst.sort(comp);
		return;
	}

	// Sort each selected block separately, leaving everything else untouched
	for (auto begin = lst.begin(); begin != lst.end(); ++begin) {
		if (!limit.count(&*begin)) continue;
		auto end = begin;
		while (end != lst.end() && limit.count(&*end)) ++end;

		// sort doesn't support only sorting a sublist, so move them to a temp list
		EntryList<AssDialogue> tmp;
		tmp.splice(tmp.begin(), lst, begin, end);
		tmp.sort(comp);
		lst.splice(end, tmp);

		begin = --end;
	}
}
Ejemplo n.º 26
0
bool CAudioLibrary::CheckForAdditionalProperties(const CVariant &properties, const std::set<std::string> &checkProperties, std::set<std::string> &foundProperties)
{
  if (!properties.isArray() || properties.empty())
    return false;

  std::set<std::string> checkingProperties = checkProperties;
  for (CVariant::const_iterator_array itr = properties.begin_array(); itr != properties.end_array() && !checkingProperties.empty(); itr++)
  {
    if (!itr->isString())
      continue;

    std::string property = itr->asString();
    if (checkingProperties.find(property) != checkingProperties.end())
    {
      checkingProperties.erase(property);
      foundProperties.insert(property);
    }
  }

  return !foundProperties.empty();
}
Ejemplo n.º 27
0
	void MyRecycleThread::run()
	{
		while(!isFini())
		{
			checkQueue();
			if (!taskSet.empty())
			{
				std::set<MySockTask *>::iterator iter = taskSet.begin();
				for (; iter != taskSet.end(); ++iter)
				{
					if (NULL != *iter)
					{
						MySockTaskManager::getInstance().removeTask(*iter);
						delete *iter;
					}
				}
				taskSet.clear();
			}
			usleep(10*1000);
		}
	}
Ejemplo n.º 28
0
Glib::ustring SimulOutSetsAdapterModelImpl::getStringListFromStringSet(
    std::set<std::string> Vect)
{
  Glib::ustring Str = "";

  if (!Vect.empty())
    Str = *Vect.begin();

  if (Vect.size() > 1)
  {
    std::set<std::string>::iterator it = Vect.begin();
    it++;
    while (it != Vect.end())
    {
      Str += Glib::ustring::compose(";%1", *it);
      ++it;
    }
  }

  return Str;
}
Ejemplo n.º 29
0
void Endpoint::OnConfigLoaded(void)
{
	DynamicObject::OnConfigLoaded();

	BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjectsByType<Zone>()) {
		const std::set<Endpoint::Ptr> members = zone->GetEndpoints();

		if (members.empty())
			continue;

		if (members.find(GetSelf()) != members.end()) {
			if (m_Zone)
				BOOST_THROW_EXCEPTION(std::runtime_error("Endpoint '" + GetName() + "' is in more than one zone."));

			m_Zone = zone;
		}
	}

	if (!m_Zone)
		BOOST_THROW_EXCEPTION(std::runtime_error("Endpoint '" + GetName() + "' does not belong to a zone."));
}
Ejemplo n.º 30
0
	/**
	 * Performs "give inventory" operations for provided avatars.
	 *
	 * Sends one requests to give all selected inventory items for each passed avatar.
	 * Avatars are represent by two vectors: names and UUIDs which must be sychronized with each other.
	 *
	 * @param avatar_names - avatar names request to be sent.
	 * @param avatar_uuids - avatar names request to be sent.
	 */
	static void give_inventory(const uuid_vec_t& avatar_uuids, const std::vector<LLAvatarName> avatar_names)
	{
		llassert(avatar_names.size() == avatar_uuids.size());

		const std::set<LLUUID> inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs();
		if (inventory_selected_uuids.empty())
		{
			return;
		}

		std::string residents;
		LLAvatarActions::buildResidentsString(avatar_names, residents);

		std::string items;
		build_items_string(inventory_selected_uuids, items);

		int folders_count = 0;
		std::set<LLUUID>::const_iterator it = inventory_selected_uuids.begin();

		//traverse through selected inventory items and count folders among them
		for ( ; it != inventory_selected_uuids.end() && folders_count <=1 ; ++it)
		{
			LLViewerInventoryCategory* inv_cat = gInventory.getCategory(*it);
			if (NULL != inv_cat)
			{
				folders_count++;
			}
		}

		// EXP-1599
		// In case of sharing multiple folders, make the confirmation
		// dialog contain a warning that only one folder can be shared at a time.
		std::string notification = (folders_count > 1) ? "ShareFolderConfirmation" : "ShareItemsConfirmation";
		LLSD substitutions;
		substitutions["RESIDENTS"] = residents;
		substitutions["ITEMS"] = items;
		LLShareInfo::instance().mAvatarNames = avatar_names;
		LLShareInfo::instance().mAvatarUuids = avatar_uuids;
		LLNotificationsUtil::add(notification, substitutions, LLSD(), &give_inventory_cb);
	}