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 150 of file CmdLine.h.

Constructor & Destructor Documentation

cmdline::OneShotIStream::OneShotIStream ( )
inline

Definition at line 153 of file CmdLine.h.

153 : valid_(false), readout_(false) {}
cmdline::OneShotIStream::OneShotIStream ( const std::string &  s)
inline

Definition at line 155 of file CmdLine.h.

156  : str_(s), valid_(true), readout_(false) {}
std::string str_
Definition: CmdLine.h:197

Member Function Documentation

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

Definition at line 158 of file CmdLine.h.

References sistrip::valid_.

159  {
160  return valid_ && !readout_ ? (void*)this : (void*)0;
161  }
template<typename T >
bool cmdline::OneShotIStream::operator>> ( T obj)
inline

Definition at line 164 of file CmdLine.h.

References cmdline::CmdLineError::CmdLineError(), cmdline::OneShotExtract(), and sistrip::valid_.

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

Member Data Documentation

bool cmdline::OneShotIStream::readout_
private

Definition at line 199 of file CmdLine.h.

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

Definition at line 197 of file CmdLine.h.

bool cmdline::OneShotIStream::valid_
private

Definition at line 198 of file CmdLine.h.