<commit_before>/*
  MusicXML Library
  Copyright (C) Grame 2006-2013

  This Source Code Form is subject to the terms of the Mozilla Public
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.

  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
  research@<EMAIL>.fr
*/

#include <sstream>

#include <climits>      /* INT_MIN, INT_MAX */
#include <iomanip>      // setw, set::precision, ...

#include "xml2lilypondOptionsHandling.h"

#include "generalOptions.h"
#include "musicXMLOptions.h"
#include "msrOptions.h"
#include "lpsrOptions.h"
#include "lilypondOptions.h"

#include "utilities.h"


using namespace std;

namespace MusicXML2 
{

#define TRACE_OPTIONS 0

//______________________________________________________________________________
S_xml2lilypondOptionsHandler xml2lilypondOptionsHandler::create (
  indentedOstream& ios)
{
  xml2lilypondOptionsHandler* o = new
    xml2lilypondOptionsHandler (
      ios);
  assert(o!=0);
  return o;
}

xml2lilypondOptionsHandler::xml2lilypondOptionsHandler (
  indentedOstream& ios)
  : msrOptionsHandler (
    "Available options",
    "Options values",
    "h", "help",
    "hs", "helpSummary",
R"(
                Welcome to xml2lilypond v0.1.0, 
              the MusicXML to LilyPond translator
          delivered as part of the libmusicxml2 library.
      https://github.com/grame-cncm/libmusicxml/tree/lilypond

Usage:

    xml2lilypond [options] [MusicXMLFile|-] [options] 

What it does:

    This multi-pass translator basically performs 4 passes:
        Pass 1: reads the contents of MusicXMLFile or stdin ('-')
                and converts it to a MusicXML tree;
        Pass 2: converts that tree to a Music Score Representation (MSR);
        Pass 3: converts the MSR to a LilyPond Score Representation (LPSR);
        Pass 4: converts the LPSR to LilyPond source code 
                and writes it to standard output.

    Other passes are performed according to the options, such as
    printing views of the internal data or printing a summary of the score.

    '-' as an argument represents standard input.

    A number of options exist to fine tune the generated LilyPond code
    and limit the need for manually editing the latter.
    Most options have a short and a long name for commodity.

    The options are organized in a group-subgroup-item hierarchy.
    Help can be obtained for groups or subgroups at will,
    as well as for any option with the '-ih, itemHelp' option.
    
    A subgroup displayed with '***' has its description printed
    only when the corresponding item short or long names are used.
    
    Both '-' and '--' can be used to introduce options in the command line,
    even though the help facility only shows them with '-'.

    Command line options and arguments can be placed in any order,
    provided item values immediately follow the corresponding items.
    
    The activity log and warning/error messages go to standard error.
)",
R"(
Options '-h, -help' print the full help,
while '-hs, -helpSummary' only print a help summary.)",
    ios
    )
{
  initializeOptionsHandler ();
}

xml2lilypondOptionsHandler::~xml2lilypondOptionsHandler ()
{}

void xml2lilypondOptionsHandler::initializeOptionsHandler ()
{
  // initialize options handling
  // ------------------------------------------------------

  initializeGeneralOptionsHandling (
    this);
    
  initializeMusicXMLOptionsHandling (
    this);
    
  initializeMsrOptionsHandling (
    this);
    
  initializeLpsrOptionsHandling (
    this);
    
  initializeLilypondOptionsHandling (
    this);

    /* JMI
  // append the various options groups
  // ------------------------------------------------------
  
  appendOptionsGroup (
    gGeneralOptions);
    
 // appendOptionsGroup (
//    gMusicXMLOptions);
    
  appendOptionsGroup (
    gMsrOptions);
    
  appendOptionsGroup (
    gLpsrOptions);
    
  appendOptionsGroup (
    gLilypondOptions);
*/

  if (TRACE_OPTIONS) {
    // print the options handler initial state
    fOptionsHandlerLogIOstream <<
      "xml2lilypondOptionsHandler has been initialized as:" <<
      endl;
  
    gIndenter++;
  
    print (
      fOptionsHandlerLogIOstream);
    fOptionsHandlerLogIOstream <<
      endl <<
      endl;
    
    gIndenter--;
  }

  // register options handler in itself,
  // so that the 'global' help options can be handled
//  this->
//    registerOptionsHandlerInItself ();

  if (TRACE_OPTIONS) {
    fOptionsHandlerLogIOstream <<
      "xml2lilypondOptionsHandler help:" <<
      endl;

    this->
      printHelp (
        fOptionsHandlerLogIOstream);
  }
}

