libMesh
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
libMesh::Parallel::Packing< std::basic_string< T > > Class Template Reference

Public Types

typedef T buffer_type
 

Static Public Member Functions

static unsigned int get_string_len (typename std::vector< T >::const_iterator in)
 
static unsigned int packed_size (typename std::vector< T >::const_iterator in)
 
static unsigned int packable_size (const std::basic_string< T > &s, const void *)
 
template<typename Iter >
static void pack (const std::basic_string< T > &b, Iter data_out, const void *)
 
static std::basic_string< T > unpack (typename std::vector< T >::const_iterator in, void *)
 

Static Public Attributes

static const unsigned int size_bytes = 4
 

Detailed Description

template<typename T>
class libMesh::Parallel::Packing< std::basic_string< T > >

Definition at line 27 of file packed_range_test.C.

Member Typedef Documentation

template<typename T >
typedef T libMesh::Parallel::Packing< std::basic_string< T > >::buffer_type

Definition at line 32 of file packed_range_test.C.

Member Function Documentation

template<typename T >
static unsigned int libMesh::Parallel::Packing< std::basic_string< T > >::get_string_len ( typename std::vector< T >::const_iterator  in)
static

Definition at line 35 of file packed_range_test.C.

36  {
37  unsigned int string_len = reinterpret_cast<const unsigned char &>(in[size_bytes-1]);
38  for (signed int i=size_bytes-2; i >= 0; --i)
39  {
40  string_len *= 256;
41  string_len += reinterpret_cast<const unsigned char &>(in[i]);
42  }
43  return string_len;
44  }
template<typename T >
template<typename Iter >
static void libMesh::Parallel::Packing< std::basic_string< T > >::pack ( const std::basic_string< T > &  b,
Iter  data_out,
const void *   
)
static

Definition at line 62 of file packed_range_test.C.

64  {
65  unsigned int string_len = b.size();
66  for (unsigned int i=0; i != size_bytes; ++i)
67  {
68  *data_out++ = (string_len % 256);
69  string_len /= 256;
70  }
71  std::copy(b.begin(), b.end(), data_out);
72  }
template<typename T >
static unsigned int libMesh::Parallel::Packing< std::basic_string< T > >::packable_size ( const std::basic_string< T > &  s,
const void *   
)
static

Definition at line 54 of file packed_range_test.C.

56  {
57  return s.size() + size_bytes;
58  }
template<typename T >
static unsigned int libMesh::Parallel::Packing< std::basic_string< T > >::packed_size ( typename std::vector< T >::const_iterator  in)
static

Definition at line 48 of file packed_range_test.C.

References libMesh::Parallel::Packing< T >::packable_size().

49  {
50  return get_string_len(in) + size_bytes;
51  }
static unsigned int get_string_len(typename std::vector< T >::const_iterator in)
template<typename T >
static std::basic_string<T> libMesh::Parallel::Packing< std::basic_string< T > >::unpack ( typename std::vector< T >::const_iterator  in,
void *   
)
static

Definition at line 75 of file packed_range_test.C.

76  {
77  unsigned int string_len = get_string_len(in);
78 
79  std::ostringstream oss;
80  for (unsigned int i = 0; i < string_len; ++i)
81  oss << reinterpret_cast<const unsigned char &>(in[i+size_bytes]);
82 
83  in += size_bytes + string_len;
84 
85  // std::cout << oss.str() << std::endl;
86  return std::string(oss.str());
87  }
static unsigned int get_string_len(typename std::vector< T >::const_iterator in)

Member Data Documentation

template<typename T >
const unsigned int libMesh::Parallel::Packing< std::basic_string< T > >::size_bytes = 4
static

Definition at line 30 of file packed_range_test.C.


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