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

References data_table, and data_table_pointers.

2134  :
2135  data_table(n_strings),
2136  data_table_pointers(n_strings),
2137  counter(0),
2138  table_size(n_strings)
2139 {
2140  for (size_t i=0; i<n_strings; ++i)
2141  {
2142  data_table[i].resize(string_length + 1);
2143 
2144  // NULL-terminate these strings, just to be safe.
2145  data_table[i][0] = '\0';
2146 
2147  // Set pointer into the data_table
2148  data_table_pointers[i] = &(data_table[i][0]);
2149  }
2150 }

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

References libMesh::err.

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

2178 {
2179  if (static_cast<unsigned>(i) >= table_size)
2180  {
2181  libMesh::err << "Requested char* " << i << " but only have " << table_size << "!" << std::endl;
2182  libmesh_error();
2183  }
2184  else
2185  return &(data_table[i][0]);
2186 }
char ** libMesh::ExodusII_IO_Helper::NamesData::get_char_star_star ( )

Provide access to the underlying C data table

Definition at line 2170 of file exodusII_io_helper.C.

Referenced by libMesh::ExodusII_IO_Helper::read_var_names_impl(), libMesh::ExodusII_IO_Helper::write_elements(), and libMesh::ExodusII_IO_Helper::write_information_records().

2171 {
2172  return &data_table_pointers[0];
2173 }
void libMesh::ExodusII_IO_Helper::NamesData::push_back_entry ( const std::string &  name)

Adds another name to the current data table.

Definition at line 2154 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().

2155 {
2156  libmesh_assert_less (counter, table_size);
2157 
2158  // 1.) Copy the C++ string into the vector<char>...
2159  size_t num_copied = name.copy(&data_table[counter][0], data_table[counter].size()-1);
2160 
2161  // 2.) ...And null-terminate it.
2162  data_table[counter][num_copied] = '\0';
2163 
2164  // Go to next row
2165  ++counter;
2166 }

Member Data Documentation

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

Definition at line 1025 of file exodusII_io_helper.h.

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

Definition at line 1022 of file exodusII_io_helper.h.

Referenced by NamesData().

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

Definition at line 1023 of file exodusII_io_helper.h.

Referenced by NamesData().

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

Definition at line 1026 of file exodusII_io_helper.h.


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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:19 UTC

Hosted By:
SourceForge.net Logo