<commit_before>// The libMesh Finite Element Library.
// Copyright (C) 2002-2012 <NAME>, <NAME>, <NAME>

// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



#ifndef __mesh_input_h__
#define __mesh_input_h__


// Local includes
#include "libmesh/libmesh_common.h"
#include "libmesh/mesh_base.h"

// C++ includes
#include <cstddef>
#include <istream>
#include <string>
#include <vector>

namespace libMesh
{



/**
 * This class defines an abstract interface for \p Mesh input.
 * Specific classes derived from this class actually implement
 * reading various mesh formats.
 *
 * \author <NAME>
 * \date 2004
 */

// ------------------------------------------------------------
// MeshInput class definition
template <class MT>
class MeshInput
{
 protected:

  /**
   * Default constructor. Will set the _obj to NULL, effectively
   * rendering this object useless.
   */
  explicit
  MeshInput (bool is_parallel_format = false);

  /**
   * Constructor.  Takes a writeable reference to an object.
   * This is the constructor required to read an object.
   */
  explicit
  MeshInput (MT&, const bool is_parallel_format = false);

 public:

  /**
   * Destructor.
   */
  virtual ~MeshInput ();

  /**
   * This method implements reading a mesh from a specified file.
   */
  virtual void read (const std::string&) = 0;


 protected:

  /**
   * Returns the object as a writeable reference.
   */
  MT& mesh ();

  /**
   * A vector of bools describing what dimension elements
   * have been encountered when reading a mesh.
   */
  std::vector<bool> elems_of_dimension;

  /**
   * Reads input from \p in, skipping all the lines
   * that start with the character \p comment_start.
   */
  void skip_comment_lines (std::istream& in,
			   const char comment_start);


 private:


  /**
   * A pointer to a non-const object object.
   * This allows us to read the object from file.
   */
  MT* _obj;

  /**
   * Flag specifying whether this format is parallel-capable.
   * If this is false (default) I/O is only permitted when the mesh
   * has been serialized.
   */
  const bool _is_parallel_format;
};



// ------------------------------------------------------------
// MeshInput inline members
template <class MT>
inline
MeshInput<MT>::MeshInput (const bool is_parallel_format) :
  elems_of_dimension(),
  _obj (NULL),
  _is_parallel_format(is_parallel_format)
{
}



template <class MT>
inline
MeshInput<MT>::MeshInput (MT& obj, const bool is_parallel_format) :
  elems_of_dimension(),
  _obj (&obj),
  _is_parallel_format(is_parallel_format)
{
  if (!_is_parallel_format && !this->mesh().is_serial())
    {
      if (libMesh::processor_id() == 0)
	{
          libmesh_do_once(libMesh::err <<
            "Warning:  This MeshInput subclass only support meshes which have been serialized!"
	    << std::endl; libmesh_here(););
        }
    }
}



template <class MT>
inline
MeshInput<MT>::~MeshInput ()
{
}



template <class MT>
inline
MT& MeshInput<MT>::mesh ()
{
  if (_obj == NULL) libmesh_error();
  return *_obj;
}



template <class MT>
void MeshInput<MT>::skip_comment_lines (std::istream &in,<commit_msg>Typo fix in warning message<commit_after>// The libMesh Finite Element Library.
// Copyright (C) 2002-2012 <NAME>, <NAME>, <NAME>

// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



#ifndef __mesh_input_h__
#define __mesh_input_h__


// Local includes
#include "libmesh/libmesh_common.h"
#include "libmesh/mesh_base.h"

// C++ includes
#include <cstddef>
#include <istream>
#include <string>
#include <vector>

namespace libMesh
{



/**
 * This class defines an abstract interface for \p Mesh input.
 * Specific classes derived from this class actually implement
 * reading various mesh formats.
 *
 * \author <NAME>
 * \date 2004
 */

// ------------------------------------------------------------
// MeshInput class definition
template <class MT>
class MeshInput
{
 protected:

  /**
   * Default constructor. Will set the _obj to NULL, effectively
   * rendering this object useless.
   */
  explicit
  MeshInput (bool is_parallel_format = false);

  /**
   * Constructor.  Takes a writeable reference to an object.
   * This is the constructor required to read an object.
   */
  explicit
  MeshInput (MT&, const bool is_parallel_format = false);

 public:

  /**
   * Destructor.
   */
  virtual ~MeshInput ();

  /**
   * This method implements reading a mesh from a specified file.
   */
  virtual void read (const std::string&) = 0;


 protected:

  /**
   * Returns the object as a writeable reference.
   */
  MT& mesh ();

  /**
   * A vector of bools describing what dimension elements
   * have been encountered when reading a mesh.
   */
  std::vector<bool> elems_of_dimension;

  /**
   * Reads input from \p in, skipping all the lines
   * that start with the character \p comment_start.
   */
  void skip_comment_lines (std::istream& in,
			   const char comment_start);


 private:


  /**
   * A pointer to a non-const object object.
   * This allows us to read the object from file.
   */
  MT* _obj;

  /**
   * Flag specifying whether this format is parallel-capable.
   * If this is false (default) I/O is only permitted when the mesh
   * has been serialized.
   */
  const bool _is_parallel_format;
};



// ------------------------------------------------------------
// MeshInput inline members
template <class MT>
inline
MeshInput<MT>::MeshInput (const bool is_parallel_format) :
  elems_of_dimension(),
  _obj (NULL),
  _is_parallel_format(is_parallel_format)
{
}



template <class MT>
inline
MeshInput<MT>::MeshInput (MT& obj, const bool is_parallel_format) :
  elems_of_dimension(),
  _obj (&obj),
  _is_parallel_format(is_parallel_format)
{
  if (!_is_parallel_format && !this->mesh().is_serial())
    {
      if (libMesh::processor_id() == 0)
	{
          libmesh_do_once(libMesh::err <<
            "Warning:  This MeshInput subclass only supports meshes which have been serialized!"
	    << std::endl; libmesh_here(););
        }
    }
}



template <class MT>
inline
MeshInput<MT>::~MeshInput ()
{
}



template <class MT>
inline
MT& MeshInput<MT>::mesh ()
{
  if (_obj == NULL) libmesh_error();
  return *_obj;
}



template <class MT>
void MeshInput<MT>::skip_comment_lines (std::istream &in,
{'fraction_non_alphanumeric': 0.13098831867699173, 'fraction_numerical': 0.00787504921905762, 'mean_word_length': 2.917737789203085, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 45, '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': '1987688', 'n_tokens_mistral': 2324, 'n_tokens_neox': 2193, 'n_words': 831}