Logo Search packages:      
Sourcecode: verbiste version File versions

int verbiste::Command::run ( int  argc,
char *  argv[] 
) throw ()

Use the given arguments as verbs, or stdin if no arguments are given. If arguments are given, argv[0] must be the first argument, and not the name of the current program. The verbs are expected to be in Latin-1 (ISO-8859-1). They are converted to lower-case and passed to the processInputWord() method, which must be overridden by a class derived from this one.

Definition at line 47 of file Command.cpp.

References fvd, processInputWord(), and verbiste::FrenchVerbDictionary::tolowerLatin1().

{
    int optind = 0;
    bool useArgs = (optind < argc);

    try
    {
      if (fvd == NULL)
          throw logic_error("fvd is NULL");

      for (;;)
      {
          string latin1InputWord;

          if (useArgs)
          {
            if (optind == argc)
                break;

            latin1InputWord = argv[optind];
            optind++;
          }
          else
          {
            if (!getline(cin, latin1InputWord))
                break;
          }


          // Source is assumed to be in ISO-8859-1; convert it to lower-case.
          processInputWord(fvd->tolowerLatin1(latin1InputWord));
      }
    }
    catch (const exception &e)
    {
      cerr << "Exception: " << e.what() << endl;
      return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index