libMesh
Public Member Functions | Private Attributes | List of all members
libMesh::ExodusII_IO_Helper::NamesData Class Reference

This class is useful for managing anything that requires a char ** input/output in ExodusII file. More...

#include <exodusII_io_helper.h>

Public Member Functions

 NamesData (size_t n_strings, size_t string_length)
 Constructor. More...
 
void push_back_entry (const std::string &name)
 Adds another name to the current data table. More...
 
char ** get_char_star_star ()
 Provide access to the underlying C data table. More...
 
char * get_char_star (int i)
 Provide access to the i'th underlying char *. More...
 

Private Attributes

std::vector< std::vector< char > > data_table
 
std::vector< char * > data_table_pointers
 
size_t counter
 
size_t table_size
 

Detailed Description

This class is useful for managing anything that requires a char ** input/output in ExodusII file.

You must know the number of strings and the length of each one at the time you create it.

Definition at line 1253 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

◆ NamesData()

libMesh::ExodusII_IO_Helper::NamesData::NamesData ( size_t  n_strings,
size_t  string_length 
)
explicit

Constructor.

Allocates enough storage to hold n_strings of length string_length. (Actually allocates string_length+1 characters per string to account for the trailing '\0' character.)

Definition at line 4850 of file exodusII_io_helper.C.

References data_table, and data_table_pointers.

4850  :
4851  data_table(n_strings),
4852  data_table_pointers(n_strings),
4853  counter(0),
4854  table_size(n_strings)
4855 {
4856  for (size_t i=0; i<n_strings; ++i)
4857  {
4858  data_table[i].resize(string_length + 1);
4859 
4860  // Properly terminate these C-style strings, just to be safe.
4861  data_table[i][0] = '\0';
4862 
4863  // Set pointer into the data_table
4864  data_table_pointers[i] = data_table[i].data();
4865  }
4866 }
std::vector< std::vector< char > > data_table

Member Function Documentation

◆ get_char_star()

char * libMesh::ExodusII_IO_Helper::NamesData::get_char_star ( int  i)

Provide access to the i'th underlying char *.

Definition at line 4893 of file exodusII_io_helper.C.

Referenced by libMesh::ExodusII_IO_Helper::read_var_names_impl(), and libMesh::ExodusII_IO_Helper::write_var_names_impl().

4894 {
4895  libmesh_error_msg_if(static_cast<unsigned>(i) >= table_size,
4896  "Requested char * " << i << " but only have " << table_size << "!");
4897 
4898  return data_table[i].data();
4899 }
std::vector< std::vector< char > > data_table

◆ get_char_star_star()

char ** libMesh::ExodusII_IO_Helper::NamesData::get_char_star_star ( )

◆ push_back_entry()

void libMesh::ExodusII_IO_Helper::NamesData::push_back_entry ( const std::string &  name)

Adds another name to the current data table.

Definition at line 4870 of file exodusII_io_helper.C.

References libMesh::Quality::name().

Referenced by libMesh::Nemesis_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_sidesets(), and libMesh::ExodusII_IO_Helper::write_var_names_impl().

4871 {
4872  libmesh_assert_less (counter, table_size);
4873 
4874  // 1.) Copy the C++ string into the vector<char>...
4875  size_t num_copied = name.copy(data_table[counter].data(), data_table[counter].size()-1);
4876 
4877  // 2.) ...And null-terminate it.
4878  data_table[counter][num_copied] = '\0';
4879 
4880  // Go to next row
4881  ++counter;
4882 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
std::vector< std::vector< char > > data_table

Member Data Documentation

◆ counter

size_t libMesh::ExodusII_IO_Helper::NamesData::counter
private

Definition at line 1284 of file exodusII_io_helper.h.

◆ data_table

std::vector<std::vector<char> > libMesh::ExodusII_IO_Helper::NamesData::data_table
private

Definition at line 1281 of file exodusII_io_helper.h.

Referenced by NamesData().

◆ data_table_pointers

std::vector<char *> libMesh::ExodusII_IO_Helper::NamesData::data_table_pointers
private

Definition at line 1282 of file exodusII_io_helper.h.

Referenced by NamesData().

◆ table_size

size_t libMesh::ExodusII_IO_Helper::NamesData::table_size
private

Definition at line 1285 of file exodusII_io_helper.h.


The documentation for this class was generated from the following files: