$extrastylesheet
libMesh::ExodusII_IO_Helper::NamesData Class Reference

#include <exodusII_io_helper.h>

List of all members.

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

References data_table, and data_table_pointers.

                                                                             :
  data_table(n_strings),
  data_table_pointers(n_strings),
  counter(0),
  table_size(n_strings)
{
  for (size_t i=0; i<n_strings; ++i)
    {
      data_table[i].resize(string_length + 1);

      // NULL-terminate these strings, just to be safe.
      data_table[i][0] = '\0';

      // Set pointer into the data_table
      data_table_pointers[i] = &(data_table[i][0]);
    }
}

Member Function Documentation

Provide access to the i'th underlying char*

Definition at line 2182 of file exodusII_io_helper.C.

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

{
  if (static_cast<unsigned>(i) >= table_size)
    libmesh_error_msg("Requested char* " << i << " but only have " << table_size << "!");

  else
    return &(data_table[i][0]);
}
void libMesh::ExodusII_IO_Helper::NamesData::push_back_entry ( const std::string &  name)

Adds another name to the current data table.

Definition at line 2159 of file exodusII_io_helper.C.

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

{
  libmesh_assert_less (counter, table_size);

  // 1.) Copy the C++ string into the vector<char>...
  size_t num_copied = name.copy(&data_table[counter][0], data_table[counter].size()-1);

  // 2.) ...And null-terminate it.
  data_table[counter][num_copied] = '\0';

  // Go to next row
  ++counter;
}

Member Data Documentation

Definition at line 1033 of file exodusII_io_helper.h.

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

Definition at line 1030 of file exodusII_io_helper.h.

Referenced by NamesData().

Definition at line 1031 of file exodusII_io_helper.h.

Referenced by NamesData().


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