AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
iDatePartFormatter.hpp
1 /*
2  ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3  Copyright (C) 2012 Vincent Lachenal
4 
5  This file is part of ANCH Framework.
6 
7  ANCH Framework is free software: you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  ANCH Framework is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef _ANCH_DATE_FORMATTER_I_DATE_PART_FORMATTER_H_
21 #define _ANCH_DATE_FORMATTER_I_DATE_PART_FORMATTER_H_
22 
23 #include <iostream>
24 #include <ostream>
25 
26 #include "date/date.hpp"
27 
28 
29 namespace anch {
30  namespace date {
31  namespace formatter {
32 
39  public:
43  virtual ~IDatePartFormatter() {
44  // Nothing to do
45  }
46 
53  virtual void format(const anch::date::Date& date, std::ostream& output) const noexcept = 0;
54 
60  virtual size_t getSize() const noexcept = 0;
61 
68  virtual bool setValue(anch::date::Date& date, const std::string& value) const noexcept = 0;
69 
75  virtual const std::string& getPattern() const noexcept = 0;
76 
77  // Accessors +
78  protected:
84  inline static int32_t getYear(const anch::date::Date& date) {
85  return date._years;
86  }
87 
94  inline static void setYear(anch::date::Date& date, int32_t year) {
95  date._years = year;
96  }
97 
103  inline static uint16_t getMonth(const anch::date::Date& date) {
104  return date._months;
105  }
106 
113  inline static void setMonth(anch::date::Date& date, uint16_t month) {
114  date._months = month;
115  }
116 
122  inline static uint16_t getDay(const anch::date::Date& date) {
123  return date._mdays;
124  }
125 
132  inline static void setDay(anch::date::Date& date, uint16_t mday) {
133  date._mdays = mday;
134  }
135 
141  inline static uint16_t getHour(const anch::date::Date& date) {
142  return date._hours;
143  }
144 
151  inline static void setHour(anch::date::Date& date, uint16_t hour) {
152  date._hours = hour;
153  }
154 
160  inline static uint16_t getMinute(const anch::date::Date& date) {
161  return date._minutes;
162  }
163 
170  inline static void setMinute(anch::date::Date& date, uint16_t minute) {
171  date._minutes = minute;
172  }
173 
179  inline static uint16_t getSecond(const anch::date::Date& date) {
180  return date._seconds;
181  }
182 
189  inline static void setSecond(anch::date::Date& date, uint16_t second) {
190  date._seconds = second;
191  }
192 
198  inline static uint16_t getMillisecond(const anch::date::Date& date) {
199  return date._milliseconds;
200  }
201 
208  inline static void setMillisecond(anch::date::Date& date, uint16_t milli) {
209  date._milliseconds = milli;
210  }
211 
217  inline static uint16_t getMicrosecond(const anch::date::Date& date) {
218  return date._microseconds;
219  }
220 
227  inline static void setMicrosecond(anch::date::Date& date, uint16_t micro) {
228  date._microseconds = micro;
229  }
230 
236  inline static uint16_t getNanosecond(const anch::date::Date& date) {
237  return date._nanoseconds;
238  }
239 
246  inline static void setNanosecond(anch::date::Date& date, uint16_t nano) {
247  date._nanoseconds = nano;
248  }
249  // Accessors -
250  };
251 
252  }
253  }
254 }
255 
256 #endif // _ANCH_DATE_FORMATTER_I_DATE_PART_FORMATTER_H_
static uint16_t getMicrosecond(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:217
static void setMinute(anch::date::Date &date, uint16_t minute)
Definition: iDatePartFormatter.hpp:170
static int32_t getYear(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:84
virtual void format(const anch::date::Date &date, std::ostream &output) const noexcept=0
static uint16_t getMonth(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:103
static uint16_t getDay(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:122
static void setMillisecond(anch::date::Date &date, uint16_t milli)
Definition: iDatePartFormatter.hpp:208
virtual size_t getSize() const noexcept=0
static uint16_t getSecond(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:179
AnCH framework base namespace.
Definition: base64.hpp:28
static uint16_t getHour(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:141
static void setHour(anch::date::Date &date, uint16_t hour)
Definition: iDatePartFormatter.hpp:151
Definition: iDatePartFormatter.hpp:38
static uint16_t getNanosecond(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:236
static void setYear(anch::date::Date &date, int32_t year)
Definition: iDatePartFormatter.hpp:94
static void setNanosecond(anch::date::Date &date, uint16_t nano)
Definition: iDatePartFormatter.hpp:246
static uint16_t getMinute(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:160
virtual ~IDatePartFormatter()
Definition: iDatePartFormatter.hpp:43
static void setMonth(anch::date::Date &date, uint16_t month)
Definition: iDatePartFormatter.hpp:113
static void setSecond(anch::date::Date &date, uint16_t second)
Definition: iDatePartFormatter.hpp:189
static void setMicrosecond(anch::date::Date &date, uint16_t micro)
Definition: iDatePartFormatter.hpp:227
static uint16_t getMillisecond(const anch::date::Date &date)
Definition: iDatePartFormatter.hpp:198
static void setDay(anch::date::Date &date, uint16_t mday)
Definition: iDatePartFormatter.hpp:132
Definition: date.hpp:47
virtual const std::string & getPattern() const noexcept=0
virtual bool setValue(anch::date::Date &date, const std::string &value) const noexcept=0