libfoedus-core
FOEDUS Core Library
foedus::assorted::Top Struct Reference

Write only first few bytes to stream. More...

Detailed Description

Write only first few bytes to stream.

Use it as follows.

std::cout << Top("abcdefghijklmn", 3) << ...
// outputs "abc..."

Definition at line 162 of file assorted_func.hpp.

#include <assorted_func.hpp>

Public Member Functions

 Top (const char *data, uint32_t data_len, uint32_t max_bytes=8)
 

Public Attributes

const char * data_
 
uint32_t data_len_
 
uint32_t max_bytes_
 

Friends

std::ostream & operator<< (std::ostream &o, const Top &v)
 

Constructor & Destructor Documentation

foedus::assorted::Top::Top ( const char *  data,
uint32_t  data_len,
uint32_t  max_bytes = 8 
)
inline

Definition at line 163 of file assorted_func.hpp.

164  : data_(data), data_len_(data_len), max_bytes_(max_bytes) {}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const Top v 
)
friend

Definition at line 138 of file assorted_func.cpp.

138  {
139  for (uint32_t i = 0; i < std::min<uint32_t>(v.data_len_, v.max_bytes_); ++i) {
140  o << i << ":" << static_cast<int>(v.data_[i]);
141  if (i != 0) {
142  o << ", ";
143  }
144  }
145  if (v.data_len_ > v.max_bytes_) {
146  o << "...";
147  }
148  return o;
149 }

Member Data Documentation

const char* foedus::assorted::Top::data_

Definition at line 166 of file assorted_func.hpp.

Referenced by foedus::assorted::operator<<().

uint32_t foedus::assorted::Top::data_len_

Definition at line 167 of file assorted_func.hpp.

Referenced by foedus::assorted::operator<<().

uint32_t foedus::assorted::Top::max_bytes_

Definition at line 168 of file assorted_func.hpp.

Referenced by foedus::assorted::operator<<().


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