当前位置: 首页>>代码示例>>C++>>正文


C++ Nibbler类代码示例

本文整理汇总了C++中Nibbler的典型用法代码示例。如果您正苦于以下问题:C++ Nibbler类的具体用法?C++ Nibbler怎么用?C++ Nibbler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Nibbler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

void main()
{
	srand(time(NULL));
	//파일경로를 파라미터로 클래스 생성 
	Nibbler testfile = Nibbler(DEMOFILE);


	//파일을 손상시키는 함수
	//1. nibbleRandom
	//	전체 구간에서 랜덤으로 파일을 손상시킴
	//	파라미터1 : 손상시킬 퍼센테이지 (소수점 4자리까지 입력가능)

	//2. nibbleGeader
	//	헤더 구간에서 지정된 확률만큼 파일을 손상시킴
	//	파라미터1 : 헤더크기(바이트)
	//	파라미터2 : 손상시킬 퍼센테이지 (소수점 4자리까지 입력가능)
	
	//3. nibbleBody
	//	헤더를 제외한 구간에서 지정된 확률만큼 파일을 손상시킴
	//	파라미터1 : 헤더크기(바이트)
	//	파라미터2 : 손상시킬 퍼센테이지 (소수점 4자리까지 입력가능)

	testfile.nibbleRandom	(0.0001);
	//헤더는 7%이상 손상 시키면 재생이 불가능해진다.
	testfile.nibbleHeader	(8	,2);
	testfile.nibbleBody		(8	,0.01);


}
开发者ID:noizbuster,项目名称:FileNibbler,代码行数:29,代码来源:main.cpp

示例2: main

int			main(int ac, char **av)
{
  void			*handle;
  IGui			*(*ext_ctor)();
  Nibbler		nibbler;

  try
    {
      if (ac != 4)
	throw myException((GamePart)42, "Usage: ./nibbler width height libXXX.so");
      handle = dlopen(av[3], RTLD_LAZY);
      if (!handle)
	throw Nibbler::nibblerException(NIBBLER, dlerror(), DLERROR);
      ext_ctor = reinterpret_cast<IGui* (*)()>(dlsym(handle, "create"));
      if (!ext_ctor)
	throw Nibbler::nibblerException(NIBBLER, dlerror(), DLERROR);
      if (!nibbler.checkArg(av[1]) || !nibbler.checkArg(av[2]))
	throw Nibbler::nibblerException(NIBBLER, "Bad map values", BADARG);
      nibbler.setGui(ext_ctor);
      nibbler.execNibbler(nibbler.getnbr(av[1]), nibbler.getnbr(av[2]));
      nibbler.deleteGui();
      nibbler.getCore()->printEndgame();
      if (dlclose(handle) != 0)
	throw Nibbler::nibblerException(NIBBLER, dlerror(), DLERROR);
    }
  catch (myException const &ex)
    {
      nibbler.deleteGui();
      std::cerr << ex.where() << " : " << ex.what() << std::endl;
      return (1);
    }
  return (0);
}
开发者ID:luxsypher,项目名称:nibbler,代码行数:33,代码来源:main.cpp

示例3: lowerCase

bool Duration::valid (const std::string& input)
{
  std::string lower_input = lowerCase (input);

  // Assume the ordinal is 1, but look for an integer, just in case.
  double value = 1;
  Nibbler n (lower_input);
  n.getNumber (value);

  if (value < 0.0)
    value = -value;

  std::string units;
  n.getUntilEOS (units);

  // Non-trivial value with no units means the duration is specified in
  // seconds, and therefore a time_t.  Consider it valid.
  if (value != 0.0 &&
      units == "")
    return true;

  // Auto complete against all supported durations.
  std::vector <std::string> supported;
  for (unsigned int i = 0; i < NUM_DURATIONS; ++i)
    supported.push_back (durations[i]);

  std::vector <std::string> matches;
  if (autoComplete (units,
                    supported,
                    matches,
                    context.config.getInteger ("abbreviation.minimum")) == 1)
    return true;

  return false;
}
开发者ID:SEJeff,项目名称:task,代码行数:35,代码来源:Duration.cpp

