CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
cmdline::OneShotIStream Class Reference

#include <CmdLine.h>

Public Member Functions

bool isValid () const
 
 OneShotIStream ()
 
 OneShotIStream (const std::string &s)
 
 operator void * () const
 
template<typename T >
bool operator>> (T &obj)
 

Private Attributes

bool readout_
 
std::string str_
 
bool valid_
 

Detailed Description

Definition at line 152 of file CmdLine.h.

Constructor & Destructor Documentation

◆ OneShotIStream() [1/2]

cmdline::OneShotIStream::OneShotIStream ( )
inline

Definition at line 154 of file CmdLine.h.

154 : valid_(false), readout_(false) {}

◆ OneShotIStream() [2/2]

cmdline::OneShotIStream::OneShotIStream ( const std::string &  s)
inline

Definition at line 156 of file CmdLine.h.

Member Function Documentation

◆ isValid()

bool cmdline::OneShotIStream::isValid ( void  ) const
inline

◆ operator void *()

cmdline::OneShotIStream::operator void * ( ) const
inline

Definition at line 158 of file CmdLine.h.

References readout_, and valid_.

158 { return valid_ && !readout_ ? (void*)this : (void*)nullptr; }

◆ operator>>()

template<typename T >
bool cmdline::OneShotIStream::operator>> ( T obj)
inline

Definition at line 161 of file CmdLine.h.

References getGTfromDQMFile::obj, cmdline::OneShotExtract(), readout_, str_, and valid_.

161  {
162  if (readout_)
163  throw CmdLineError() << "can't reuse command line argument \"" << str_ << '"';
164  readout_ = true;
165  if (valid_) {
166  std::istringstream is(str_);
167  OneShotExtract(is, obj);
168  if (is.bad() || is.fail())
169  throw CmdLineError() << "failed to parse command line argument \"" << str_ << '"'
170 #ifdef __GNUC__
171  << ", " << demangle(obj) << " expected"
172 #endif
173  ;
174  if (is.peek() != EOF)
175  throw CmdLineError() << "extra characters in command line argument \"" << str_ << '"'
176 #ifdef __GNUC__
177  << ", " << demangle(obj) << " expected"
178 #endif
179  ;
180  }
181  return valid_;
182  }
std::string str_
Definition: CmdLine.h:187
void OneShotExtract(std::istringstream &is, T &obj)
Definition: CmdLine.h:142

Member Data Documentation

◆ readout_

bool cmdline::OneShotIStream::readout_
private

Definition at line 189 of file CmdLine.h.

Referenced by operator void *(), and operator>>().

◆ str_

std::string cmdline::OneShotIStream::str_
private

Definition at line 187 of file CmdLine.h.

Referenced by operator>>().

◆ valid_

bool cmdline::OneShotIStream::valid_
private

Definition at line 188 of file CmdLine.h.

Referenced by isValid(), operator void *(), and operator>>().