Example #1
0
void ConsoleTools::profile(int loopCount){
  clock_t msecs;

  // parsers factory
  ParserFactory pf(catalogPath);
  // Source file text lines store.
  TextLinesStore textLinesStore;
  textLinesStore.loadFile(inputFileName, inputEncoding, true);
  // Base editor to make primary parse
  BaseEditor baseEditor(&pf, &textLinesStore);
  // HRD RegionMapper linking
  baseEditor.setRegionMapper(&DString("console"), hrdName);
  FileType *type = selectType(pf.getHRCParser(), &textLinesStore);
  type->getBaseScheme();
  baseEditor.setFileType(type);

  msecs = clock();
  while(loopCount--){
    baseEditor.modifyLineEvent(0);
    baseEditor.lineCountEvent(textLinesStore.getLineCount());
    baseEditor.validate(-1, false);
  }
  msecs = clock() - msecs;

  printf("%ld\n", (msecs*1000)/CLOCKS_PER_SEC );
}
Example #2
0
void ConsoleTools::listTypes(bool load, bool useNames){
  Writer *writer = null;
  try{
    writer = new StreamWriter(stdout, outputEncodingIndex, bomOutput);
    ParserFactory pf(catalogPath);
    HRCParser *hrcParser = pf.getHRCParser();
    fprintf(stderr, "\nloading file types...\n");
    for(int idx = 0;; idx++){
      FileType *type = hrcParser->enumerateFileTypes(idx);
      if (type == null) break;
      if (useNames){
        writer->write(StringBuffer(type->getName())+"\n");
      }else{
        if (type->getGroup() != null){
          writer->write(StringBuffer(type->getGroup()) + ": ");
        }
        writer->write(type->getDescription());
        writer->write(DString("\n"));
      }

      if (load) type->getBaseScheme();
    }
    delete writer;
  }catch(Exception &e){
    delete writer;
    fprintf(stderr, "%s\n", e.getMessage()->getChars());
  }
}