示例4: n

////////////////////////////////////////////////////////////////////////////////
// Enumerate all hooks, and tell API about the script files it must load in
// order to call them.  Note that API will perform a deferred read, which means
// that if it isn't called, a script will not be loaded.
void Hooks::initialize ()
{
#ifdef HAVE_LIBLUA
  _api.initialize ();
#endif

  // Allow a master switch to turn the whole thing off.
  bool big_red_switch = context.config.getBoolean ("extensions");
  if (big_red_switch)
  {
    std::vector <std::string> vars;
    context.config.all (vars);

    std::vector <std::string>::iterator it;
    for (it = vars.begin (); it != vars.end (); ++it)
    {
      std::string type;
      std::string name;
      std::string value;

      // "<type>.<name>"
      Nibbler n (*it);
      if (n.getUntil ('.', type) &&
          type == "hook"         &&
          n.skip ('.')           &&
          n.getUntilEOS (name))
      {
        std::string value = context.config.get (*it);
        Nibbler n (value);

        // <path>:<function> [, ...]
        while (!n.depleted ())
        {
          std::string file;
          std::string function;
          if (n.getUntil (':', file) &&
              n.skip (':')           &&
              n.getUntil (',', function))
          {
            context.debug (std::string ("Event '") + name + "' hooked by " + file + ", function " + function);
            Hook h (name, Path::expand (file), function);
            _all.push_back (h);

            (void) n.skip (',');
          }
          else
            throw std::string (format (STRING_LUA_BAD_HOOK_DEF, *it));
        }
      }
    }
  }
  else
    context.debug ("Hooks::initialize --> off");
}
开发者ID:SEJeff,项目名称:task,代码行数:58,代码来源:Hooks.cpp

示例5: AGui

Gui::Gui(Nibbler &nibbler) : AGui(nibbler)
{
  screen = NULL;
  if (SDL_Init(SDL_INIT_VIDEO) == -1)
    throw (NibError("SDL_init", "fail"));
  atexit(SDL_Quit);
  TTF_Init();
  screen = SDL_SetVideoMode(nibbler.getWidth() * 25, nibbler.getHeight() * 25, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
  SDL_WM_SetCaption("NIBBLER", NULL);
  if (screen == NULL)
    throw (NibError("Video_mode", "fail"));   
}
开发者ID:foo-foo,项目名称:epitech-projects,代码行数:12,代码来源:Gui.cpp

示例6: n

////////////////////////////////////////////////////////////////////////////////
// Enumerate all hooks, and tell API about the script files it must load in
// order to call them.  Note that API will perform a deferred read, which means
// that if it isn't called, a script will not be loaded.
void Hooks::initialize ()
{
  // Allow a master switch to turn the whole thing off.
  bool big_red_switch = context.config.getBoolean ("extensions");
  if (big_red_switch)
  {
    Config::const_iterator it;
    for (it = context.config.begin (); it != context.config.end (); ++it)
    {
      std::string type;
      std::string name;
      std::string value;

      // "<type>.<name>"
      Nibbler n (it->first);
      if (n.getUntil ('.', type) &&
          type == "hook"         &&
          n.skip ('.')           &&
          n.getUntilEOS (name))
      {
        Nibbler n (it->second);

        // <path>:<function> [, ...]
        while (!n.depleted ())
        {
          std::string file;
          std::string function;
          if (n.getUntil (':', file) &&
              n.skip (':')           &&
              n.getUntil (',', function))
          {
            context.debug (std::string ("Event '") + name + "' hooked by " + file + ", function " + function);
            Hook h (name, Path::expand (file), function);
            _all.push_back (h);

            (void) n.skip (',');
          }
          else
            ; // Was: throw std::string (format ("Malformed hook definition '{1}'.", it->first));
        }
      }
    }
  }
  else
    context.debug ("Hooks::initialize --> off");
}
开发者ID:georgebrock,项目名称:task,代码行数:50,代码来源:Hooks.cpp

示例7: n

Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */)
{
  // Before parsing according to "format", perhaps this is a relative date?
  if (isRelativeDate (input))
    return;

  // Parse an ISO date.
  Nibbler n (input);
  if (n.getDateISO (_t) && n.depleted ())
    return;

  // Parse a formatted date.
  if (n.getDate (format, _t) && n.depleted ())
    return;

  // Perhaps it is an epoch date, in string form?
  if (isEpoch (input))
    return;

  throw ::format (STRING_DATE_INVALID_FORMAT, input, format);
}
开发者ID:SEJeff,项目名称:task,代码行数:21,代码来源:Date.cpp