void xml2lilypondOptionsHandler::checkOptionsAndArguments ()
{
  unsigned int argumentsNumber =<commit_msg>options 21<commit_after>/*
  MusicXML Library
  Copyright (C) Grame 2006-2013

  This Source Code Form is subject to the terms of the Mozilla Public
  License, v. 2.0. If a copy of the MPL was not distributed with this
  file, You can obtain one at http://mozilla.org/MPL/2.0/.

  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
  research@grame.fr
*/

#include <sstream>

#include <climits>      /* INT_MIN, INT_MAX */
#include <iomanip>      // setw, set::precision, ...

#include "xml2lilypondOptionsHandling.h"

#include "generalOptions.h"
#include "musicXMLOptions.h"
#include "msrOptions.h"
#include "lpsrOptions.h"
#include "lilypondOptions.h"

#include "utilities.h"


using namespace std;

namespace MusicXML2 
{

#define TRACE_OPTIONS 0

//______________________________________________________________________________
S_xml2lilypondOptionsHandler xml2lilypondOptionsHandler::create (
  indentedOstream& ios)
{
  xml2lilypondOptionsHandler* o = new
    xml2lilypondOptionsHandler (
      ios);
  assert(o!=0);
  return o;
}

xml2lilypondOptionsHandler::xml2lilypondOptionsHandler (
  indentedOstream& ios)
  : msrOptionsHandler (
    "Available options",
    "Options values",
    "h", "help",
    "hs", "helpSummary",
R"(
                Welcome to xml2lilypond v0.1.0, 
              the MusicXML to LilyPond translator
          delivered as part of the libmusicxml2 library.
      https://github.com/grame-cncm/libmusicxml/tree/lilypond

Usage:

    xml2lilypond [options] [MusicXMLFile|-] [options] 

What it does:

    This multi-pass translator basically performs 4 passes:
        Pass 1: reads the contents of MusicXMLFile or stdin ('-')
                and converts it to a MusicXML tree;
        Pass 2: converts that tree to a Music Score Representation (MSR);
        Pass 3: converts the MSR to a LilyPond Score Representation (LPSR);
        Pass 4: converts the LPSR to LilyPond source code 
                and writes it to standard output.

    Other passes are performed according to the options, such as
    printing views of the internal data or printing a summary of the score.

    '-' as an argument represents standard input.

    A number of options exist to fine tune the generated LilyPond code
    and limit the need for manually editing the latter.
    Most options have a short and a long name for commodity.

    The options are organized in a group-subgroup-item hierarchy.
    Help can be obtained for groups or subgroups at will,
    as well as for any option with the '-ih, itemHelp' option.
    
    A subgroup displayed with '***' has its description printed
    only when the corresponding item short or long names are used.
    
    Both '-' and '--' can be used to introduce options in the command line,
    even though the help facility only shows them with '-'.

    Command line options and arguments can be placed in any order,
    provided item values immediately follow the corresponding items.
    
    The activity log and warning/error messages go to standard error.
)",
R"(
Options '-h, -help' print the full help,
while '-hs, -helpSummary' only print a help summary.)",
    ios
    )
{
  initializeOptionsHandler ();
}

xml2lilypondOptionsHandler::~xml2lilypondOptionsHandler ()
{}

void xml2lilypondOptionsHandler::initializeOptionsHandler ()
{
  // initialize options handling
  // ------------------------------------------------------

  initializeGeneralOptionsHandling (
    this);
    
  initializeMusicXMLOptionsHandling (
    this);
    
  initializeMsrOptionsHandling (
    this);
    
  initializeLpsrOptionsHandling (
    this);
    
  initializeLilypondOptionsHandling (
    this);

    /* JMI
  // append the various options groups
  // ------------------------------------------------------
  
  appendOptionsGroup (
    gGeneralOptions);
    
 // appendOptionsGroup (
//    gMusicXMLOptions);
    
  appendOptionsGroup (
    gMsrOptions);
    
  appendOptionsGroup (
    gLpsrOptions);
    
  appendOptionsGroup (
    gLilypondOptions);
*/

  if (TRACE_OPTIONS) {
    // print the options handler initial state
    fOptionsHandlerLogIOstream <<
      "xml2lilypondOptionsHandler has been initialized as:" <<
      endl;
  
    gIndenter++;
  
    print (
      fOptionsHandlerLogIOstream);
    fOptionsHandlerLogIOstream <<
      endl <<
      endl;
    
    gIndenter--;
  }

  // register options handler in itself,
  // so that the 'global' help options can be handled
  this->
    registerOptionsHandlerInItself ();

  if (TRACE_OPTIONS) {
    fOptionsHandlerLogIOstream <<
      "xml2lilypondOptionsHandler help:" <<
      endl;

    this->
      printHelp (
        fOptionsHandlerLogIOstream);
  }
}

void xml2lilypondOptionsHandler::checkOptionsAndArguments ()
{
  unsigned int argumentsNumber =
{'fraction_non_alphanumeric': 0.09766233766233766, 'fraction_numerical': 0.009766233766233767, 'mean_word_length': 2.795741324921136, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 14, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 34}, 'pii_count': 1, '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': '5034400', 'n_tokens_mistral': 2803, 'n_tokens_neox': 2700, 'n_words': 913}