<commit_before>// DOMWriter.cpp : Defines the entry point for the application.
//

#pragma warning(disable: 4786 4250 4503)

#include <string>
#include <DOM/SAX2DOM/SAX2DOM.h>
#include <DOM/Utils/Stream.h>

////////////////////////////////////////////////
int main(int argc, char* argv[])
{
  if(argc < 2) 
  {
    std::cout << "Usage : " << argv[0] << " xmlfile ... " << std::endl;
    return 0;
  } // if(argc < 2)

  { // narrow
    SAX2DOM::Parser<std::string> domParser;

	  for(int i = 1; i < argc; ++i)
    {
      std::string file(argv[i]);
      SAX::InputSource is;
      is.setSystemId(file);

      if(file != "-")
        domParser.parse(is);
      else
      {
        is.setSystemId("stdin");
        is.setByteStream(std::cin);

        domParser.parse(is);
      } // if(file != "-")

      DOM::Document<std::string> doc = domParser.getDocument();

      std::cout << doc;
    } // for ...
  } 

/*
  { // wide
    SAX2DOM::Parser<std::wstring> domParser;

    SAX::wInputSource is;
    is.setSystemId(L"stdin");
    is.setByteStream(std::cin);

    domParser.parse(is);

    DOM::Document<std::wstring> doc = domParser.getDocument();

    std::wcout << doc;
  }
*/

  return 0;
} // main

// end of file<commit_msg>Use CatchErrorHandler to report errors<commit_after>// DOMWriter.cpp : Defines the entry point for the application.
//

#pragma warning(disable: 4786 4250 4503)

#include <string>
#include <DOM/SAX2DOM/SAX2DOM.h>
#include <SAX/helpers/CatchErrorHandler.h>
#include <DOM/Utils/Stream.h>

////////////////////////////////////////////////
int main(int argc, char* argv[])
{
  if(argc < 2) 
  {
    std::cout << "Usage : " << argv[0] << " xmlfile ... " << std::endl;
    return 0;
  } // if(argc < 2)

  { // narrow
    SAX2DOM::Parser<std::string> domParser;
    SAX::CatchErrorHandler<std::string> eh;
    domParser.setErrorHandler(eh);

	  for(int i = 1; i < argc; ++i)
    {
      std::string file(argv[i]);
      SAX::InputSource is;
      is.setSystemId(file);

      if(file != "-")
        domParser.parse(is);
      else
      {
        is.setSystemId("stdin");
        is.setByteStream(std::cin);

        domParser.parse(is);
      } // if(file != "-")

      if(!eh.errorsReported())
      {
        DOM::Document<std::string> doc = domParser.getDocument();
        std::cout << doc;
      }
      else
      {
        std::cerr << eh.errors() << std::endl;
        eh.reset();
      } // if ...
    } // for ...
  } 

/*
  { // wide
    SAX2DOM::Parser<std::wstring> domParser;

    SAX::wInputSource is;
    is.setSystemId(L"stdin");
    is.setByteStream(std::cin);

    domParser.parse(is);

    DOM::Document<std::wstring> doc = domParser.getDocument();

    std::wcout << doc;
  }
*/

  return 0;
} // main

// end of file
{'fraction_non_alphanumeric': 0.2109064644275912, 'fraction_numerical': 0.015890213073311666, 'mean_word_length': 2.1334841628959276, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7033714', 'n_tokens_mistral': 1023, 'n_tokens_neox': 969, 'n_words': 179}