示例8: main

int		main(int ac, char **av)
{
  Nibbler	*nibbler;
  void		*handle;
  std::pair<int, int>	map;

  if (ac != 4)
    {
      std::cerr << "Usage : ./nibler width[10..55] height[10..55] ./LIB.so" << std::endl;
      return (-1);
    }
  if ((handle = Glibc::Libdl::_dlopen(av[3], RTLD_LAZY)) == NULL)
    {
      std::cerr << Glibc::Libdl::_dlerror() << std::endl;
      return (-1);
    }
  if (!check_size(Glibc::Atoi::_atoi(av[1]), Glibc::Atoi::_atoi(av[2])))
    {
      std::cerr << "Entrer a size between 10x10 and 55x55" << std::endl;
      return (-1);
    }
  try
    {
      map.first = Glibc::Atoi::_atoi(av[1]);
      map.second = Glibc::Atoi::_atoi(av[2]);
      nibbler = new Nibbler(handle, map);
      nibbler->runGame();
      std::cout << "Game Over" << std::endl;
      delete nibbler;
    }
  catch (std::exception& e)
    {
      std::cerr << e.what() << std::endl;
      return (-1);
    }
  return (0);
}
开发者ID:FowlingLight,项目名称:Nibbler,代码行数:37,代码来源:main.cpp

示例9: n

////////////////////////////////////////////////////////////////////////////////
// A Path and a Subst may look similar, and so the rule is that if a Subst looks
// like a path, it must also not exist in the file system in order to actually
// be a Subst.
bool Subst::valid (const std::string& input) const
{
  std::string ignored;
  Nibbler n (input);
  if (n.skip     ('/')            &&
      n.getUntil ('/', ignored)   &&
      n.skip     ('/')            &&
      n.getUntil ('/', ignored)   &&
      n.skip     ('/'))
  {
    n.skip ('g');
    if (n.depleted ())
      return ! Directory (input).exists ();
  }

  return false;
}
开发者ID:lmacken,项目名称:task,代码行数:21,代码来源:Subst.cpp

示例10: main

