Jpp  17.2.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static 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 Types

enum  { UUID_t = 0 }
 

Public Member Functions

 JComment ()
 Default constructor. More...
 
JCommentupdate (const JUUID &uuid)
 Update this comment with given UUID. More...
 
JCommentupdate ()
 Update this comment with random UUID. More...
 
JCommentadd (const std::string &comment)
 Add comment. More...
 
JCommentadd (const JComment_t &comment)
 Add comment block. More...
 
bool hasUUID () const
 Check if this comment has UUID. More...
 
JUUID getUUID () const
 Get UUID. More...
 

Static Public Member Functions

static bool is_special (const std::string &buffer)
 Check if given string is special. More...
 

Static Public Attributes

static const char START_COMMENT = '#'
 start comment More...
 
static const char CLOSE_COMMENT = '\n'
 close comment More...
 
static const char START_SPECIAL = '$'
 start special comment More...
 
static const char CLOSE_SPECIAL = '$'
 close special comment More...
 
static const char QUOTE = '"'
 quote 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 text between the quotes JComment::QUOTE is considered as one block which may cross newlines, etc.
The comments are appended.

Definition at line 41 of file JComment.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
UUID_t 

index of UUID

Definition at line 44 of file JComment.hh.

44  {
45  UUID_t = 0 //!< index of UUID
46  };
index of UUID
Definition: JComment.hh:45

Constructor & Destructor Documentation

JEEP::JComment::JComment ( )
inline

Default constructor.

Definition at line 58 of file JComment.hh.

59  {}

Member Function Documentation

JComment& JEEP::JComment::update ( const JUUID uuid)
inline

Update this comment with given UUID.

Parameters
uuidUUID
Returns
this comment

Definition at line 68 of file JComment.hh.

69  {
70  if (!this->hasUUID()) {
71  if ((int) this->size() <= UUID_t)
72  this->resize(UUID_t + 1);
73  else
74  this->insert(this->begin() + UUID_t, value_type());
75  }
76 
77  (*this)[UUID_t] = MAKE_STRING(START_SPECIAL << uuid << CLOSE_SPECIAL);
78 
79  return *this;
80  }
index of UUID
Definition: JComment.hh:45
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
bool hasUUID() const
Check if this comment has UUID.
Definition: JComment.hh:129
static const char START_SPECIAL
start special comment
Definition: JComment.hh:50
static const char CLOSE_SPECIAL
close special comment
Definition: JComment.hh:51
JComment& JEEP::JComment::update ( )
inline

Update this comment with random UUID.

Returns
this comment

Definition at line 88 of file JComment.hh.

89  {
90  return this->update(JUUID::rndm());
91  }
static const JUUID & rndm()
Generate random UUID.
Definition: JUUID.hh:67
JComment & update()
Update this comment with random UUID.
Definition: JComment.hh:88
JComment& JEEP::JComment::add ( const std::string &  comment)
inline

Add comment.

Parameters
commentcomment
Returns
this comment

Definition at line 100 of file JComment.hh.

101  {
102  this->push_back(comment);
103 
104  return this->update();
105  }
JComment & update()
Update this comment with random UUID.
Definition: JComment.hh:88
JComment& JEEP::JComment::add ( const JComment_t comment)
inline

Add comment block.

Parameters
commentcomment block
Returns
this comment

Definition at line 114 of file JComment.hh.

115  {
116  for (const_iterator i = comment.begin(); i != comment.end(); ++i) {
117  this->push_back(*i);
118  }
119 
120  return this->update();
121  }
JComment & update()
Update this comment with random UUID.
Definition: JComment.hh:88
bool JEEP::JComment::hasUUID ( ) const
inline

Check if this comment has UUID.

Returns
true if UUID present; else false

Definition at line 129 of file JComment.hh.

130  {
131  return (UUID_t < (int) this->size() && is_special((*this)[UUID_t]));
132  }
index of UUID
Definition: JComment.hh:45
static bool is_special(const std::string &buffer)
Check if given string is special.
Definition: JComment.hh:223
JUUID JEEP::JComment::getUUID ( ) const
inline

Get UUID.

Returns
UUID

Definition at line 140 of file JComment.hh.

141  {
142  if (this->hasUUID()) {
143 
144  const std::string& buffer = (*this)[UUID_t];
145 
146  return JUUID::valueOf(buffer.substr(1, buffer.size() - 2));
147 
148  } else {
149 
150  THROW(JNoValue, "No UUID in comment.");
151  }
152  }
index of UUID
Definition: JComment.hh:45
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
bool hasUUID() const
Check if this comment has UUID.
Definition: JComment.hh:129
static JUUID valueOf(const std::string &buffer)
Extract UUID.
Definition: JUUID.hh:113
static bool JEEP::JComment::is_special ( const std::string &  buffer)
inlinestatic

Check if given string is special.

Parameters
bufferinput string
Returns
true if special; else false

Definition at line 223 of file JComment.hh.

224  {
225  const int N = buffer.size();
226 
227  return (N > 2 &&
228  buffer[0] == START_SPECIAL &&
229  buffer[N-1] == CLOSE_SPECIAL);
230  }
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
static const char START_SPECIAL
start special comment
Definition: JComment.hh:50
static const char CLOSE_SPECIAL
close special comment
Definition: JComment.hh:51

Friends And Related Function Documentation

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

Read comment from input.

Parameters
ininput stream
commentcomment
Returns
input stream

Definition at line 162 of file JComment.hh.

163  {
164  using namespace std;
165 
166  while (in.peek() == (int) START_COMMENT) {
167 
168  in.get();
169 
170  if (in.peek() == (int) ' ') {
171  in.get();
172  }
173 
174  int c;
175  string buffer;
176 
177  while ((c = in.get()) != EOF && c != (int) CLOSE_COMMENT) {
178 
179  buffer.push_back((char) c);
180 
181  if (c == (int) QUOTE) {
182 
183  while ((c = in.get()) != EOF && c != (int) QUOTE) {
184  buffer.push_back((char) c);
185  }
186 
187  buffer.push_back(QUOTE);
188  }
189  }
190 
191  comment.push_back(buffer);
192  }
193 
194  return in;
195  }
static const char START_COMMENT
start comment
Definition: JComment.hh:48
static const char CLOSE_COMMENT
close comment
Definition: JComment.hh:49
static const char QUOTE
quote
Definition: JComment.hh:52
$WORKDIR ev_configure_domsimulator txt echo process $DOM_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DOM_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
std::ostream& operator<< ( std::ostream &  out,
const JComment comment 
)
friend

Write comment to output.

Parameters
outoutput stream
commentcomment
Returns
output stream

Definition at line 205 of file JComment.hh.

206  {
207  using namespace std;
208 
209  for (JComment::const_iterator i = comment.begin(); i != comment.end(); ++i) {
210  out << START_COMMENT << ' ' << *i << CLOSE_COMMENT;
211  }
212 
213  return out << flush;
214  }
static const char START_COMMENT
start comment
Definition: JComment.hh:48
static const char CLOSE_COMMENT
close comment
Definition: JComment.hh:49

Member Data Documentation

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

start comment

Definition at line 48 of file JComment.hh.

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

close comment

Definition at line 49 of file JComment.hh.

const char JEEP::JComment::START_SPECIAL = '$'
static

start special comment

Definition at line 50 of file JComment.hh.

const char JEEP::JComment::CLOSE_SPECIAL = '$'
static

close special comment

Definition at line 51 of file JComment.hh.

const char JEEP::JComment::QUOTE = '"'
static

quote

Definition at line 52 of file JComment.hh.


The documentation for this struct was generated from the following file: