Classes | Functions
stan::io Namespace Reference

Classes

class  array_var_context
 
class  chained_var_context
 
class  cmd_line
 
class  dump
 
class  dump_reader
 
class  empty_var_context
 
struct  preproc_event
 
class  program_reader
 
class  random_var_context
 
class  reader
 
struct  stan_csv
 
struct  stan_csv_adaptation
 
struct  stan_csv_metadata
 
class  stan_csv_reader
 
struct  stan_csv_timing
 
class  var_context
 
class  writer
 

Functions

template<typename T >
T product (std::vector< T > dims)
 
void pad_help_option (std::ostream *o, const std::string &option="", unsigned int width=20)
 
void print_help_helper (std::ostream *o, const std::string &key_val, const std::string &msg, const std::string &note="")
 
void print_help_option (std::ostream *o, const std::string &key, const std::string &value_type, const std::string &msg, const std::string &note="")
 
template<>
bool cmd_line::bare< std::string > (size_t n, std::string &x) const
 
template<>
bool cmd_line::val< std::string > (const std::string &key, std::string &x) const
 
std::string read_line (std::istream &in)
 
bool starts_with (const std::string &p, const std::string &s)
 
std::string utc_time_string ()
 
template<typename B >
void validate_zero_buf (const B &buf)
 

Function Documentation

template<>
bool stan::io::cmd_line::bare< std::string > ( size_t  n,
std::string &  x 
) const
inline

Definition at line 275 of file cmd_line.hpp.

References stan::io::cmd_line::bare_, getGoodRuns4SAM::n, and submit_syst::x.

275  {
276  if (n >= bare_.size())
277  return false;
278  x = bare_[n];
279  return true;
280  }
template<>
bool stan::io::cmd_line::val< std::string > ( const std::string &  key,
std::string &  x 
) const
inline

Definition at line 285 of file cmd_line.hpp.

References stan::io::cmd_line::has_key(), stan::io::cmd_line::key_val_, and submit_syst::x.

286  {
287  if (!has_key(key))
288  return false;
289  x = key_val_.find(key)->second;
290  return true;
291  }
void stan::io::pad_help_option ( std::ostream *  o,
const std::string &  option = "",
unsigned int  width = 20 
)
inline

Print help option with padding.

Print 2 spaces, the specified help option, then pad to the specified width with spaces. If there is not room for at least 2 padding spaces, start a new line and pad out to width.

Parameters
optionOption to print (default to empty string).
widthWidth of option (defaults to 20).
oOutput stream ptr, default to null

Definition at line 27 of file cmd_line.hpp.

References allTimeWatchdog::endl, and MECModelEnuComparisons::i.

Referenced by print_help_helper(), and TEST().

29  {
30  if (!o) return;
31  *o << " " << option;
32  int padding = width - option.size();
33  if (padding < 2) {
34  *o << std::endl;
35  padding = width + 2; // 2 is
36  }
37  for (int i = 0; i < padding; ++i)
38  *o << ' ';
39  }
void stan::io::print_help_helper ( std::ostream *  o,
const std::string &  key_val,
const std::string &  msg,
const std::string &  note = "" 
)
inline

Prints single print option to output ptr if non-null.

Parameters
o
key_val
msg
note

Definition at line 49 of file cmd_line.hpp.

References allTimeWatchdog::endl, and pad_help_option().

Referenced by print_help_option().

52  {
53  if (!o) return;
54  pad_help_option(o, key_val);
55  *o << msg
56  << std::endl;
57  if (note.size() > 0) {
58  pad_help_option(o, "");
59  *o << " (" << note << ")"
60  << std::endl;
61  }
62  *o << std::endl;
63  }
void pad_help_option(std::ostream *o, const std::string &option="", unsigned int width=20)
Definition: cmd_line.hpp:27
void stan::io::print_help_option ( std::ostream *  o,
const std::string &  key,
const std::string &  value_type,
const std::string &  msg,
const std::string &  note = "" 
)
inline

Prints single print option to output ptr if non-null.

Parameters
o
key
value_type
msg
note

Definition at line 74 of file cmd_line.hpp.

References findDuplicateFiles::key, lem_server::msg, print_help_helper(), and ss.

Referenced by print_stanc_help().

78  {
79  std::stringstream ss;
80  ss << "--" << key;
81  if (value_type.size() > 0)
82  ss << "=<" << value_type << ">";
83  print_help_helper(o, ss.str(), msg, note);
84  }
Float_t ss
Definition: plot.C:24
void print_help_helper(std::ostream *o, const std::string &key_val, const std::string &msg, const std::string &note="")
Definition: cmd_line.hpp:49
template<typename T >
T stan::io::product ( std::vector< T dims)

Definition at line 17 of file array_var_context.hpp.

References MECModelEnuComparisons::i, T, and submit_syst::y.

Referenced by stan::io::array_var_context::add_i(), stan::io::array_var_context::add_r(), art::Wrapper< T >::Class_Version(), art::Ptr< L >::Class_Version(), mcchk::NeutrinoAna::DotProduct(), novaddt::ChannelMapService::fillMapFromEvent(), art::DataViewImpl::fillView_(), novaddt::SortByDCM::filter(), novaddt::SortByPlane::filter(), novaddt::SortByTDC::filter(), novaddt::HighSortByTDC::filter(), novaddt::TDSlice::filter(), novaddt::Clusterer::filter(), novaddt::RemoveNoise::filter(), novaddt::RestrictHitsByPlane::filter(), novaddt::SpaceSlice::filter(), novaddt::RemoveOneDSlices::filter(), novaddt::RemoveSpatialNoise::filter(), novaddt::HighADCFilter::filter(), novaddt::DCMSlice::filter(), novaddt::TimeDCMSlice::filter(), novaddt::TimeSlice::filter(), novaddt::DBSlicer::filter(), novaddt::SlicePrescale::filter(), novaddt::FEBFlashFilter::filter(), novaddt::ClusterConvert::filter(), novaddt::Multiplet::filter(), novaddt::Multiplet::findslices(), novaddt::ChannelMapService::getCounterMax(), art::EDProduct::insertIfSampledProduct(), novaddt::Multiplet::isHitCloseToHit(), art::FileDumperOutput::printPrincipal(), stan::math::prod(), novaddt::SortByView::produce(), art::Results::put(), art::Run::put(), art::Event::put(), art::SubRun::put(), art::Run::put_(), art::SubRun::put_(), art::rangeSetFor(), and stan::io::array_var_context::validate().

17  {
18  T y = 1;
19  for (size_t i = 0; i < dims.size(); ++i)
20  y *= dims[i];
21  return y;
22  }
double T
Definition: Xdiff_gwt.C:5
std::string stan::io::read_line ( std::istream &  in)
inline

Returns the next line read from the specified stream, or the empty string if the stream is empty.

The input stream is read character by character and not buffered, though the use cases are only for small files of code, so this probably isn't a big deal.

Parameters
ininput stream
Returns
next line from stream or empty string if empty

Definition at line 22 of file read_line.hpp.

References make_syst_table_plots::c, and ss.

Referenced by stan::io::program_reader::read(), and TEST().

22  {
23  std::stringstream ss;
24  while (true) {
25  int c = in.get();
26  if (c == std::char_traits<char>::eof())
27  return ss.str();
28  ss << static_cast<char>(c);
29  if (c == '\n')
30  return ss.str();
31  }
32  }
Float_t ss
Definition: plot.C:24
ifstream in
Definition: comparison.C:7
bool stan::io::starts_with ( const std::string &  p,
const std::string &  s 
)
inline

Return true if the specified string starts with the specified prefix.

Parameters
pprefix
sstring to test
Returns
true if s has p as a prefix

Definition at line 17 of file starts_with.hpp.

Referenced by expect_starts(), stan::lang::validate_assgn::operator()(), and stan::io::program_reader::read().

18  {
19  return s.size() >= p.size() && s.substr(0, p.size()) == p;
20  }
const char * p
Definition: xmltok.h:285
const XML_Char * s
Definition: expat.h:262
std::string stan::io::utc_time_string ( )

Return the current coordinated universal time (UTC) as a string.

Output is of the form "Fri Feb 24 21:15:36 2012"

Returns
String representation of current UTC.

Definition at line 18 of file util.hpp.

Referenced by TEST().

18  {
19  // FIXME: use std::strftime
20 
21  // original with asctime
22  // std::time_t rawtime = time(0);
23  // std::tm *time = gmtime(&rawtime);
24  // return std::string(asctime(time));
25 
26  // new with strfitime
27  time_t rawtime;
28  std::time(&rawtime);
29 
30  char cbuf[80];
31  std::strftime(cbuf, 80, "%a %b %d %Y %H:%M:%S",
32  std::localtime(&rawtime));
33 
34  return std::string(cbuf);
35  }
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
template<typename B >
void stan::io::validate_zero_buf ( const B &  buf)

Throw an bad-cast exception if the specified buffer contains a digit other than 0 before an e or E. The buffer argument must implement size_t size() method and char operator[](size_t).

Template Parameters
BCharacter buffer type
Exceptions
<code>boost::bad_lexical_cast</code>if the buffer contains non-zero characters before an exponentiation symbol.

Definition at line 21 of file validate_zero_buf.hpp.

References MECModelEnuComparisons::i.

Referenced by stan::json::parser< Handler, Validate_UTF_8 >::parse_number(), stan::io::dump_reader::scan_double(), and TEST().

21  {
22  for (size_t i = 0; i < buf.size(); ++i) {
23  if (buf[i] == 'e' || buf[i] == 'E')
24  return;
25  if (buf[i] >= '1' && buf[i] <= '9')
26  boost::conversion::detail::throw_bad_cast<std::string, double>();
27  }
28  }
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154