int main (int argc, char** argv)
{
#ifdef NIBBLER_FEATURE_DATE
#ifdef NIBBLER_FEATURE_REGEX
  UnitTest t (410);
#else
  UnitTest t (380);
#endif
#else
#ifdef NIBBLER_FEATURE_REGEX
  UnitTest t (346);
#else
  UnitTest t (322);
#endif
#endif

  // Ensure environment has no influence.
  unsetenv ("TASKDATA");
  unsetenv ("TASKRC");

  try
  {
    Nibbler n;
    std::string s;
    int i;
    double d;
    time_t ti;

#ifdef NIBBLER_FEATURE_DATE
    Date dt;
#endif
    std::vector <std::string> options;

    // Make sure the nibbler behaves itself with trivial input.
    t.diag ("Test all nibbler calls given empty input");
    n = Nibbler ("");
    t.notok (n.getUntil (' ', s),        "trivial: getUntil");
    t.notok (n.getUntil ("hi", s),       "trivial: getUntil");
    t.notok (n.getUntilOneOf ("ab", s),  "trivial: getUntilOneOf");
    t.notok (n.skipN (123),              "trivial: skipN");
    t.notok (n.skip ('x'),               "trivial: skip");
    t.notok (n.skipAll ('x'),            "trivial: skipAll");
    t.notok (n.skipAllOneOf ("abc"),     "trivial: skipAllOneOf");
    t.notok (n.backN (1),                "trivial: backN");
    t.notok (n.getQuoted ('"', s),       "trivial: getQuoted");
    t.notok (n.getDigit (i),             "trivial: getDigit");
    t.notok (n.getInt (i),               "trivial: getInt"); // 10
    t.notok (n.getUnsignedInt (i),       "trivial: getUnsignedInt");
    t.notok (n.getUntilEOL (s),          "trivial: getUntilEOL");
    t.notok (n.getUntilEOS (s),          "trivial: getUntilEOS");
    t.notok (n.getDateISO (ti),          "trivial: getDateISO");
#ifdef NIBBLER_FEATURE_DATE
    t.notok (n.getDate ("YYYYMMDD", ti), "trivial: getDate");
#endif
    t.notok (n.getOneOf (options, s),    "trivial: getOneOf");
    t.ok    (n.depleted (),              "trivial: depleted");

    // bool getUntil (char, std::string&);
    t.diag ("Nibbler::getUntil");
    n = Nibbler ("one two");
    t.ok    (n.getUntil (' ', s),        " 'one two' :       getUntil (' ')    -> true");
    t.is    (s, "one",                   " 'one two' :       getUntil (' ')    -> 'one'"); // 20
    t.ok    (n.getUntil (' ', s),        "    ' two' :       getUntil (' ')    -> true");
    t.is    (s, "",                      "    ' two' :       getUntil (' ')    -> ''");
    t.ok    (n.skip (' '),               "    ' two' :           skip (' ')    -> true");
    t.ok    (n.getUntil (' ', s),        "     'two' :       getUntil (' ')    -> 'two'");
    t.notok (n.getUntil (' ', s),        "        '' :       getUntil (' ')    -> false");
    t.ok    (n.depleted (),              "        '' :       depleted ()       -> true");

#ifdef NIBBLER_FEATURE_REGEX
    // bool getUntilRx (const std::string&, std::string&);
    t.diag ("Nibbler::getUntilRx");
    n = Nibbler ("one two");
    t.ok    (n.getUntilRx ("th", s),     " 'one two' :     getUntilRx ('th')   -> true");
    t.is    (s, "one two",               " 'one two' :     getUntilRx ('th')   -> 'one two'");

    n = Nibbler ("one two");
    t.ok    (n.getUntilRx ("e", s),      " 'one two' :     getUntilRx ('e')    -> true");
    t.is    (s, "on",                    " 'one two' :     getUntilRx ('e')    -> 'on'"); // 30
    t.ok    (n.getUntilRx ("tw", s),     "   'e two' :     getUntilRx ('tw')   -> true");
    t.is    (s, "e ",                    "   'e two' :     getUntilRx ('tw')   -> 'e '");
    t.ok    (n.getUntilRx ("$", s),      "     'two' :     getUntilRx ('$')    -> true");
    t.is    (s, "two",                   "     'two' :     getUntilRx ('$')    -> 'two'");
    t.ok    (n.depleted (),              "        '' :       depleted ()       -> true");
#endif

    // bool getUntilOneOf (const std::string&, std::string&);
    t.diag ("Nibbler::getUntilOneOf");
    n = Nibbler ("ab.cd");
    t.ok    (n.getUntilOneOf (".:", s),  "   'ab.cd' :  getUntilOneOf ('.:')   -> true");
    t.is    (s, "ab",                    "   'ab.cd' :  getUntilOneOf ('.:')   -> 'ab'");
    t.ok    (n.skipN (),                 "     '.cd' :          skipN ()       -> true");
    t.ok    (n.getUntilOneOf (".:", s),  "      'cd' :  getUntilOneOf ('.:')   -> true");
    t.notok (n.getUntilOneOf (".:", s),  "        '' :  getUntilOneOf ('.:')   -> false");
    t.ok    (n.depleted (),              "        '' :       depleted ()       -> true");

    // bool getUntil (const std::string&, std::string&);
    t.diag ("Nibbler::getUntil");
    n = Nibbler ("ab\r\ncd");
    t.ok (n.getUntil ("\r\n", s),     "'ab\\r\\ncd' :       getUntil ('\\r\\n') -> true");
//.........这里部分代码省略.........
开发者ID:JensErat,项目名称:task,代码行数:101,代码来源:nibbler.t.cpp

示例11: findValue


//.........这里部分代码省略.........

        // This guarantees that if more than one annotation has the same date,
        // that the seconds will be different, thus unique, thus not squashed.
        // Bug #249
        when += (const int) annotations.size ();

        std::stringstream name;
        name << "annotation_" << when.toEpoch ();
        std::string text = trim (value.substr (gap + 4), "\t ");
        annotations.insert (std::make_pair (name.str (), text));
      }
    }
  }

  task.setAnnotations (annotations);

  // Dependencies
  value = findValue (after, "\n  Dependencies:");
  std::vector <std::string> dependencies;
  split (dependencies, value, ",");

  task.remove ("depends");
  std::vector <std::string>::iterator dep;
  for (dep = dependencies.begin (); dep != dependencies.end (); ++dep)
  {
    if (dep->length () >= 7)
      task.addDependency (*dep);
    else
      task.addDependency ((int) strtol (dep->c_str (), NULL, 10));
  }

  // UDAs
  std::map <std::string, Column*>::iterator col;
  for (col = context.columns.begin (); col != context.columns.end (); ++col)
  {
    std::string type = context.config.get ("uda." + col->first + ".type");
    if (type != "")
    {
      std::string value = findValue (after, "\n  UDA " + col->first + ":");
      if ((task.get (col->first) != value) && (type != "date" ||
           (task.get (col->first) != Date (value, dateformat).toEpochString ())) &&
           (type != "duration" ||
           (task.get (col->first) != (std::string) Duration (value) )))
      {
        if (value != "")
        {
          context.footnote (format (STRING_EDIT_UDA_MOD, col->first));

          if (type == "string")
          {
            task.set (col->first, value);
          }
          else if (type == "numeric")
          {
            Nibbler n (value);
            double d;
            if (n.getNumber (d) &&
                n.depleted ())
              task.set (col->first, value);
            else
              throw format (STRING_UDA_NUMERIC, value);
          }
          else if (type == "date")
          {
            Date d (value, dateformat);
            task.set (col->first, d.toEpochString ());
          }
          else if (type == "duration")
          {
            Duration d (value);
            task.set (col->first, (time_t) d);
          }
        }
        else
        {
          context.footnote (format (STRING_EDIT_UDA_DEL, col->first));
          task.remove (col->first);
        }
      }
    }
  }

  // UDA orphans
  std::vector <std::string> orphanValues = findValues (after, "\n  UDA Orphan ");
  std::vector <std::string>::iterator orphan;
  for (orphan = orphanValues.begin (); orphan != orphanValues.end (); ++orphan)
  {
    std::string::size_type colon = orphan->find (':');
    if (colon != std::string::npos)
    {
      std::string name  = trim (orphan->substr (0, colon),  "\t ");
      std::string value = trim (orphan->substr (colon + 1), "\t ");

      if (value != "")
        task.set (name, value);
      else
        task.remove (name);
    }
  }
}
开发者ID:gerarldlee,项目名称:task,代码行数:101,代码来源:CmdEdit.cpp

