Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
JEEP::JTime< JSeparator_t > Struct Template Reference

Auxiliary class for simple time. More...

#include <JTime.hh>

Inheritance diagram for JEEP::JTime< JSeparator_t >:
JLANG::JComparable< JTime< JSeparator_t > >

Public Member Functions

 JTime ()
 Default constructor. More...
 
 JTime (const int hour, const int minute, const int second)
 Constructor. More...
 
 JTime (const std::string &time)
 Constructor. More...
 
bool less (const JTime &time) const
 Less-than method. More...
 

Static Public Member Functions

static JTime min ()
 Minimal time. More...
 
static JTime max ()
 Maximal time. More...
 

Public Attributes

int hour
 hour More...
 
int minute
 minute More...
 
int second
 second More...
 

Static Public Attributes

static const char SEPARATOR = JSeparator_t
 Separation character. More...
 

Friends

std::istream & operator>> (std::istream &in, JTime &object)
 Read time from input stream. More...
 
std::ostream & operator<< (std::ostream &out, const JTime &object)
 Write time to output stream. More...
 

Detailed Description

template<char JSeparator_t>
struct JEEP::JTime< JSeparator_t >

Auxiliary class for simple time.

The corresponding ASCII format is yyyy<separator>mm<separator>dd. where the separator is defined by the template parameter.

Definition at line 30 of file Jeep/JTime.hh.

Constructor & Destructor Documentation

template<char JSeparator_t>
JEEP::JTime< JSeparator_t >::JTime ( )
inline

Default constructor.

Definition at line 42 of file Jeep/JTime.hh.

42  :
43  hour (0),
44  minute(0),
45  second(0)
46  {}
int second
second
Definition: Jeep/JTime.hh:155
int minute
minute
Definition: Jeep/JTime.hh:154
int hour
hour
Definition: Jeep/JTime.hh:153
template<char JSeparator_t>
JEEP::JTime< JSeparator_t >::JTime ( const int  hour,
const int  minute,
const int  second 
)
inline

Constructor.

Parameters
hourhour
minuteminute
secondsecond

Definition at line 56 of file Jeep/JTime.hh.

58  :
59  hour (hour),
60  minute(minute),
61  second(second)
62  {}
int second
second
Definition: Jeep/JTime.hh:155
int minute
minute
Definition: Jeep/JTime.hh:154
int hour
hour
Definition: Jeep/JTime.hh:153
template<char JSeparator_t>
JEEP::JTime< JSeparator_t >::JTime ( const std::string &  time)
inline

Constructor.

Parameters
timetime

Definition at line 70 of file Jeep/JTime.hh.

71  {
72  std::istringstream in(time);
73 
74  in >> *this;
75  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45

Member Function Documentation

template<char JSeparator_t>
static JTime JEEP::JTime< JSeparator_t >::min ( )
inlinestatic

Minimal time.

Definition at line 78 of file Jeep/JTime.hh.

template<char JSeparator_t>
static JTime JEEP::JTime< JSeparator_t >::max ( )
inlinestatic

Maximal time.

Definition at line 79 of file Jeep/JTime.hh.

template<char JSeparator_t>
bool JEEP::JTime< JSeparator_t >::less ( const JTime< JSeparator_t > &  time) const
inline

Less-than method.

Parameters
timetime
Returns
true if this time earlier than given time; else false

Definition at line 88 of file Jeep/JTime.hh.

89  {
90  if (this->hour == time.hour) {
91 
92  if (this->minute == time.minute)
93  return this->second < time.second;
94  else
95  return this->minute < time.minute;
96 
97  } else {
98 
99  return this->hour < time.hour;
100  }
101  }
int second
second
Definition: Jeep/JTime.hh:155
int minute
minute
Definition: Jeep/JTime.hh:154
int hour
hour
Definition: Jeep/JTime.hh:153

Friends And Related Function Documentation

template<char JSeparator_t>
std::istream& operator>> ( std::istream &  in,
JTime< JSeparator_t > &  object 
)
friend

Read time from input stream.

Parameters
ininput stream
objecttime
Returns
input stream

Definition at line 111 of file Jeep/JTime.hh.

112  {
113  using namespace std;
114 
115  object = JTime();
116 
117  string buffer;
118 
119  if (in >> buffer) {
120 
121  for (string::iterator i = buffer.begin(); i != buffer.end(); ++i) {
122  if (*i == JTime::SEPARATOR) {
123  *i = ' ';
124  }
125  }
126 
127  istringstream is(buffer);
128 
129  if (! (is >> object.hour >> object.minute >> object.second)) {
130  in.setstate(is.rdstate());
131  }
132  }
133 
134  return in;
135  }
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
is
Definition: JDAQCHSM.chsm:167
int second
second
Definition: Jeep/JTime.hh:155
int minute
minute
Definition: Jeep/JTime.hh:154
static const char SEPARATOR
Separation character.
Definition: Jeep/JTime.hh:36
int hour
hour
Definition: Jeep/JTime.hh:153
JTime()
Default constructor.
Definition: Jeep/JTime.hh:42
template<char JSeparator_t>
std::ostream& operator<< ( std::ostream &  out,
const JTime< JSeparator_t > &  object 
)
friend

Write time to output stream.

Parameters
outoutput stream
objecttime
Returns
output stream

Definition at line 145 of file Jeep/JTime.hh.

146  {
147  return out << FILL(4,'0') << object.hour << JTime::SEPARATOR
148  << FILL(2,'0') << object.minute << JTime::SEPARATOR
149  << FILL(2,'0') << object.second << FILL();
150  }
Auxiliary data structure for sequence of same character.
Definition: JPrint.hh:361
static const char SEPARATOR
Separation character.
Definition: Jeep/JTime.hh:36

Member Data Documentation

template<char JSeparator_t>
const char JEEP::JTime< JSeparator_t >::SEPARATOR = JSeparator_t
static

Separation character.

Definition at line 36 of file Jeep/JTime.hh.

template<char JSeparator_t>
int JEEP::JTime< JSeparator_t >::hour

hour

Definition at line 153 of file Jeep/JTime.hh.

template<char JSeparator_t>
int JEEP::JTime< JSeparator_t >::minute

minute

Definition at line 154 of file Jeep/JTime.hh.

template<char JSeparator_t>
int JEEP::JTime< JSeparator_t >::second

second

Definition at line 155 of file Jeep/JTime.hh.


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