ewmscp  ..
Functions
options::escapedIO Namespace Reference

Functions

std::istream & operator>> (std::istream &aStream, const char *&aCstring)
 
std::ostream & operator<< (std::ostream &aStream, const std::string &aString)
 
std::istream & operator>> (std::istream &aStream, std::string &aString)
 
std::ostream & operator<< (std::ostream &aStream, const std::chrono::system_clock::time_point &aTime)
 
std::istream & operator>> (std::istream &aStream, std::chrono::system_clock::time_point &aTime)
 
template<class Rep , class Period >
std::ostream & operator<< (std::ostream &aStream, const std::chrono::duration< Rep, Period > &aDuration)
 
template<class Rep , class Period >
std::istream & operator>> (std::istream &aStream, std::chrono::duration< Rep, Period > &aDuration)
 

Function Documentation

◆ operator<<() [1/3]

template<class Rep , class Period >
std::ostream& options::escapedIO::operator<< ( std::ostream &  aStream,
const std::chrono::duration< Rep, Period > &  aDuration 
)

Definition at line 46 of file OptionsChrono.h.

46  {
47  auto flags(aStream.flags());
48  aStream << std::fixed;
49  aStream << aDuration.count();
50  aStream.flags(flags);
51  return aStream;
52  }

◆ operator<<() [2/3]

std::ostream & options::escapedIO::operator<< ( std::ostream &  aStream,
const std::chrono::system_clock::time_point &  aTime 
)

Definition at line 465 of file OptionsChrono.cpp.

465  {
466  single<std::chrono::system_clock::time_point>::fDefaultValuePrinter(aStream, aTime);
467  return aStream;
468  }

◆ operator<<() [3/3]

std::ostream & options::escapedIO::operator<< ( std::ostream &  aStream,
const std::string &  aString 
)

Definition at line 447 of file Options.cpp.

447  {
448  parser::fPrintEscapedString(aStream, aString);
449  return aStream;
450  }

References options::parser::fPrintEscapedString().

Here is the call graph for this function:

◆ operator>>() [1/4]

std::istream & options::escapedIO::operator>> ( std::istream &  aStream,
const char *&  aCstring 
)

Definition at line 435 of file Options.cpp.

435  {
436  auto buffer = new std::string;
437  aStream >> *buffer;
438  if (aStream.fail()) {
439  delete buffer;
440  } else { // leak a string...
441  aCstring = buffer->c_str();
442  }
443  return aStream;
444  }

◆ operator>>() [2/4]

template<class Rep , class Period >
std::istream& options::escapedIO::operator>> ( std::istream &  aStream,
std::chrono::duration< Rep, Period > &  aDuration 
)

Definition at line 53 of file OptionsChrono.h.

53  {
54  std::string buf;
55  aStream >> buf;
56  if (!aStream.fail()) {
57  internal::parseDurationString(aDuration, buf);
58  }
59  return aStream;
60  };

References options::internal::parseDurationString().

Here is the call graph for this function:

◆ operator>>() [3/4]

std::istream & options::escapedIO::operator>> ( std::istream &  aStream,
std::chrono::system_clock::time_point &  aTime 
)

Definition at line 469 of file OptionsChrono.cpp.

469  {
470  std::string buf;
471  aStream >> buf;
472  if (!aStream.fail()) {
473  aTime = internal::fParseTimePointString(buf);
474  }
475  return aStream;
476  }

References options::internal::fParseTimePointString().

Here is the call graph for this function:

◆ operator>>() [4/4]

std::istream & options::escapedIO::operator>> ( std::istream &  aStream,
std::string &  aString 
)

Definition at line 451 of file Options.cpp.

451  {
452  std::istream::sentry s(aStream);
453  if (s) {
454  aString.clear();
455  auto delimiter = aStream.peek();
456  if (delimiter == '"' || delimiter == '\'') { // string is enclosed in a pair of delimiters
457  aStream.get();
458  } else {
459  delimiter = '\0';
460  }
461  while (! aStream.eof()) {
462  auto c = aStream.peek();
463  if (c == '\n' || aStream.eof()) {
464  break;
465  }
466  aStream.get();
467  if (c == '\\') {
468  c = aStream.get();
469  switch (c) {
470  case 'a':
471  aString.push_back('\a');
472  break;
473  case 'b':
474  aString.push_back('\b');
475  break;
476  case 'f':
477  aString.push_back('\f');
478  break;
479  case 'n':
480  aString.push_back('\n');
481  break;
482  case 'r':
483  aString.push_back('\r');
484  break;
485  case 't':
486  aString.push_back('\t');
487  break;
488  case 'v':
489  aString.push_back('\v');
490  break;
491  default:
492  if (c >= '0' && c <= '7') {
493  char ch = 0;
494  for (int i = 0; i < 3 && c >= '0' && c <= '7'; i++) {
495  ch = (ch << 3) | ((c - '0') & 0x7);
496  c = aStream.get();
497  }
498  aString.push_back(ch);
499  } else {
500  aString.push_back(c);
501  }
502  break;
503  }
504  } else if (c == delimiter) {
505  break;
506  } else {
507  aString.push_back(c);
508  }
509  }
510  }
511  auto eof = aStream.eof();
512  aStream.clear();
513  if (eof) {
514  aStream.setstate(std::ios_base::eofbit);
515  };
516  return aStream;
517  }
options::internal::fParseTimePointString
std::chrono::system_clock::time_point fParseTimePointString(const std::string &aString)
Definition: OptionsChrono.cpp:183
options::internal::parseDurationString
void parseDurationString(std::chrono::duration< Rep, Period > &aDuration, const std::string &aString, int *aMonths=nullptr, int *aYears=nullptr)
parse a string into a std::chrono::duration, if given set the years and months separately
Definition: OptionsChrono.h:22