示例12: findValue


//.........这里部分代码省略.........
        // we need to increment until we find an unused key
        int timestamp = (int) when.toEpoch ();

        std::stringstream name;

        do
        {
          name.str ("");  // Clear
          name << "annotation_" << timestamp;
          timestamp++;
        }
        while (annotations.find (name.str ()) != annotations.end ());

        std::string text = trim (value.substr (gap + 4), "\t ");
        annotations.insert (std::make_pair (name.str (), json::decode (text)));
      }
    }
  }

  task.setAnnotations (annotations);

  // Dependencies
  value = findValue (after, "\n  Dependencies:");
  std::vector <std::string> dependencies;
  split (dependencies, value, ",");

  task.remove ("depends");
  for (auto& dep : dependencies)
  {
    if (dep.length () >= 7)
      task.addDependency (dep);
    else
      task.addDependency ((int) strtol (dep.c_str (), NULL, 10));
  }

  // UDAs
  for (auto& col : context.columns)
  {
    std::string type = context.config.get ("uda." + col.first + ".type");
    if (type != "")
    {
      std::string value = findValue (after, "\n  UDA " + col.first + ":");
      if ((task.get (col.first) != value) && (type != "date" ||
           (task.get (col.first) != ISO8601d (value, dateformat).toEpochString ())) &&
           (type != "duration" ||
           (task.get (col.first) != (std::string) ISO8601p (value))))
      {
        if (value != "")
        {
          context.footnote (format (STRING_EDIT_UDA_MOD, col.first));

          if (type == "string")
          {
            task.set (col.first, value);
          }
          else if (type == "numeric")
          {
            Nibbler n (value);
            double d;
            if (n.getNumber (d) &&
                n.depleted ())
              task.set (col.first, value);
            else
              throw format (STRING_UDA_NUMERIC, value);
          }
          else if (type == "date")
          {
            task.set (col.first, ISO8601d (value, dateformat).toEpochString ());
          }
          else if (type == "duration")
          {
            task.set (col.first, (time_t) ISO8601p (value));
          }
        }
        else
        {
          context.footnote (format (STRING_EDIT_UDA_DEL, col.first));
          task.remove (col.first);
        }
      }
    }
  }

  // UDA orphans
  std::vector <std::string> orphanValues = findValues (after, "\n  UDA Orphan ");
  for (auto& orphan : orphanValues)
  {
    auto colon = orphan.find (':');
    if (colon != std::string::npos)
    {
      std::string name  = trim (orphan.substr (0, colon),  "\t ");
      std::string value = trim (orphan.substr (colon + 1), "\t ");

      if (value != "")
        task.set (name, value);
      else
        task.remove (name);
    }
  }
}
开发者ID:austinwagner,项目名称:task,代码行数:101,代码来源:CmdEdit.cpp

