示例#1
0
    /// Utility function to adjust option strings, used by ToNormalised()/ToCustomised().
    bool AdjustOptions(void * parm, unsigned * parmLen, bool (PluginCodec_MediaFormat:: * adjuster)(OptionMap & original, OptionMap & changed))
    {
      if (parmLen == NULL || parm == NULL || *parmLen != sizeof(char ***)) {
        PTRACE(1, "Plugin", "Invalid parameters to AdjustOptions.");
        return false;
      }

      OptionMap originalOptions;
      for (const char * const * option = *(const char * const * *)parm; *option != NULL; option += 2)
        originalOptions[option[0]] = option[1];

      OptionMap changedOptions;
      if (!(this->*adjuster)(originalOptions, changedOptions)) {
        PTRACE(1, "Plugin", "Could not normalise/customise options.");
        return false;
      }

      char ** options = (char **)calloc(changedOptions.size()*2+1, sizeof(char *));
      *(char ***)parm = options;
      if (options == NULL) {
        PTRACE(1, "Plugin", "Could not allocate new option lists.");
        return false;
      }

      for (OptionMap::iterator i = changedOptions.begin(); i != changedOptions.end(); ++i) {
        *options++ = strdup(i->first.c_str());
        *options++ = strdup(i->second.c_str());
      }

      return true;
    }
示例#2
0
void loadOptions( OptionArray& outOptions, void* av_class, int req_flags )
{
	OptionMap optionMap;
	loadOptions( optionMap, av_class, req_flags );

	for( OptionMap::iterator it = optionMap.begin(); it != optionMap.end(); ++it )
		outOptions.push_back( it->second );
}
示例#3
0
void ClangOptionsEmitter::run(std::ostream &OS) {
  // Build up a map from options to controlled diagnostics.
  OptionMap OM;  
       
  const RecordVector &Opts = Records.getAllDerivedDefinitions("Option");
  for (RecordVector::const_iterator I=Opts.begin(), E=Opts.end(); I!=E; ++I)
    if (const RecordVal* V = findRecordVal(**I, "Members"))
      if (const ListInit* LV = dynamic_cast<const ListInit*>(V->getValue())) {        
        VisitedLists Visited;
        BuildGroup(OM[*I], Visited, LV);
      }
  
  // Iterate through the OptionMap and emit the declarations.
  for (OptionMap::iterator I = OM.begin(), E = OM.end(); I!=E; ++I) {    
    // Output the option.
    OS << "static const diag::kind " << I->first->getName() << "[] = { ";
    
    DiagnosticSet &DS = I->second;
    bool first = true;
    for (DiagnosticSet::iterator I2 = DS.begin(), E2 = DS.end(); I2!=E2; ++I2) {
      if (first)
        first = false;
      else
        OS << ", ";
        
      OS << "diag::" << (*I2)->getName();
    }
    OS << " };\n";
  }
    
  // Now emit the OptionTable table.
  OS << "\nstatic const WarningOption OptionTable[] = {";
  bool first = true;
  for (OptionMap::iterator I = OM.begin(), E = OM.end(); I!=E; ++I) {
    if (first)
      first = false;
    else
      OS << ',';
    
    OS << "\n  {\"" << getOptName(I->first)
       << "\", DIAGS(" << I->first->getName() << ")}";
  }
  OS << "\n};\n";
}
示例#4
0
	void Settings::SettingsPerModule::merge(OptionMap& out, const OptionMap& with) const
	{
		const OptionMap::const_iterator end = with.end();
		for (OptionMap::const_iterator i = with.begin(); i != end; ++i)
			out[i->first] = true;
	}