Ejemplo n.º 1
0
bool
EnvironmentBase::IsAutoConfigParam( const Param& p )
{
  enum { autoType = 0, autoTag, autoKind, count };
  static const char* s[][count] =
  {
    { "blob", 0 },
    { "auto", "AutoConfig", 0 },
    { "(enumeration)", 0 },
  };
  struct
  {
    bool Is( int type, const char* str )
    { 
      const char** p = s[type];
      while( *p )
        if( !::stricmp( *p++, str ) )
          return true;
      return false;
    }
    bool Contains( int type, const char* str )
    { 
      while( *str )
        if( Is( type, str++ ) )
          return true;
      return false;
    }
  } strings;

  bool result = strings.Is( autoType, p.Type().c_str() );
  if( p.NumValues() == 1 )
    result = result || strings.Is( autoTag, p.Value().c_str() );
  if( p.NumValues() > 0 && !::atoi( p.Value().c_str() ) )
    result = result || strings.Contains( autoKind, p.Comment().c_str() )
                       && strings.Contains( autoTag, p.Comment().c_str() );
  return result;
}