Jpp
Public Member Functions | List of all members
JPARSER::JParserTemplateElement< JType_t, has_eq > Class Template Reference

Template class holder for I/O of parser element. More...

#include <JParser.hh>

Public Member Functions

template<>
std::istream & read (std::istream &in)
 Template specialisation of JParserTemplateElement<std::string>::read to read complete line from stream input. More...
 
template<>
std::ostream & write (std::ostream &out) const
 Template specialisation of JParserTemplateElement<std::string>::write to surround text with quotes. More...
 
template<>
std::istream & read (std::istream &in)
 Template specialisation of JParserTemplateElement<TString>::read to read complete line from stream input. More...
 
template<>
std::istream & read (std::istream &in)
 Template specialisation of JParserTemplateElement< std::vector<TString> >::read to read tokens from stream input. More...
 

Detailed Description

template<class JType_t, bool has_eq = JComparisonAvailable<JType_t>::has_eq>
class JPARSER::JParserTemplateElement< JType_t, has_eq >

Template class holder for I/O of parser element.

This class implements the JPARSER::JParserElementInterface interface.

Definition at line 463 of file JParser.hh.

Member Function Documentation

◆ read() [1/3]

template<>
std::istream & JPARSER::JParserTemplateElement< std::string, false >::read ( std::istream &  in)
inline

Template specialisation of JParserTemplateElement<std::string>::read to read complete line from stream input.

Parameters
ininput stream
Returns
input stream

Definition at line 702 of file JParser.hh.

703  {
704  std::getline(in, object);
705 
706  if (fail(in)) {
707  THROW(JParserException, "JParser: error reading parameter " << getName());
708  }
709 
710  if (in.peek() != EOF) {
711  THROW(JParserException, "JParser: pending data after reading parameter " << getName());
712  }
713 
714  setInitialiationStatus(true);
715 
716  return in;
717  }

◆ write()

template<>
std::ostream & JPARSER::JParserTemplateElement< std::string, false >::write ( std::ostream &  out) const
inline

Template specialisation of JParserTemplateElement<std::string>::write to surround text with quotes.

Parameters
outoutput stream
Returns
output stream

Definition at line 727 of file JParser.hh.

728  {
729  return writeObject(out, JLANG::double_quote(object));
730  }

◆ read() [2/3]

template<>
std::istream & JPARSER::JParserTemplateElement< TString, false >::read ( std::istream &  in)
inline

Template specialisation of JParserTemplateElement<TString>::read to read complete line from stream input.

Parameters
ininput stream
Returns
input stream

Definition at line 820 of file JParser.hh.

821  {
822  TStringHelper<>::read(in, object);
823 
824  setInitialiationStatus(true);
825 
826  return in;
827  }

◆ read() [3/3]

template<>
std::istream & JPARSER::JParserTemplateElement< std::vector< TString >, false >::read ( std::istream &  in)
inline

Template specialisation of JParserTemplateElement< std::vector<TString> >::read to read tokens from stream input.

Parameters
ininput stream
Returns
input stream

Definition at line 837 of file JParser.hh.

838  {
839  TStringHelper<>::read(in, object);
840 
841  setInitialiationStatus(true);
842 
843  return in;
844  }

The documentation for this class was generated from the following file:
JLANG::double_quote
std::string double_quote(const std::string &value)
Quote string.
Definition: JLangToolkit.hh:324
JLANG::JParserException
Exception when parsing a value.
Definition: JException.hh:522
THROW
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:669
JEEP::writeObject
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
Definition: JStreamToolkit.hh:42
JPARSER::fail
bool fail(std::istream &in)
Check for stream state.
Definition: JParser.hh:93
JROOT::getName
const char * getName()
Get ROOT name of given data type.
Definition: JRootToolkit.hh:45
JLANG::getline
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:468