libMesh::ExodusII_IO_Helper::NamesData Class Reference

#include <exodusII_io_helper.h>

Public Member Functions

 NamesData (size_t n_strings, size_t string_length)
 
void push_back_entry (const std::string &name)
 
char ** get_char_star_star ()
 
char * get_char_star (int i)
 

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

References data_table, and data_table_pointers.

2503  :
2504  data_table(n_strings),
2505  data_table_pointers(n_strings),
2506  counter(0),
2507  table_size(n_strings)
2508 {
2509  for (size_t i=0; i<n_strings; ++i)
2510  {
2511  data_table[i].resize(string_length + 1);
2512 
2513  // Properly terminate these C-style strings, just to be safe.
2514  data_table[i][0] = '\0';
2515 
2516  // Set pointer into the data_table
2517  data_table_pointers[i] = data_table[i].data();
2518  }
2519 }
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 2546 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().

2547 {
2548  if (static_cast<unsigned>(i) >= table_size)
2549  libmesh_error_msg("Requested char * " << i << " but only have " << table_size << "!");
2550 
2551  else
2552  return data_table[i].data();
2553 }
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 2523 of file exodusII_io_helper.C.

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_nodesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), and libMesh::ExodusII_IO_Helper::write_var_names_impl().

2524 {
2525  libmesh_assert_less (counter, table_size);
2526 
2527  // 1.) Copy the C++ string into the vector<char>...
2528  size_t num_copied = name.copy(data_table[counter].data(), data_table[counter].size()-1);
2529 
2530  // 2.) ...And null-terminate it.
2531  data_table[counter][num_copied] = '\0';
2532 
2533  // Go to next row
2534  ++counter;
2535 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
std::vector< std::vector< char > > data_table
IterBase * data

Member Data Documentation

◆ counter

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

Definition at line 1276 of file exodusII_io_helper.h.

◆ data_table

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

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

Referenced by NamesData().

◆ table_size

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

Definition at line 1277 of file exodusII_io_helper.h.


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