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 984 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 3356 of file exodusII_io_helper.C.

3356  :
3357  data_table(n_strings),
3358  data_table_pointers(n_strings),
3359  counter(0),
3360  table_size(n_strings)
3361 {
3362  for (size_t i=0; i<n_strings; ++i)
3363  {
3364  data_table[i].resize(string_length + 1);
3365 
3366  // Properly terminate these C-style strings, just to be safe.
3367  data_table[i][0] = '\0';
3368 
3369  // Set pointer into the data_table
3370  data_table_pointers[i] = data_table[i].data();
3371  }
3372 }

References data_table, and data_table_pointers.

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 3399 of file exodusII_io_helper.C.

3400 {
3401  if (static_cast<unsigned>(i) >= table_size)
3402  libmesh_error_msg("Requested char * " << i << " but only have " << table_size << "!");
3403 
3404  else
3405  return data_table[i].data();
3406 }

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

◆ 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 3376 of file exodusII_io_helper.C.

3377 {
3378  libmesh_assert_less (counter, table_size);
3379 
3380  // 1.) Copy the C++ string into the vector<char>...
3381  size_t num_copied = name.copy(data_table[counter].data(), data_table[counter].size()-1);
3382 
3383  // 2.) ...And null-terminate it.
3384  data_table[counter][num_copied] = '\0';
3385 
3386  // Go to next row
3387  ++counter;
3388 }

References data, and libMesh::Quality::name().

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

Member Data Documentation

◆ counter

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

Definition at line 1015 of file exodusII_io_helper.h.

◆ data_table

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

Definition at line 1012 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 1013 of file exodusII_io_helper.h.

Referenced by NamesData().

◆ table_size

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

Definition at line 1016 of file exodusII_io_helper.h.


The documentation for this class was generated from the following files:
libMesh::ExodusII_IO_Helper::NamesData::data_table
std::vector< std::vector< char > > data_table
Definition: exodusII_io_helper.h:1012
libMesh::ExodusII_IO_Helper::NamesData::data_table_pointers
std::vector< char * > data_table_pointers
Definition: exodusII_io_helper.h:1013
libMesh::ExodusII_IO_Helper::NamesData::table_size
size_t table_size
Definition: exodusII_io_helper.h:1016
data
IterBase * data
Ideally this private member data should have protected access.
Definition: variant_filter_iterator.h:337
libMesh::ExodusII_IO_Helper::NamesData::counter
size_t counter
Definition: exodusII_io_helper.h:1015
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42