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::JDate< JSeparator_t > Struct Template Reference

Auxiliary class for simple date. More...

#include <JDate.hh>

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

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

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

Static Public Attributes

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

Friends

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

Detailed Description

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

Auxiliary class for simple date.

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/JDate.hh.

Constructor & Destructor Documentation

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

Default constructor.

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

42  :
43  year (0),
44  month(0),
45  day (0)
46  {}
int year
year
Definition: Jeep/JDate.hh:153
int month
month
Definition: Jeep/JDate.hh:154
int day
day
Definition: Jeep/JDate.hh:155
template<char JSeparator_t>
JEEP::JDate< JSeparator_t >::JDate ( const int  year,
const int  month,
const int  day 
)
inline

Constructor.

Parameters
yearyear
monthmonth
dayday

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

58  :
59  year (year),
60  month(month),
61  day (day)
62  {}
int year
year
Definition: Jeep/JDate.hh:153
int month
month
Definition: Jeep/JDate.hh:154
int day
day
Definition: Jeep/JDate.hh:155
template<char JSeparator_t>
JEEP::JDate< JSeparator_t >::JDate ( const std::string &  date)
inline

Constructor.

Parameters
datedate

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

71  {
72  std::istringstream in(date);
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 JDate JEEP::JDate< JSeparator_t >::min ( )
inlinestatic

Minimal date.

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

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

Maximal date.

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

template<char JSeparator_t>
bool JEEP::JDate< JSeparator_t >::less ( const JDate< JSeparator_t > &  date) const
inline

Less-than method.

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

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

89  {
90  if (this->year == date.year) {
91 
92  if (this->month == date.month)
93  return this->day < date.day;
94  else
95  return this->month < date.month;
96 
97  } else {
98 
99  return this->year < date.year;
100  }
101  }
int year
year
Definition: Jeep/JDate.hh:153
int month
month
Definition: Jeep/JDate.hh:154
int day
day
Definition: Jeep/JDate.hh:155

Friends And Related Function Documentation

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

Read date from input stream.

Parameters
ininput stream
objectdate
Returns
input stream

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

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

Write date to output stream.

Parameters
outoutput stream
objectdate
Returns
output stream

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

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

Member Data Documentation

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

Separation character.

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

template<char JSeparator_t>
int JEEP::JDate< JSeparator_t >::year

year

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

template<char JSeparator_t>
int JEEP::JDate< JSeparator_t >::month

month

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

template<char JSeparator_t>
int JEEP::JDate< JSeparator_t >::day

day

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


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