示例13: clear

////////////////////////////////////////////////////////////////////////////////
// Attempt an FF4 parse first, using Task::parse, and in the event of an error
// try a legacy parse (F3, FF2).  Note that FF1 is no longer supported.
//
// start --> [ --> Att --> ] --> end
//              ^       |
//              +-------+
//
void Task::parse (const std::string& input)
{
  std::string copy;
  if (input[input.length () - 1] == '\n')
    copy = input.substr (0, input.length () - 1);
  else
    copy = input;

  try
  {
    clear ();

    Nibbler n (copy);
    std::string line;
    if (n.skip     ('[')       &&
        n.getUntil (']', line) &&
        n.skip     (']')       &&
        n.depleted ())
    {
      if (line.length () == 0)
        throw std::string (STRING_RECORD_EMPTY);

      Nibbler nl (line);
      std::string name;
      std::string value;
      while (!nl.depleted ())
      {
        if (nl.getUntil (':', name) &&
            nl.skip (':')           &&
            nl.getQuoted ('"', value))
        {
          // Experimental legacy value translation of 'recur:m' --> 'recur:mo'.
          if (name == "recur" &&
              digitsOnly (value.substr (0, value.length () - 1)) &&
              value[value.length () - 1] == 'm')
            value += 'o';

          if (name.substr (0, 11) == "annotation_")
            ++annotation_count;

          (*this)[name] = decode (json::decode (value));
        }

        nl.skip (' ');
      }

      std::string remainder;
      nl.getUntilEOS (remainder);
      if (remainder.length ())
        throw std::string (STRING_RECORD_JUNK_AT_EOL);
    }
    else
      throw std::string (STRING_RECORD_NOT_FF4);
  }

  catch (const std::string&)
  {
    legacyParse (copy);
  }

  recalc_urgency = true;
}
开发者ID:nigeil,项目名称:task,代码行数:70,代码来源:Task.cpp

