Jpp  master_rocky
the software that should make you happy
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< JFirst_t, JSecond_t > JDATABASE::JDateAndTime_t JDATABASE::JDatim_t JDATABASE::JDateAndTimeUS_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 hh<separator>mm<separator>ss, where hh corresponds to the hour, mm to the minutes and ss to the seconds.
The separator is defined by the template parameter.

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

Constructor & Destructor Documentation

◆ JTime() [1/3]

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

Default constructor.

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

50  :
51  hour (0),
52  minute(0),
53  second(0)
54  {}
int second
second
Definition: Jeep/JTime.hh:155
int minute
minute
Definition: Jeep/JTime.hh:154
int hour
hour
Definition: Jeep/JTime.hh:153

◆ JTime() [2/3]

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 64 of file Jeep/JTime.hh.

66  :
67  hour (hour),
68  minute(minute),
69  second(second)
70  {}

◆ JTime() [3/3]

template<char JSeparator_t>
JEEP::JTime< JSeparator_t >::JTime ( const std::string &  time)
inline

Constructor.

Parameters
timetime

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

79  {
80  std::istringstream in(time);
81 
82  in >> *this;
83  }

Member Function Documentation

◆ min()

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

Minimal time.

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

◆ max()

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

Maximal time.

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

◆ less()

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 96 of file Jeep/JTime.hh.

97  {
98  if (this->hour == time.hour) {
99 
100  if (this->minute == time.minute)
101  return this->second < time.second;
102  else
103  return this->minute < time.minute;
104 
105  } else {
106 
107  return this->hour < time.hour;
108  }
109  }

Friends And Related Function Documentation

◆ operator>>

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 119 of file Jeep/JTime.hh.

120  {
121  using namespace std;
122  using namespace JPP;
123 
124  object = JTime();
125 
126  while (isspace(in.peek())) { in.ignore(); }
127 
128  const locale loc = in.imbue(locale(in.getloc(), new JWhiteSpacesFacet(in.getloc(), JTime::SEPARATOR)));
129 
130  in >> object.hour >> object.minute >> object.second;
131 
132  in.imbue(loc);
133 
134  return in;
135  }
Auxiliary class to specify white space character(s) in currect locale.
char * loc(char *orig)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
static const char SEPARATOR
Separation character.
Definition: Jeep/JTime.hh:44
JTime()
Default constructor.
Definition: Jeep/JTime.hh:50

◆ operator<<

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(2,'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: JManip.hh:330

Member Data Documentation

◆ SEPARATOR

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

Separation character.

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

◆ hour

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

hour

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

◆ minute

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

minute

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

◆ second

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: