<commit_before>#include <iostream>
#include <cstdlib>
#include <cassert>
#include "MeshPartReader.h"
#include "StringUtils.h"

using namespace std;
using namespace cigma;

// ---------------------------------------------------------------------------

MeshPartReader::MeshPartReader()
{
    meshPart = 0;
    meshReader = 0;
    coordsReader = 0;
    connectReader = 0;
}

MeshPartReader::~MeshPartReader()
{
    if (meshPart != 0)
    {
        if (meshPart->coords != 0)
        {
            delete [] meshPart->coords;
            meshPart->coords = 0;
        }

        if (meshPart->connect != 0)
        {
            delete [] meshPart->connect;
            meshPart->connect = 0;
        }

        delete meshPart;
        meshPart = 0;
    }
}

// ---------------------------------------------------------------------------

void MeshPartReader::load_args(AnyOption *opt, const char *opt_prefix)
{
    assert(opt != 0);

    char *in;
    string optstr;
    string mesh_name = opt_prefix;

    in = opt->getValue(mesh_name.c_str());
    if (in != 0)
    {
        this->meshPath = in;
    }

    optstr = mesh_name + "-coordinates";
    in = opt->getValue(optstr.c_str());
    if (in != 0)
    {
        this->coordsPath = in;
    }

    optstr = mesh_name + "-connectivity";
    in = opt->getValue(optstr.c_str());
    if (in != 0)
    {
        this->connectPath = in;
    }
}

void MeshPartReader::validate_args(const char *cmd_name)
{
    if (has_paths())
    {
        if (meshPath == "")
        {
            if (coordsPath == "")
            {
                cerr << cmd_name
                     << ": Detected missing option --mesh-coordinates"
                     << endl;
                exit(1);
            }
            if (connectPath == "")
            {
                cerr << cmd_name
                     << ": Detected missing option --mesh-connectivity"
                     << endl;
                exit(1);
            }
        }
    }
}

// ---------------------------------------------------------------------------

bool MeshPartReader::has_paths()
{
    return (meshPath != "") || (coordsPath != "") || (connectPath != "");
}

bool MeshPartReader::has_coords_path()
{
    return (meshPath != "") || (coordsPath != "");
}

bool MeshPartReader::has_connect_path()<commit_msg>Updated error msgs (option prefix can change, as it does in CompareCmd)<commit_after>#include <iostream>
#include <cstdlib>
#include <cassert>
#include "MeshPartReader.h"
#include "StringUtils.h"

using namespace std;
using namespace cigma;

// ---------------------------------------------------------------------------

MeshPartReader::MeshPartReader()
{
    meshPart = 0;
    meshReader = 0;
    coordsReader = 0;
    connectReader = 0;
}

MeshPartReader::~MeshPartReader()
{
    if (meshPart != 0)
    {
        if (meshPart->coords != 0)
        {
            delete [] meshPart->coords;
            meshPart->coords = 0;
        }

        if (meshPart->connect != 0)
        {
            delete [] meshPart->connect;
            meshPart->connect = 0;
        }

        delete meshPart;
        meshPart = 0;
    }
}

// ---------------------------------------------------------------------------

void MeshPartReader::load_args(AnyOption *opt, const char *opt_prefix)
{
    assert(opt != 0);

    char *in;
    string optstr;
    string mesh_name = opt_prefix;

    in = opt->getValue(mesh_name.c_str());
    if (in != 0)
    {
        this->meshPath = in;
    }

    optstr = mesh_name + "-coordinates";
    in = opt->getValue(optstr.c_str());
    if (in != 0)
    {
        this->coordsPath = in;
    }

    optstr = mesh_name + "-connectivity";
    in = opt->getValue(optstr.c_str());
    if (in != 0)
    {
        this->connectPath = in;
    }
}

void MeshPartReader::validate_args(const char *cmd_name)
{
    if (has_paths())
    {
        if (meshPath == "")
        {
            if (coordsPath == "")
            {
                cerr << cmd_name
                     << ": Missing mesh coordinates option"
                     << endl;
                exit(1);
            }
            if (connectPath == "")
            {
                cerr << cmd_name
                     << ": Missing mesh connectivity option"
                     << endl;
                exit(1);
            }
        }
    }
}

// ---------------------------------------------------------------------------

bool MeshPartReader::has_paths()
{
    return (meshPath != "") || (coordsPath != "") || (connectPath != "");
}

bool MeshPartReader::has_coords_path()
{
    return (meshPath != "") || (coordsPath != "");
}

bool MeshPartReader::has_connect_path()
{'fraction_non_alphanumeric': 0.22548179871520344, 'fraction_numerical': 0.006852248394004282, 'mean_word_length': 1.3425275827482448, 'pattern_counts': {'":': 4, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6850417', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1333, 'n_words': 270}