Jpp
Public Member Functions | Static Public Attributes | Friends | List of all members
JEEP::JComment Struct Reference

Auxiliary class for comment. More...

#include <JComment.hh>

Inheritance diagram for JEEP::JComment:
std::vector< std::string >

Public Member Functions

 JComment ()
 Default constructor. More...
 
JCommentadd (const std::string &comment)
 Add comment. More...
 
JCommentadd (const JComment &comment)
 Add comment. More...
 

Static Public Attributes

static const char START_COMMENT = '#'
 start of comment More...
 
static const char CLOSE_COMMENT = '\n'
 close of comment More...
 

Friends

std::istream & operator>> (std::istream &in, JComment &comment)
 Read comment from input. More...
 
std::ostream & operator<< (std::ostream &out, const JComment &comment)
 Write comment to output. More...
 

Detailed Description

Auxiliary class for comment.

A comment starts with a

JComment::START_COMMENT

and ends with a

JComment::CLOSE_COMMENT

. The comments are appended.

Definition at line 34 of file JComment.hh.

Constructor & Destructor Documentation

◆ JComment()

JEEP::JComment::JComment ( )
inline

Default constructor.

Definition at line 45 of file JComment.hh.

46  {}

Member Function Documentation

◆ add() [1/2]

JComment& JEEP::JComment::add ( const std::string &  comment)
inline

Add comment.

Parameters
commentcomment
Returns
this comment

Definition at line 55 of file JComment.hh.

56  {
57  this->push_back(comment);
58 
59  return *this;
60  }

◆ add() [2/2]

JComment& JEEP::JComment::add ( const JComment comment)
inline

Add comment.

Parameters
commentcomment
Returns
this comment

Definition at line 69 of file JComment.hh.

70  {
71  for (const_iterator i = comment.begin(); i != comment.end(); ++i) {
72  this->push_back(*i);
73  }
74 
75  return *this;
76  }

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  in,
JComment comment 
)
friend

Read comment from input.

Parameters
ininput stream
commentcomment
Returns
input stream

Definition at line 86 of file JComment.hh.

87  {
88  using namespace std;
89 
90  for (string buffer; in.peek() == (int) START_COMMENT; ) {
91 
92  in.get();
93 
94  if (in.peek() == (int) ' ') {
95  in.get();
96  }
97 
98  getline(in, buffer, CLOSE_COMMENT);
99 
100  comment.push_back(buffer);
101  }
102 
103  return in;
104  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JComment comment 
)
friend

Write comment to output.

Parameters
outoutput stream
commentcomment
Returns
output stream

Definition at line 114 of file JComment.hh.

115  {
116  using namespace std;
117 
118  for (JComment::const_iterator i = comment.begin(); i != comment.end(); ++i) {
119  out << START_COMMENT << ' ' << *i << CLOSE_COMMENT;
120  }
121 
122  return out << flush;
123  }

Member Data Documentation

◆ START_COMMENT

const char JEEP::JComment::START_COMMENT = '#'
static

start of comment

Definition at line 38 of file JComment.hh.

◆ CLOSE_COMMENT

const char JEEP::JComment::CLOSE_COMMENT = '\n'
static

close of comment

Definition at line 39 of file JComment.hh.


The documentation for this struct was generated from the following file:
JEEP::JComment::START_COMMENT
static const char START_COMMENT
start of comment
Definition: JComment.hh:38
JEEP::JComment::CLOSE_COMMENT
static const char CLOSE_COMMENT
close of comment
Definition: JComment.hh:39
std
Definition: jaanetDictionary.h:36
JLANG::getline
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:468