Example #1
0
File: node.cpp Project: halbbob/dff
bool	Node::isCompatibleModule(string modname)
{
  
  ConfigManager*		cm;
  Config*			conf;
  Constant*			constant;
  std::list<Variant*>		values;
  std::list<Variant*>::iterator	it;
  bool				compat;
  
  compat = false;
  if (((cm = ConfigManager::Get()) != NULL) && ((conf = cm->configByName(modname)) != NULL))
    {
      Attributes	dtypes;
      Variant*		vptr;
      std::string	ext;

      vptr = this->dataType();
      ext = this->extension();
      if (vptr != NULL && ((constant = conf->constantByName("mime-type")) != NULL))
	{
	  dtypes = vptr->value<Attributes >();
	  values = constant->values();
	  for (Attributes::iterator mit = dtypes.begin(); mit != dtypes.end(); mit++)
	    {
	      if (mit->second->type() == typeId::String)
		{
		  std::string	dtype = mit->second->value<std::string>();
		  it = values.begin();
		  while (it != values.end() && !compat)
		    {
		      if ((*it)->type() == typeId::String && dtype.find((*it)->value<std::string>()) != std::string::npos)
			compat = true;
		      it++;
		    }
		}
	    }
	  delete vptr;
	}
      if (!ext.empty() && !compat && ((constant = conf->constantByName("extension-type")) != NULL))
	{
	  values = constant->values();
	  it = values.begin();
	  while (it != values.end() && !compat)
	    {
	      if ((*it)->type() == typeId::String && (*it)->value<std::string>().find(ext) != std::string::npos)
		compat = true;
	      it++;
	    }
	}
    }
  return compat;
}