示例14: error


//.........这里部分代码省略.........
          << "\n\n";
  }

  // Display the unrecognized variables.
  if (unrecognized.size ())
  {
    out << STRING_CMD_SHOW_UNREC << "\n";

    for (i = unrecognized.begin (); i != unrecognized.end (); ++i)
      out << "  " << *i << "\n";

    if (context.color ())
      out << "\n  " << format (STRING_CMD_SHOW_DIFFER_COLOR, error.colorize ("color"));

    out << "\n\n";
  }

  out << legacyCheckForDeprecatedVariables ();
  out << legacyCheckForDeprecatedColor ();
  out << legacyCheckForDeprecatedColumns ();

  // TODO Check for referenced but missing theme files.
  // TODO Check for referenced but missing string files.
  // TODO Check for referenced but missing tips files.

  // Check for referenced but missing hook scripts.
#ifdef HAVE_LIBLUA
  std::vector <std::string> missing_scripts;
  for (i = all.begin (); i != all.end (); ++i)
  {
    if (i->substr (0, 5) == "hook.")
    {
      std::string value = context.config.get (*i);
      Nibbler n (value);

      // <path>:<function> [, ...]
      while (!n.depleted ())
      {
        std::string file;
        std::string function;
        if (n.getUntil (':', file) &&
            n.skip (':')           &&
            n.getUntil (',', function))
        {
          Path script (file);
          if (!script.exists () || !script.readable ())
            missing_scripts.push_back (file);

          (void) n.skip (',');
        }
      }
    }
  }

  if (missing_scripts.size ())
  {
    out << STRING_CMD_SHOW_HOOKS << "\n";

    for (i = missing_scripts.begin (); i != missing_scripts.end (); ++i)
      out << "  " << *i << "\n";

    out << "\n";
  }
#endif

  // Check for bad values in rc.annotations.
开发者ID:SEJeff,项目名称:task,代码行数:67,代码来源:CmdShow.cpp

示例15: n

bool Duration::parse (const std::string& input, std::string::size_type& start)
{
  std::string::size_type original_start = start;
  Nibbler n (input.substr (start));

  // Static and so preserved between calls.
  static std::vector <std::string> units;
  if (units.size () == 0)
    for (unsigned int i = 0; i < NUM_DURATIONS; i++)
      units.push_back (durations[i].unit);

  std::string number;
  std::string unit;

  if (n.getOneOf (units, unit))
  {
    if (n.depleted () ||
        Lexer::isWhitespace (n.next ()))
    {
      start = original_start + n.cursor ();

      // Linear lookup - should be logarithmic.
      for (unsigned int i = 0; i < NUM_DURATIONS; i++)
      {
        if (durations[i].unit == unit &&
            durations[i].standalone == true)
        {
          _secs = static_cast <int> (durations[i].seconds);
          return true;
        }
      }
    }
  }

  else if (n.getNumber (number))
  {
    n.skipWS ();
    if (n.getOneOf (units, unit))
    {
      if (n.depleted () ||
          Lexer::isWhitespace (n.next ()))
      {
        start = original_start + n.cursor ();
        double quantity = strtod (number.c_str (), NULL);

        // Linear lookup - should be logarithmic.
        double seconds = 1;
        for (unsigned int i = 0; i < NUM_DURATIONS; i++)
        {
          if (durations[i].unit == unit)
          {
            seconds = durations[i].seconds;
            _secs = static_cast <int> (quantity * static_cast <double> (seconds));
            return true;
          }
        }
      }
    }
  }

  return false;
}
开发者ID:gerarldlee,项目名称:task,代码行数:62,代码来源:Duration.cpp


注:本文中的Nibbler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。