Jpp
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
JDATABASE::JDate_t Struct Reference

Auxiliary class for integration date. More...

#include <JDetectorIntegration.hh>

Inheritance diagram for JDATABASE::JDate_t:
JLANG::JComparable< JDate_t >

Public Member Functions

 JDate_t ()
 Default constructor. More...
 
 JDate_t (const int year, const int month, const int day)
 Constructor. More...
 
bool less (const JDate_t &date) const
 Less-than method. More...
 

Static Public Member Functions

static JDate_t min ()
 Minimal date. More...
 
static JDate_t max ()
 Maximal date. More...
 

Public Attributes

int year
 year More...
 
int month
 month More...
 
int day
 year More...
 

Static Public Attributes

static const char SEPARATOR = '/'
 Separation character. More...
 

Friends

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

Detailed Description

Auxiliary class for integration date.

The corresponding ASCII format is "yyyy/mm/dd".

Definition at line 40 of file JDetectorIntegration.hh.

Constructor & Destructor Documentation

◆ JDate_t() [1/2]

JDATABASE::JDate_t::JDate_t ( )
inline

Default constructor.

Definition at line 52 of file JDetectorIntegration.hh.

52  :
53  year (0),
54  month(0),
55  day (0)
56  {}

◆ JDate_t() [2/2]

JDATABASE::JDate_t::JDate_t ( const int  year,
const int  month,
const int  day 
)
inline

Constructor.

Parameters
yearyear
monthmonth
dayday

Definition at line 66 of file JDetectorIntegration.hh.

68  :
69  year (year),
70  month(month),
71  day (day)
72  {}

Member Function Documentation

◆ min()

static JDate_t JDATABASE::JDate_t::min ( )
inlinestatic

Minimal date.

Definition at line 75 of file JDetectorIntegration.hh.

◆ max()

static JDate_t JDATABASE::JDate_t::max ( )
inlinestatic

Maximal date.

Definition at line 76 of file JDetectorIntegration.hh.

◆ less()

bool JDATABASE::JDate_t::less ( const JDate_t date) const
inline

Less-than method.

Parameters
datedate
Returns
true if this date earlier than given date; else false

Definition at line 85 of file JDetectorIntegration.hh.

86  {
87  if (this->year == date.year) {
88 
89  if (this->month == date.month)
90  return this->day < date.day;
91  else
92  return this->month < date.month;
93 
94  } else {
95 
96  return this->year < date.year;
97  }
98  }

Friends And Related Function Documentation

◆ operator>>

std::istream& operator>> ( std::istream &  in,
JDate_t object 
)
friend

Read date from input stream.

Parameters
ininput stream
objectdate
Returns
input stream

Definition at line 108 of file JDetectorIntegration.hh.

109  {
110  using namespace std;
111 
112  object = JDate_t();
113 
114  string buffer;
115 
116  if (in >> buffer) {
117 
118  for (string::iterator i = buffer.begin(); i != buffer.end(); ++i) {
119  if (*i == JDate_t::SEPARATOR) {
120  *i = ' ';
121  }
122  }
123 
124  istringstream is(buffer);
125 
126  is >> object.year >> object.month >> object.day;
127 
128  in.setstate(is.rdstate());
129  }
130 
131  return in;
132  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const JDate_t object 
)
friend

Write date to output stream.

Parameters
outoutput stream
objectdate
Returns
output stream

Definition at line 142 of file JDetectorIntegration.hh.

143  {
144  return out << object.year << JDate_t::SEPARATOR
145  << object.month << JDate_t::SEPARATOR
146  << object.day;
147  }

Member Data Documentation

◆ SEPARATOR

const char JDATABASE::JDate_t::SEPARATOR = '/'
static

Separation character.

Definition at line 46 of file JDetectorIntegration.hh.

◆ year

int JDATABASE::JDate_t::year

year

Definition at line 150 of file JDetectorIntegration.hh.

◆ month

int JDATABASE::JDate_t::month

month

Definition at line 151 of file JDetectorIntegration.hh.

◆ day

int JDATABASE::JDate_t::day

year

Definition at line 152 of file JDetectorIntegration.hh.


The documentation for this struct was generated from the following file:
JDATABASE::JDate_t::year
int year
year
Definition: JDetectorIntegration.hh:150
JDATABASE::JDate_t::JDate_t
JDate_t()
Default constructor.
Definition: JDetectorIntegration.hh:52
JDATABASE::JDate_t::SEPARATOR
static const char SEPARATOR
Separation character.
Definition: JDetectorIntegration.hh:46
JDATABASE::JDate_t::day
int day
year
Definition: JDetectorIntegration.hh:152
JDATABASE::JDate_t::month
int month
month
Definition: JDetectorIntegration.hh:151
std
Definition: jaanetDictionary.h:36