Exemplo n.º 1
0
void Spread::addRule(RuleSet &rules, const std::string &str)
{
  const char *ptr = str.c_str();

  // Decode rule string
  std::string verb = getNext(ptr);

  if(verb == "URL")
    {
      Hash hash = getHash(ptr);

      int prio;
      float w;
      std::string url;

      decodeURL(ptr, url, prio, w);

      if(hash.isNull() || url == "")
        fail("Invalid URL rule " + str);

       rules.addURL(hash, url, prio, w, str);
    }
  else if(verb == "ARC")
    {
      Hash arcHash = getHash(ptr);
      Hash dirHash = getHash(ptr);

      if(arcHash.isNull() || dirHash.isNull())
        fail("Invalid ARC rule " + str);

      rules.addArchive(arcHash, dirHash, str);
    }

  /* Ignore unknown rule verbs. More rules may be added later as
     optimizations or new sources for obtaining data. Clients who are
     not able to parse these rules should still be allowed to use the
     rules they DO understand.
   */
}
Exemplo n.º 2
0
void add(const std::string &file, const Hash &h = Hash(), bool allowMissing=false)
{
  cout << "Adding " << file;
  if(!h.isNull()) cout << " (expecting " << h << ")";
  cout << endl;
  try
    {
      Hash out =index.addFile(file,h, allowMissing);
      cout << "  Got: " << out << endl;
    }
  catch(exception &e)
    {
      cout << "  Error: " << e.what() << endl;
    }
}
Exemplo n.º 3
0
Hash add(const std::string &file, const Hash &h = Hash())
{
  cout << "Adding " << file;
  if(!h.isNull()) cout << " (expecting " << h << ")";
  cout << endl;
  Hash out;
  try
    {
      out = index.addFile(file,h);
      cout << "  Got: " << out << endl;
    }
  catch(exception &e)
    {
      cout << "  Error: " << e.what() << endl;
    }
  return out;
}