Example #1
0
size_t Options::OptionsSetDiff(const OptionSet &set_a, const OptionSet &set_b,
                               OptionSet &diffs) {
  size_t num_diffs = 0;
  OptionSet::const_iterator pos_a;
  OptionSet::const_iterator pos_b;

  for (pos_a = set_a.begin(); pos_a != set_a.end(); ++pos_a) {
    pos_b = set_b.find(*pos_a);
    if (pos_b == set_b.end()) {
      ++num_diffs;
      diffs.insert(*pos_a);
    }
  }

  return num_diffs;
}
Example #2
0
bool Options::IsASubset(const OptionSet &set_a, const OptionSet &set_b) {
  bool is_a_subset = true;
  OptionSet::const_iterator pos_a;
  OptionSet::const_iterator pos_b;

  // set_a is a subset of set_b if every member of set_a is also a member of
  // set_b

  for (pos_a = set_a.begin(); pos_a != set_a.end() && is_a_subset; ++pos_a) {
    pos_b = set_b.find(*pos_a);
    if (pos_b == set_b.end())
      is_a_subset = false;
  }

  return is_a_subset;
}
Example #3
0
void Options::OptionsSetUnion(const OptionSet &set_a, const OptionSet &set_b,
                              OptionSet &union_set) {
  OptionSet::const_iterator pos;
  OptionSet::iterator pos_union;

  // Put all the elements of set_a into the union.

  for (pos = set_a.begin(); pos != set_a.end(); ++pos)
    union_set.insert(*pos);

  // Put all the elements of set_b that are not already there into the union.
  for (pos = set_b.begin(); pos != set_b.end(); ++pos) {
    pos_union = union_set.find(*pos);
    if (pos_union == union_set.end())
      union_set.insert(*pos);
  }
}
/*! Removes the option \a name from \a optSet. If the option is not present
    \c false is returned, \c true otherwise.

    \param[in] optSet OptionSet to modify.
    \param[in] name   Name of the option.
    \return Whether the option was successfully removed.
 */
bool
IOFileTypeBase::unsetOption(OptionSet &optSet, const std::string &name)
{
    bool                retVal = false;
    OptionSet::iterator oIt    = optSet.find(name);
    
    if(oIt != optSet.end())
    {
        optSet.erase(oIt);
        retVal = true;
    }
    
    return retVal;
}
/*! Attempts to return the \a value associated with option \a name
    in \a optSet. If the option is not present \c false is returned,
    \c true otherwise and only in this case value is being set.
    
    \param[in] optSet OptionSet to read.
    \param[in] name   Name of the option.
    \param[out] value Value of option.
    \return Whether the option is present.
 */
bool
IOFileTypeBase::getOption(
    const OptionSet &optSet, std::string const &name, std::string &value)
{
    bool                      retVal = false;
    OptionSet::const_iterator oIt    = optSet.find(name);
    
    if(oIt != optSet.end())
    {
        value  = oIt->second.optValue;
        retVal = true;
    }
    
    return retVal;
}
void NFIOOptions::init(const OptionSet &options)
{
    // init default parameters
    _inlineTextures             = true;
    _compressTextures           = false;
    _texturesCompressionQuality = 75;
    _texturesImageType          = "jpeg",
    _quantizePositions          = Quantizer::QRES_OFF;
    _quantizeNormals            = Quantizer::QRES_OFF;
    _quantizeTexCoords          = Quantizer::QRES_OFF;
    _packIndices                = false;
    _unpack16BitIndices         = false;
    
    OptionSet::const_iterator oIt  = options.begin();
    OptionSet::const_iterator oEnd = options.end  ();
    
    for(; oIt != oEnd; ++oIt)
    {
        if(oIt->first == "inlineTextures")
            _inlineTextures = getBoolOption(oIt->second);
        
        if(oIt->first == "compressTextures")
            _compressTextures = getBoolOption(oIt->second);
            
        if(oIt->first == "texturesCompressionQuality")
            _texturesCompressionQuality = getValue<UInt32>(oIt->second, 75);
            
        if(oIt->first == "texturesImageType")
            _texturesImageType = getValue<std::string>(oIt->second, "jpeg");
            
        if(oIt->first == "quantizePositions")
            _quantizePositions = getQuantizeOption(oIt->second);

        if(oIt->first == "quantizeNormals")
            _quantizeNormals = getQuantizeOption(oIt->second);
            
        if(oIt->first == "quantizeTexCoords")
            _quantizeTexCoords = getQuantizeOption(oIt->second);
            
        if(oIt->first == "packIndices")
            _packIndices = getBoolOption(oIt->second);
            
        if(oIt->first == "unpack16BitIndices")
            _unpack16BitIndices = getBoolOption(oIt->second);
    }
}