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 1194 of file exodusII_io_helper.h.

Constructor & Destructor Documentation

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 NULL character.)

Definition at line 2450 of file exodusII_io_helper.C.

References data_table, and data_table_pointers.

2450  :
2451  data_table(n_strings),
2452  data_table_pointers(n_strings),
2453  counter(0),
2454  table_size(n_strings)
2455 {
2456  for (size_t i=0; i<n_strings; ++i)
2457  {
2458  data_table[i].resize(string_length + 1);
2459 
2460  // NULL-terminate these strings, just to be safe.
2461  data_table[i][0] = '\0';
2462 
2463  // Set pointer into the data_table
2464  data_table_pointers[i] = &(data_table[i][0]);
2465  }
2466 }
std::vector< std::vector< char > > data_table

Member Function Documentation

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

Provide access to the i'th underlying char *.

Definition at line 2493 of file exodusII_io_helper.C.

References data_table, and table_size.

Referenced by libMesh::ExodusII_IO_Helper::read_var_names_impl().

2494 {
2495  if (static_cast<unsigned>(i) >= table_size)
2496  libmesh_error_msg("Requested char * " << i << " but only have " << table_size << "!");
2497 
2498  else
2499  return &(data_table[i][0]);
2500 }
std::vector< std::vector< char > > data_table
char ** libMesh::ExodusII_IO_Helper::NamesData::get_char_star_star ( )
void libMesh::ExodusII_IO_Helper::NamesData::push_back_entry ( const std::string &  name)

Adds another name to the current data table.

Definition at line 2470 of file exodusII_io_helper.C.

References counter, data_table, and table_size.

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().

2471 {
2472  libmesh_assert_less (counter, table_size);
2473 
2474  // 1.) Copy the C++ string into the vector<char>...
2475  size_t num_copied = name.copy(&data_table[counter][0], data_table[counter].size()-1);
2476 
2477  // 2.) ...And null-terminate it.
2478  data_table[counter][num_copied] = '\0';
2479 
2480  // Go to next row
2481  ++counter;
2482 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
std::vector< std::vector< char > > data_table

Member Data Documentation

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

Definition at line 1225 of file exodusII_io_helper.h.

Referenced by push_back_entry().

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

Definition at line 1222 of file exodusII_io_helper.h.

Referenced by get_char_star(), NamesData(), and push_back_entry().

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

Definition at line 1223 of file exodusII_io_helper.h.

Referenced by get_char_star_star(), and NamesData().

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

Definition at line 1226 of file exodusII_io_helper.h.

Referenced by get_char_star(), and push_back_entry().


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